As JS Communication
Favorites
----------- Asjsalert. mxml ---------------
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" initialize = "Init ()">
<Mx: SCRIPT>
<! [CDATA [
Import flash. External. externalinterface;
Import MX. Controls. Alert;
// Here we register two methods. One is for as to call JS
// One is for js to call
Public Function Init (): void
{
Externalinterface. addcallback ("asalerttext", asalerttext );
}
Public Function jstest (): void
{
// Call defines the method and parameters for calling Js.
Externalinterface. Call ("jsalerttest", jstesttext. Text );
}
Public Function asalerttext (STR: string): void
{
Alert. Show (STR, "test ");
}
]>
</MX: SCRIPT>
<Mx: button x = "58" Y = "43" label = "button" Click = "jstest ()"/>
<Mx: textinput x = "58" Y = "105" id = "jstesttext"/>
</MX: Application>
--------Asjstext.html -------------------
<HTML lang = "en">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<LINK rel = "stylesheet" type = "text/CSS" href = "History/history.css"/>
<Title> </title>
<SCRIPT src = "ac_oetags.js" Language = "JavaScript"> </SCRIPT>
<SCRIPT src = "History/history. js" Language = "JavaScript"> </SCRIPT>
<Style>
Body {margin: 0px; overflow: hidden}
</Style>
<Script language = "JavaScript" type = "text/JavaScript">
<! --
VaR requiredmajorversion = 9;
VaR requiredminorversion = 0;
VaR requiredrevision = 124;
</SCRIPT>
</Head>
<Body scroll = "no">
<Button onclick = "asalerttest ()"> JS calls the as method </button>
<Input type = "text" id = "astesttext"/>
<Script language = "JavaScript" type = "text/JavaScript">
<! --
Function jsalerttest (STR)
{
Alert (STR );
}
Function asalerttest ()
{
Thismovie ('asjsalert '). asalerttext (document. getelementbyid ('astesttext'). value );
}
Function thismovie (moviename)
{
If (navigator. appname. indexof ("Microsoft ")! =-1 ){
Return window [moviename];
} Else {
Return document [moviename];
}
}
VaR hasproductinstall = detectflashver (6, 0, 65 );
VaR hasrequestedversion = detectflashver (requiredmajorversion, requiredminorversion, requiredrevision );
If (hasproductinstall &&! Hasrequestedversion ){
VaR mmplayertype = (isie = true )? "ActiveX": "plugin ";
VaR mmredirecturl = Window. location;
Document. Title = Document. Title. Slice (0, 47) + "-Flash Player installation ";
VaR mmdoctitle = Document. title;
Ac_fl_runcontent (
"Src", "playerproductinstall ",
"Flashvars", "mmredirecturl =" + mmredirecturl + '& mmplayertype =' + mmplayertype + '& mmdoctitle =' + mmdoctitle + "",
"Width", "100% ",
"Height", "100% ",
"Align", "Middle ",
"ID", "asjsalert ",
"Quality", "high ",
"Bgcolor", "#869ca7 ",
"Name", "asjsalert ",
"AllowScriptAccess", "samedomain ",
"Type", "application/X-Shockwave-flash ",
"Pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} Else if (hasrequestedversion ){
Ac_fl_runcontent (
"Src", "asjsalert ",
"Width", "100% ",
"Height", "100% ",
"Align", "Middle ",
"ID", "asjsalert ",
"Quality", "high ",
"Bgcolor", "#869ca7 ",
"Name", "asjsalert ",
"AllowScriptAccess", "samedomain ",
"Type", "application/X-Shockwave-flash ",
"Pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} Else {
VaR alternatecontent = 'alternate HTML content shoshould be placed here .'
+ 'This content requires the Adobe Flash Player .'
+ '<A href = http://www.adobe.com/go/getflash/> get flash </a> ';
Document. Write (alternatecontent );
}
</SCRIPT>
<NoScript>
<Object classid = "CLSID: D27CDB6E-AE6D-11cf-96B8-444553540000"
Id = "asjsalert" width = "100%" Height = "100%"
Codebase = "http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<Param name = "movie" value = "asjsalert.swf"/>
<Param name = "quality" value = "high"/>
<Param name = "bgcolor" value = "#869ca7"/>
<Param name = "allowScriptAccess" value = "samedomain"/>
<Embed src = "asjsalert.swf" Quality = "high" bgcolor = "#869ca7"
Width = "100%" Height = "100%" name = "asjsalert" align = "center"
Play = "true"
Loop = "false"
Quality = "high"
AllowScriptAccess = "samedomain"
Type = "application/X-Shockwave-flash"
Pluginspage = "http://www.adobe.com/go/getflashplayer">
</Embed>
</Object>
</NoScript>
</Body>
</Html>