Processing of SwF passing parameters and flashvars in actionscript3

Source: Internet
Author: User

The webpage can pass variables to flash through the SWF address and pass them as value pairs, as shown below:

<Object classid = "CLSID: d27cdb6e-ae6d-11cf-96b8-444553540000"
Id = "loaderinfosample" width = "100%" Height = "100%"
Codebase = "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<Param name = "movie" value = "loaderinfosample.swf? A = 1 & B = 2 "/>
<Param name = "quality" value = "high"/>
<Param name = "bgcolor" value = "#869ca7"/>
<Param name = "allowScriptAccess" value = "samedomain"/>
<Embed src = "loaderinfosample.swf? A = 1 & B = 2 "Quality =" high "bgcolor =" #869ca7"
Width = "100%" Height = "100%" name = "loaderinfosample" align = "Middle"
Play = "true"
Loop = "false"
Quality = "high"
AllowScriptAccess = "samedomain"
Type = "application/X-Shockwave-flash"
Pluginspage = "http://www.adobe.com/go/getflashplayer">
</Embed>
</Object>

In actionsrippt2, the two variables passed in can be directly referenced at the first frame.
As3 abandons this nonstandard usage and agrees to use the parameter attribute of loaderinfo to complete the process.

Loaderinfo help documentation see: http://livedocs.macromedia.com/L... lay/loaderinfo.html
The loaderinfo class is specially designed to save the loading information of SWF, images, or any other displayobject.
The SwF parameter is also part of the loading information. It can be obtained through the parameters attribute of loaderinfo. The result is an array and its value can be traversed through for... in.

The sample code is as follows:
Package org. flashbbs. Sample
{
Import flash. display. movieclip;
Import flash. display. loaderinfo;
Import flash. Text. textfield;

Public class loaderinfosample extends movieclip
{
Public Function loaderinfosample (){
Var key: string;
VaR value: string;
VaR text1: textfield = new textfield ();
Addchild (text1 );
VaR Param: Object = This. Root. loaderinfo. parameters;
For (Key In Param ){
Value = string (Param [Key]);
Text1.appendtext (Key + "=" + value );
}
}
}
}

Note that loaderinfo belongs to the as3 class. If Flash contains the code of AS1 or As2, it cannot retrieve the value and can only retrieve null.

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.