AS3 obtain SWF Parameters

Source: Internet
Author: User
In AS2, you can add parameters to the end of flash, for example, demo.swf? U1 = good & u2 = bad
In flash, u1 and u2 are the root variables by default. You can use _ root. u1 and _ root. u2 to obtain the value.
But in as3.
To use the parameters attribute of the flash. display. loaderInfo class, a parameter object is returned.
Usage:
For example, defining var param: Object = root. loaderInfo. parameters in the document class;
If the value of u1 is obtained, you can use param ["u1"], and the same u2 value: param ["u2"]

The document class is as follows:Package{

Import Flash.Display.Sprite;
Import Flash.Display.Stage;
Import Flash.Display.StageScaleMode;
Import Flash. Text.TextField;
Import Flash. Text.TextFieldAutoSize;

PublicClass LoaderInfoDemoExtends Sprite{

Public FunctionLoaderInfoDemo (){

Stage. scaleMode =StageScaleMode. NO_SCALE;

VarOut_txt:TextField= CreateText ();
Out_txt.border =True;
Out_txt.borderColor = 0xFF6600;
Out_txt.y = 20;
AddChild (out_txt );

VarInfo_txt:TextField= CreateText ();
Info_txt.text = "Modify loaderinfodemo.swf? Msg = xxx value in xxx, and then press ENTER ";
Info_txt.autoSize =TextFieldAutoSize. LEFT;
AddChild (info_txt );

VarParam:Object= Root. loaderInfo. parameters;
If(Param ["msg"]! =Null){
Out_txt.text = param ["msg"];
Trace("Value:" + param ["msg"]);
}Else{
Out_txt.text = "null ";
Trace("Value: null ");
}
}

Private FunctionCreateText ():TextField{
VarTmp:TextField=New TextField();
Tmp. selectable =False;
Tmp. width = 100;
Tmp. height = 20;
ReturnTmp;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.