Flex file:
CopyCode The Code is as follows: <? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute"
Width = "200" Height = "150"
Creationcomplete = "Init ()">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Controls. Alert;
Import flash. External .*;
[Bindable]
Private var jstime: string;
Private function Init (): void
{
Flash. External. externalinterface. addcallback ("jstest", jstest );
}
Public Function JS (): void {
VaR M: String = externalinterface. Call ("flashtest", "Flash ");
Alert. Show (m );
}
Public Function jstest (STR: string): String
{
Jstime = STR;
Return "jstest:" + jstime;
}
Private function TTT (): void
{
Alert. Show (jstime );
}
]>
</MX: SCRIPT>
<Mx: button label = "test" Click = "JS ()" x = "142" Y = "118"/>
<Mx: button label = "jstest" Click = "TTT ()" x = "76" Y = "118"/>
<Mx: Text x = "10" Y = "43" text = "{jstime}" width = "180"/>
</MX: Application>
HTML:Copy codeThe Code is as follows: <HTML lang = "en">
<Script language = "JavaScript">
Function now ()
{
VaR d = new date ();
Return D. getyear () + "-" + (D. getmonth () + 1) + "-" + D. getdate () + "" + D. gethours () + ":" + D. getminutes () + ":" + D. getseconds ();
}
Function flashtest (SID)
{
Return Sid + ":" + now ();
}
Function testflash ()
{
VaR x = flexjs. jstest (now ());
Alert (X );
}
</SCRIPT>
id =" flexjs "width =" 200 "Height =" 150 "
codebase =" http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab ">
width = "200" Height = "150" name = "flexjs" align = "Middle"
play = "true"
loop = "false"
Quality = "high"
allowScriptAccess = "samedomain"
type = "application/X-Shockwave-flash"
pluginspage = "http://www.adobe.com/go/getflashplayer">