Loading Cookies...
Check HTML restrictions in SWF. Determine AllowScriptAccess and AllowNetworking with AS3

As I was digging around the allowNetworking setting and how the SWF can determine it at runtime, I decided to go deeper and catch other types of embedding restrictions, like the allowScriptAccess parameter. I've seen sites that block outgoing links of certain flash files - in most cases flash games are prevented to access the web, resulting in negative effect over their authors - the game developers.

Here are the allowed settings for both HTML parameters:

allowScriptAccess:["always" / "sameDomain" / "never"]
allowNetworking:["all" / "internal" / "none"]

The following useful script determines any of the mentioned restrictions:

if (Capabilities.playerType != "External" &&
Capabilities.playerType != "StandAlone"){ var url:String; try{ navigateToURL(new URLRequest(null)); } catch (err:*){ if(err is SecurityError){ trace("SECURITY ERROR::allowNetworking is disabled!"); throw new Error("ERROR::allowNetworking is disabled!\n"+err); } else { trace("SECURITY::allowNetworking is OK!"); } } try{ if (ExternalInterface.available){ url = ExternalInterface.call("window.location.href.toString"); } else { url = _stage.loaderInfo.loaderURL; } trace("SECURITY::allowScriptAccess is OK!"); } catch(err:*){ if(err is SecurityError){ trace("SECURITY::allowScriptAccess is disabled!"); } else { trace("SECURITY::Unknown Error!",err);
} }

The script first checks if it is running in a browser online with Capabilities.playerType, then tries a null URLRequest to determine the allowNetworking setting.

If allowNetworking is set to "all" the compiler will throw a TypeError, otherwise with "internal" or "none" setting there will be a SecurityError.

Next allowScriptAccess is verified using ExternalInterface in attempt to retrieve the current URL with the javascript call "window.location.href.toString".

Again a SecurityError will differentiate "always" from "sameDomain" and "never".

Finally an "url" var is available for further evaluation, domain check or tracking purpose.

For convenience, I'll include the import statements as well:
import flash.net.URLRequest; 
import flash.net.navigateToURL;
import flash.system.Capabilities;
import flash.external.ExternalInterface;
(It's a hard quest to import classes manually after a copied snippet, isn't it :)

Let me know if you have issues with the above code. Thanks.


In the previous part, we learned about the basics of the Apple II Hi-Res graphics mode, allowing us to display up to six colors on a 280x192 pixel screen. Today, we will explore the Double Hi-Res mode, its 16 colors and doubled resolution, how it works, the memory it occupies and what are its advantages and challenges...

Read more

Flash was once the dominant web technology for creating interactive and multimedia content. It powered countless websites, games, animations, and videos that entertained and educated millions of users. However, Flash also had many drawbacks, such as security issues, performance problems, and compatibility challenges. As newer web standards like HTML5 emerged, Flash became obsolete and was eventually discontinued by Adobe in 2020...

Read more

Have you ever stumbled upon an old blog post that you wish you could read again? What if that blog post was about something you're passionate about, like retro computers and programming? Unfortunately, many old blog posts are no longer available online today. But don't worry! Thanks to the WayBackMachine - an internet archive that provides backups of webpages throughout the years - you can still access these precious internet resources. In fact, it's important that we make sure these resources are available to the public again so that we can continue to learn from them and appreciate their value. That's why I'm excited to share with you a blog post about Apple II programming, especially about its Double Hi-Res graphics mode, originally published in BattleStations...

Read more

JS13K games is Javascript golfing competition that runs for a month between August 13th and September 13th every year. The game jam has one main characteristic - the entire game (source code, graphics, sounds etc.) must be contained in a 13 kilobytes ZIP archive, as constrained by the creator of the compo, Andrzej Mazur (@end3r)...

Read more

The Puzzle of Life was created during Castle Game Jam 2018 by Noncho Savov (me, programming) and Jurgita Raynite (art). The Game Jam was organized by James Newnorth (Spelkollektivet) and was held in a medieval castle located in Örebro, Sweden between the 7th and 15th of July. The main theme of the jam was "Capricious"...

Read more

My upcoming rogue-like role playing game RogueVerse Dungeon was showcased at Retrospelsmässan - one of the largest retro game conventions in the world! The convention is held every year in Gothenburg Sweden and I presented my game as part of Spelkollektivet exhibition. It was an amazing experience - I managed to collect a great portion of feedback from attendees of all ages.. and it was incredible to see a little girl beating my game:..

Read more

Check out my new game Formation Absent - a turn-based tactical puzzle, which is easy to win but hard to master. A game that is only 13 kilobytes, submission in JS13K competition. Theme of the competition this year is "Lost". As per Compo rules the game is contained in 13kb archive and includes 13 stages and a level editor. The game also keeps your game progress and score through utilizing URL vars. Here is an example of the gameplay:..

Read more

Each year, a unique JavaScript game development competition takes place within one month, starting on August 13th, named JS13KGames. What's interesting about this competition is that there is a filesize limit requirement on the submitted game source - the entire game must be packed in 13kB ZIP archive. In 2016, I participated with Skip'n Glitch, a two player competitive logical game involving strategy and arithmetics. The game has a single player mode set against a simple and predictable but challenging AI opponent. Two players can play against each other on the same device...

Read more

As the web tech is evolving, the flash player for web browsers is getting more and more obsolete. For example the biggest advertising platform - Google's DoubleClick dropped support for flash ads. I'm not speaking against the flash technology, which is still viable for game development (it can be easily compiled for mobile or wrapped into Steam). However in web there are new heroes and one of them is the HTML Canvas. I've already shared some lightweight JavaScript libraries used in #js13kgames and today I'm sharing another class - Lens Flare effect!..

Read more