This is found onlineCode.
Load the FLEX of the sub-SwFProgramCode
<? XML version = "1.0" ?>
< MX: Application Xmlns: MX = "Http://www.adobe.com/2006/mxml" Layout = "Absolute" >
< MX: script >
<! [CDATA [
Import MX. Managers. systemmanager;
Import MX. Controls. label;
[Bindable]
Public var loadedswf: systemmanager;
Private function initnestedappprops (): void {
Loadedswf = systemmanager (myloader. content );
}
Public Function updatelabel (): void {
LBL. Text = loadedswf. application ["text_1"]. text;
}
// Write to the label control in the loaded application.
Public Function updatenestedlabels (): void {
Loadedswf. application ["text_2"]. Text = text_value.text;
}
]>
</ MX: script >
< MX: Label ID = "LBL" X = "204" Y = "69" Fontsize = "12" />
< MX: swfloader ID = "Myloader" Width = "250" Height = "200"
Source = "Subswf.swf"
Creationcomplete = "Initnestedappprops ();" X = "13" Y = "124" />
< MX: button Label = "Get the control value for loading SWF"
Click = "Updatelabel ();" Fontsize = "12" X = "10" Y = "65" />
< MX: button Label = "Modify the control value for loading SWF"
Click = "Updatenestedlabels ();" Fontsize = "12" X = "10" Y = "33" />
< MX: textinput ID = "Text_value" X = "192" Y = "35" Fontsize = "12" />
</ MX: Application >
Sub-SwF program code
<? XML version = "1.0" encoding = "UTF-8" ?>
< MX: Application Xmlns: MX = "Http://www.adobe.com/2006/mxml" Layout = "Absolute" >
< MX: Panel X = "0" Y = "0" Width = "250" Height = "200" Layout = "Absolute" Title = "Loaded SWF file" Fontsize = "12" >
< MX: textinput ID = "Text_1" X = "10" Y = "41" Fontsize = "12" Text = "Hello everyone, I'm flex" />
< MX: textinput ID = "Text_2" X = "10" Y = "88" Fontsize = "12" />
</ MX: Panel >
</ MX: Application >
If you need to call the sub-SwF method, you can convert the loadswf application to an object, and then call the method in the sub-SWF. Otherwise, the method cannot be found.
VaRLoadswf: systemmanager=Systemmanager (myloader. content );
(Loadswf. Application as object). Test ();
Source code download
#===================================================== ==========================================================
Later, I found that the above Code is still risky. If the SWF file to be loaded is large, the value of application in item_loadswf may be null.
Below is a piece of code I added.
Supplemental code Private VaR _ Loadswf: systemmanager;
Private VaR Content: image;
Private Function Onloadcompleted (Event: Event ): Void
{
_ Loadswf = systemmanager (content. content);
_ loadswf. addeventlistener (flexevent. application_complete, swfready);
function swfready (Event: flexevent): void
{< br> _ loadswf. removeeventlistener (flexevent. application_complete, swfready);
(_ loadswf. application as object ). test ();
}< BR >}