Archive for March, 2009

Structure Creator 1.1.6 Out Now!

Thursday, March 26th, 2009
Structure Creator

Structure Creator 1.1.6 extension for Flash is now available. It will now save your last used schema, width, height and frame rate.

Get it from Google Code

I'd appreciate your feedback. Thanks.

Use SharedObject to save data on users computer

Tuesday, March 24th, 2009

By using SharedObject you are able to store limited amounts of data on a user's computer. It's works in the same kind of way that your browser stores cookies. However there are some limitations with using this. Sometimes swf files may not be able to write the data, and the data can sometimes be deleted without your knowledge. Users can set their own limits on how much space flash player can use on their computer. When they lower the amount of disk space available, some local shared objects might get removed.

I'll show you a basic example of using SharedObject. We will have an input text field on stage and a button that will save the text in the text field.

Create a new AS3 Document and put a text field on stage and give it an instance name. I will call mine theText_txt.
Next make a button on stage and give it an instance name. I called mine save_btn.

Create a new layer in the main timeline and call it actions and lock it. Open up the actions panel and enter the following:

  1. var mySO:SharedObject;
  2. mySO = SharedObject.getLocal("myfirstSO");

The first line creates the shared object. The second line gets a local shared object called myfirstSO. Nothing is stored in it at the moment but we will assign data to it shortly.

Now when we click the button we want to assign whatever text is in the text field to the shared object. In the actions panel enter:

  1. save_btn.addEventListener(MouseEvent.CLICK, saveText);
  3. function saveText(e:MouseEvent):void
  4. {
  5. = theText_txt.text;
  6. }

This has now assigned the text in the text field to a variable called myText in the SharedObject.

OK now that the text is saved we will want to populate the text field with that saved data when you open the swf again. In the actions panel enter the following.

  1. if (
  2. {
  3. theText_txt.text =;
  4. }

This checks to see if there is any data in the myText variable in the SharedObject. If there is then it assigns that value to the text field.

Now test the movie. Enter some text in the text field and click your save button. Close the swf and test the movie again. You will see that the text you entered before is in the text field.

You can download the example here:

Hope this was helpful,

Instance names and code hinting – Tips & Tricks

Monday, March 2nd, 2009

code_hintingWhen coding in actionscript sometimes it can be a pain that you don't get code hinting with objects that are on stage. A good way of overcoming this is to change the instance names of your objects (Movie Clips, Buttons, etc.) to have an underscore "_" then the abbreviated name of that object at the end of the name.

For example, you may have a movie clip on stage called myMovieClip. Change the instance name to have an _mc at the end (myMovieClip_mc), and now in your actions panel type myMovieClip_mc and press period. You will now see all the code hinting for a movie clip popup (see image). This can save a whole heap of time when coding.

Here is a list of the different shortcuts that you can use to bring up the code hinting. Some of these are for AS2 but the rest will work with AS3.

Object type Variable suffix
Array _array
Button _btn
Camera _cam
Color _color
ContextMenu _cm
ContextMenuItem _cmi
Date _date
Error _err
LoadVars _lv
LocalConnection _lc
Microphone _mic
MovieClip _mc
MovieClipLoader _mcl
PrintJob _pj
NetConnection _nc
NetStream _ns
SharedObject _so
Sound _sound
String _str
TextField _txt
TextFormat _fmt
Video _video
XML _xml
XMLNode _xmlnode
XMLSocket _xmlsocket

I find that using this technique saves me a whole heap of time when programming.