How to use FlashVars with ActionScript 3.0?

I found this guide for using flash options, I thought it might be useful to post here, because Flash CS3 has no use case for reading these options.

See answers to the link

+4
source share
2 answers

I don't know why his example calls LoaderInfo. The DisplayObject class has its own (read-only) loaderinfo property. As long as your main class extends DisplayObject, you can directly call this property

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 in which this display object belongs. The loaderInfo property is defined only for the root display object of the SWF file or for the loaded bitmap (not for the Bitmap that is drawn using ActionScript). To find the loaderInfo object associated with a SWF file that contains a display object named myDisplayObject, use myDisplayObject.root.loaderInfo.

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

The entire article is located 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 try to load the parameters in a subclass, you will not get anything.

+1
source

Source: https://habr.com/ru/post/1276977/


All Articles