jsp和flex传值的问题

把FLEX生成的SWF嵌入到JSP中,JSP传参数给FLEX.我想用ExternalInterface.addCallback进行传植操作,但是不能成功,求指点.
JSP代码:
[code="java"]



My JSP 'MyJsp.jsp' starting page
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->


This is my JSP page.



name:


id="flex" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">




width="100%" height="100%" name="flex" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">



[/code]

FLEX代码:
[code="java"]
<?xml version="1.0" encoding="utf-8"?>

mx:Script
<![CDATA[
import mx.controls.Alert;
private function init():void{
ExternalInterface.addCallback("getData",testFunction);
}

        private function testFunction(param:String):void{
            Alert.show("Alert:");
            text.text = param;
        }
    ]]>
</mx:Script>
<mx:TextInput id="text" width="200" height="20" text="12"/>

/mx:Application
[/code]
JS代码:
[code="java"]
function deliverData(){
alert("gaga");
var flashPlay = document.getElementById("flex");
flashPlay.getData("haha");
}
[/code]
每次都进入了js代码,但是传不到FLEX里的SWF中.
求指点... 不胜感激

2个回答

顺便送你一个demo:
[code="as"]
import flash.external.ExternalInterface;
ExternalInterface.call("Ok");
function beginSnap(){
ExternalInterface.call("Ok");
}
ExternalInterface.addCallback("beginSnap",beginSnap);
[/code]

[code="html"]<!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>
        var dt=new Object();
        var start=false;
        //类块开始 BEGAIN
        function  bigHead(Id){       
                if (navigator.appName.indexOf("Microsoft") > -1){
                        this.swfObj=window[Id];
                }else{
                        this.swfObj=document[Id];
                }
        }
        bigHead.prototype.beginSnap=function(){if(start==true){this.swfObj.beginSnap()}}
</script>
</head>
<body onload="dt=new bigHead('bigHead');">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="bighead" width="640" height="240" id="bigHead">
  <param name="movie" value="a.swf" />
  <param name="quality" value="high" />
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="bgcolor" value="#666666" />
  <embed src="a.swf" bgcolor="#666666" width="640" height="240" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowScriptAccess="sameDomain" name="bigHead"></embed>
</object>
<br><input type="button" value="执行" onClick="dt.beginSnap();">
<script>
function Ok(){
        alert("ok")
}
</script>
</body>
</html>

[/code]

demo 连接:
[url]http://blog.zol.com.cn/1737/article_1736946.html[/url]

iteye_5246
iteye_5246 没事到我blog里转转。。里面有相关demo。和组件使用demo。
接近 8 年之前 回复
beicuinan
beicuinan 我已经实现了,还是谢谢你
接近 8 年之前 回复

哥们,看我的blog吧 ExternalInterface 是调用js的。。。flex javascript
[url]http://demojava.iteye.com/blog/1325212[/url]

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问