AS2 to AS3 migration – Where did getURL go?

1

Posted by Tyler Madison | Posted in Actionscript Tips | Posted on 13-07-2009

There are lots of reasons for the upgrade to the URLRequest object from AS2’s getURL method. The major reason is that the URLRequest contains all of the HTTP information for a specific url request, content headers , get or post methodsĀ  , content type etc. BUT the downside is that it takes a little more effort and importing to get the same functionality as the AS2 standard getURL method. So I’ve include a simple global getURL class that you just need to import wherever it is used, then you can just call “getURL” as it worked in AS2, but now for AS3. The function takes two parameters; The first is the URL that you want to direct to, the second and optional parameter is the window method(“_blank” , “_self” , “_parent” ) which defaults to “_blank”.

The simplest implementation would be:

import getURL;
getURL("http://www.google.com");

Download getURL class here!

ENJOY!

* This is really only useful when you just need to launch a single url without special data being sent, as there is no access to the URLRequest object specifically.

Awesome Actionscript library – CASA Lib

2

Posted by Tyler Madison | Posted in Actionscript Tips | Posted on 10-07-2009

I’ve been going back and forth between frameworks, utilities, and tool kits for a while now, adding to, adapting or re-writing many common things that I thought I could make better / more useful. Then I found CASA lib. This library covers some of the most common and tedious aspects of being a Flash developer that are out there. Preloading assets, multiple assets, preloading video , and the granular detail that goes into those things. You don’t have to worry about managing the URLLoaders for XML loading or the NetStream objects’ events. You basically as one info commercial host famously once said, “Just set it and forget it, it’s that easy”. But its true, there are a host (no pun intended) or utilities in here that will not only make your production time faster, will put your mind at ease that you don’t have to come up with a custom system every time you run into the same problems. Okay I am done boasting, just really excited to announce that I’ve added into a scaffold ed framework: TweenLite, PureMVC, CASA lib and SWFAddress for all of my new projects! What else could you ask for , someone to do the work for you? Well in short, these fine folks pretty much have…now you just get to do the fun part!

Check out CASA lib!

Flash CS4 Preloading Exported Classes

2

Posted by Tyler Madison | Posted in Actionscript Tips | Posted on 10-07-2009

I have been utilizing AS3 for a little over 3 years and have always wanted to have the same control over preloading assets in my main .FLA , as I did with AS2. The main difference is that with Flash CS4 and AS3 , you can truly export your classes on a desired frame without having to dump all of the linked library assets on the stage prior to instantiating any of those exported assets with actionscript. This also allows you to keep the “Document Class” or main application class the entry point for the application.

Here’s the trick:

  1. 1. Go to File > Publish Settings > Click on the Flash tab. Under the player version next where it says script type , click on the “Settings” button. Where it says “Export classes in frame” type anything BUT 1 (2 is my standard). Click the ok buttons to exit out of those dialogs.
  2. Create a new MovieClip symbol in the library.
  3. In the Symbol Properties Dialog where it says “Linkage” click the checkbox that says “Export for ActionScript” , make sure the name of the symbol is the name of the class that you are using as your main application class or “Document Class”.
  4. Now all you have to do is instantiate a ExportTroller object and pass it the main movieclip reference (this) , the name of your main application class , the frameĀ  number you targeted for exporting your classes on in step 1, and optionally an update method to monitor download progress of the .SWF. (JUST LIKE in AS2!).
  5. publish the movie and you can see if you bring up the bandwidth profiler that the bulk of the .swf bytes has been deffered until your export frame! So you can do anything you want in the first frame to show progress, and get the user to start viewing your swf right away instead of waiting until the whole .swf has completely downloaded before they see anything,

If you followed the steps above correctly this is the only code you should need in your whole .FLA to get this to work!

//import the trolling class
import info.tylermadison.ExportTroller;

//instantiates the trolling object
var troller:ExportTroller = new ExportTroller(this , “Main” , 2 , updateMethod);

//the optional but recommended update method to show download progress
function updateMethod(prct:Number):void{
iLoader.width = prct * stage.stageWidth;
}

Download the source and demo Here!