Question

I found this guide for using the flash parameters, thought it might be useful to post here, since Flash CS3 lacks a usage example for reading these parameters.

See answers for the link

Was it helpful?

Solution

Not sure why his example calls LoaderInfo. The DisplayObject class has its own (readonly) loaderinfo property. As long as your main class extends a DisplayObject, you can call the property directly

package {
    import flash.display.Sprite;

    public class Main extends Sprite {

        public function Main() {
            var test1:String    = '';

            if (this.loaderInfo.parameters.test1 !== undefined) {
                test1 = this.loaderInfo.parameters.test1;
            }
        }
    }
}

From the doc:

Returns a LoaderInfo object containing information about loading the file to which this display object belongs. The loaderInfo property is defined only for the root display object of a SWF file or for a loaded Bitmap (not for a Bitmap that is drawn with ActionScript). To find the loaderInfo object associated with the SWF file that contains a display object named myDisplayObject, use myDisplayObject.root.loaderInfo.

OTHER TIPS

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;

The entire article is at:

http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html

Important note! This will only work in the main class. If you'll try to load the parameters in a subclass you'll get nothing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top