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
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
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.
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.
I am having the same problem also. It is working fine when I am using as a main class but when I import it in any other class file and then making object then it giving me error
TypeError: Error #1009: Cannot access a property or method of a null object reference. at :FlashVarsParam$iinit()
Any help please tell me
Thanks in advance
Sunil Kumar