GhostWire Studios - Flash/Flex UI Components Development And Consulting Services
Quality User Interface Controls For Flash Application DevelopmentAspireUI Components

Archive for the 'Flash AS3' Category

Nov 12 2009

[AS3] Applying ROT128 Encryption On ByteArray

Published by under Flash,Flash AS3,Tips

In this post, we will look at a very simple algorithm for weak encryption. You should not use this method for real cryptographic security. However, because it is so simple to implement, the light-weight algorithm could easily escape prying eyes and avoid being the target for decryption in the first place.

I should also clarify that the term “ROT128″ does not actually exist. The original idea comes from ROT13, a variant of the Caesar Cipher (named after Julius Caesar of ancient Rome who used it to encrypt messages, but it is not clear who first invented or started using the cipher).

Continue Reading »

No responses yet

Nov 07 2009

[AS3] Simple Editor For Loading And Saving XML As Binary

Published by under Flash,Flash AS3,Tips

This post is a supplement to “Saving XML As Binary”.

As mentioned in the previous post, you can save XML in binary and get the benefits of compression, but doing so would make it impossible to edit the data through a text editor.

This post explores a simple tool you can create easily using Flash/ActionScript 3, a tool that will allow you (or your clients and end-users) to load, read, edit and save XML in compressed binary format. As shown below, this is a minimalist approach – feel free to beautify and/or customize it to fit your own requirements.

You can find the source code at the end of this post. The code does not use any UI component, not from Aspire UI, Flex or Flash, just plain native Flash Player classes so you can compile the AS3 class alone without any additional library.

Continue Reading »

10 responses so far

Nov 06 2009

[AS3] Saving XML As Binary

Published by under Flash,Flash AS3,Tips

This could be useful if you have an external large, verbose XML file which your application must load during run-time. By saving the XML as binary, you can compress the data and get a much smaller file. Of course, the amount of compression you can get depends on the complexity of your data, but it would typically be over 50% (conservative estimate).

Admittedly, having the XML data in compressed binary format contradicts the original intention of using XML in the first place – to allow human-readable data. Therefore, you will have to decide what exactly is important for your application before proceeding. Perhaps having cryptic external data is indeed what you want – allowing data to be externalized so they can be changed without requiring the SWF to be recompiled, and yet would prefer the data to be non-human-readable.

Continue Reading »

8 responses so far

Nov 05 2009

[AS3] Hiding the Built-In Native MenuBar (And ContextMenu Items)

Published by under Flash,Flash AS3,Tips

By default, the SWFs you publish will show a native menu bar (the pull down menu showing the items File – View – Control – Help) when run locally. The same case applies to Projector (.exe) files published either from the Adobe Flash IDE, or created from local SWFs using the File – Create Projector… menu item from the native pull down menu.

flash menu bar


In my opinion, this menu does not add any functionality to any Flash application, is as useless as the built-in contextMenu items, and should always be hidden. Luckily, it takes only one line of code to hide the menu.

Continue Reading »

No responses yet

Oct 07 2009

[AS3] Truncating ByteArray Does Not Dispose Contents, Free Up Memory

Published by under Flash,Flash AS3,Tips

When targeting Flash Player 10 or AIR 1.5, you can use the clear() method of the ByteArray class to explicitly clear the contents of the byte array and free up the memory otherwise used by the bytes. The length and position properties are reset to zero after calling the clear() method.

Unfortunately, when targeting Flash Player 9, this clear() method is not available. If you are using a ByteArray object as a data store, keeping a reference to the object and therefore not allowing the object to be garbage collected, do take note that there is no way to clear the contents. This means that the size of ByteArray objects can only be enlarged and never shrunk.

It is important to note that while you can truncate the ByteArray to zero byte by setting its length property to zero, this will not dispose the contents or free up the memory used.

Continue Reading »

2 responses so far

Sep 10 2009

[AS3] Difference Between Stage Size, Screen Size And SWF Size

Published by under Flash,Flash AS3,Tips

In this post, we look at three different pairs of width and height properties that are commonly misunderstood – “stage.width/stage.height“, “stage.stageWidth/stage.stageHeight” and “loaderInfo.width/loaderInfo.height“.

Continue Reading »

4 responses so far

Sep 07 2009

[AS3] Finding Occurrences Of A Sequence Of Bytes Within A ByteArray

Published by under Flash,Flash AS3,Tips

The following is a simple way to search within a ByteArray for specific patterns of bytes. At the end of this post is a ByteArrayUtils class that contains the indexOf(), indicesOf and lastIndexOf() methods discussed below. If you just want to grab the code and skip all the walk-through, please feel free to jump there.

Continue Reading »

No responses yet

Sep 03 2009

[AS3] Domain Locking SWFs

Published by under Flash,Flash AS3,Tips

By domain locking (or site locking), we are restricting the SWF to be run only from a certain domain, ie the SWF should execute normally only if it has been viewed from a certain domain. If it is loaded from other domains, the SWF should execute in an alternative manner – perhaps not run at all, or run with limited features (as the developer deems appropriate). This is usually done to prevent unauthorized re-distributions of SWF files.

Continue Reading »

11 responses so far

Aug 21 2009

[AS3] Hiding Assets And Code By Embedding SWF Within Another SWF

Published by under Flash,Flash AS3,Tips

The technique discussed below is fairly easy to implement and will cost nothing other than a few minutes of your time. You can use this method in conjunction with code obfuscation, encryption or whatever other protection methods – this just adds another layer of protection. While this isn’t going to be a 100% foolproof protection, it is nevertheless better than no protection at all, and should help to deter most if not all casual decompiling.

Continue Reading »

7 responses so far

Aug 18 2009

[AS3] Avoiding NULL Object Reference Error When Loading Module SWF

Published by under Flash,Flash AS3,Tips

When building modular Flash applications, a common error that may be encountered is that related to accessing a property or method of the stage property when it is still null. If a display object is not yet added to the display list, its stage property returns null.

An ActionScript error has occurred: “Cannot access a property or method of a null object reference.”

Quite a cryptic message, especially if you test the module SWF standalone and nothing seems wrong, but the error is thrown when you load the module SWF into a host SWF.

Continue Reading »

10 responses so far

« Prev - Next »