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;
}
}
}
}
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.
发布评论
评论(2)
不知道为什么这个示例调用LoaderInfo。 DisplayObject 类有自己的(只读)< href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#loaderInfo" rel="nofollow noreferrer">loaderinfo 属性。 只要您的主类扩展了 DisplayObject,您就可以直接调用该属性
从文档:
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
From the doc:
整篇文章位于:
http://blogs.adobe.com/pdehaan/ 2006/07/using_flashvars_with_actionscr.html
重要提示! 这仅适用于主类。 如果您尝试在子类中加载参数,您将一无所获。
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.