`
zxyskycn
  • 浏览: 50870 次
  • 性别: Icon_minigender_1
  • 来自: 天津
最近访客 更多访客>>
社区版块
存档分类
最新评论

as3和js交互

阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function Flash(_url,_id,_width,_height,_wmode,_bgcolor,_quality){
var url=_url;
var id=_id;
var width=_width;
var height=_height;
var wmode=_wmode||false
wmode?wmode="transparent":wmode="opaque";
var bgcolor=_bgcolor||"#869ca7";
var quality=_quality||"high";
var varialbe="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id="+id+" width="+width+" height="+height+" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab\">\
         <param name=\"movie\" value="+url+" />\
         <param name=\"quality\" value="+quality+" />\
         <param name=\"bgcolor\" value="+bgcolor+" />\
   <param name=\"wmode\" value="+wmode+" />\
         <param name=\"allowScriptAccess\" value=\"sameDomain\" />\
         <embed src="+url+" quality="+quality+" bgcolor="+bgcolor+"\
             width="+width+" height="+height+" wmode="+wmode+" name="+id+" align=\"middle\"\
             play=\"true\" loop=\"false\" quality="+quality+" allowScriptAccess=\"sameDomain\"\
             type=\"application/x-shockwave-flash\"\
             pluginspage=\"http://www.macromedia.com/go/getflashplayer\">\
         </embed>\
     <\/object>";
 this.add=function(_parent){
  var parent=document.getElementById(_parent);
  if(parent==null){
   return document.body.innerHTML=varialbe;
  }else{
   return parent.innerHTML=varialbe;
  }
 }
}

window.onload=function(){
var flash=new Flash("ExternalInterfaceExample.swf","ExternalInterfaceExample",550,400)
 flash.add();
}

function hello(){alert("hello")}
function getfl(movieName){
  if (window.all) {
    return window[movieName];
  } else {
    return document[movieName];
  }
  // return document.getElementById(movieName)
}
function brige(){
 getfl("ExternalInterfaceExample").callAsFunc("jajaja");
}
</script>
</head>
<body>
</body>
</html>

 

//var url:URLRequest=new URLRequest("javascript:brige()")
//navigateToURL(url,"_self")
var txt2:TextField=new TextField();
 addChild(txt2);
 txt2.x=300
if(ExternalInterface.available){
ExternalInterface.addCallback("callAsFunc",callAs);
ExternalInterface.call("brige");
txt2.text="true";
}else{
 txt2.text="false";
}
function callAs(str:String):void{
 var txt:TextField=new TextField();
 txt.appendText(str);
 addChild(txt);
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics