gpt4 book ai didi

javascript - 对 Flex 的 Iframe Javascript 调用

转载 作者:行者123 更新时间:2023-11-30 18:24:56 25 4
gpt4 key购买 nike

我有一个顶部有 iframe 的 flex 应用程序。

我想从 iframe 调用 flex with javascript。

到目前为止我已经试过了:

这是包含 ROOT 文档中嵌入的 swf 的对象

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="IPRS_Dispatcher" width="1400" height="1000"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="DispatcherMain.swf" />
<param name="quality" value="high" />
<!-- <param name="bgcolor" value="${bgcolor}" /> -->
<param name="allowScriptAccess" value="sameDomain" />
<param name='flashVars' value='strLang=english&strIPRSSrvHost=&strGPSSrvHost=192.168.1.130&strGPSSrvSoapPort=8081&strGPSSrvFwdPort=26000&strLoginMode=simple&strSOSSrvHost=192.168.1.80&strSOSSrvSoapPort=8082&strSOSSrvFwdPort=26001&strSOSLoginMode=simple&strUserSIP=&strUserPswd=&nDelayForMapReadySecs=10&nGPSUpdatesRateSecs=120&nGPSSubscriptionsIntervalMinutes=10&nLat=35.0&nLng=32.5&nZoomLevel=5&strClientServiceVersion=2.1.36.19&nPathDotsSize=1&nPathWidth=5&bHideAnnounce=false&bHideEmergencyPan=true&strMapMarkerLabelMode=name&key=ABQIAAAAYbXZyR09wFj6QsiYucHpGxQEO34WZEWuIFq1A7yobGXPE-K5exQV9ZYR6NIkF8LCR8wsYvlhOIYsfA' />
<embed id="IPRS_Dispatcher2" src="DispatcherMain.swf"
flashVars='strLang=english&strIPRSSrvHost=&strGPSSrvHost=192.168.1.130&strGPSSrvSoapPort=8081&strGPSSrvFwdPort=26000&strLoginMode=simple&strSOSSrvHost=192.168.1.80&strSOSSrvSoapPort=8082&strSOSSrvFwdPort=26001&strSOSLoginMode=simple&strUserSIP=&strUserPswd=&nDelayForMapReadySecs=10&nGPSUpdatesRateSecs=120&nGPSSubscriptionsIntervalMinutes=10&nLat=35.0&nLng=32.5&nZoomLevel=5&strClientServiceVersion=2.1.36.19&nPathDotsSize=1&nPathWidth=5&bHideAnnounce=false&bHideEmergencyPan=true&strMapMarkerLabelMode=name&key=ABQIAAAAYbXZyR09wFj6QsiYucHpGxQEO34WZEWuIFq1A7yobGXPE-K5exQV9ZYR6NIkF8LCR8wsYvlhOIYsfA'
width="1400" height="1000" name="IPRS_Dispatcher" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer"> <!-- bgcolor="${bgcolor}" -->
</embed>
</object>

我已经为我想公开的函数添加了 addcallback

ExternalInterface.addCallback("sendToFlash", callFromJavaScript);

仅供引用

  public function callFromJavaScript(str):void
{
LogAddItem( 30, str);
}

在我的 IFRAME 中我添加了函数

function callToFlash(str) 
{
var swf = parent.top.$("#IPRS_Dispatcher");
var bool = swf.sendToFlash(str);
}

现在在 chrome 中出现错误 - Uncaught TypeError: Object [object Object] has no method 'sendToFlash'

更新 25/06/2012 - console.log(swf) 的输出

[
<embed src=​"DispatcherMain.swf" width=​"100%" height=​"100%" align=​"middle" id=​"IPRS_Dispatcher" quality=​"high" name=​"IPRS_Dispatcher" wmode=​"opaque" allowfullscreen=​"true" allowscriptaccess=​"always" pluginspage=​"http:​/​/​www.adobe.com/​go/​getflashplayer" flashvars=​"strOEM=mt&strSplashImage=./​assets/​loadinglogo.jpg&strLang=english&strSelectableLangs=english,chinese, portuguese_brazil,german,french,spanish&strIPRSSrvHost=85.118.26.10&strGPSSrvHost=85.118.26.16&strGPSSrvSoapPort=8081&strGPSSrvFwdPort=26000&strLoginMode=simple&strUserSIP=&strUserPswd=&strSOSSrvHost=85.118.26.17&strSOSSrvSoapPort=8082&strSOSSrvFwdPort=26001&strClientServicePort=&strSOSLoginMode=simple&themeColor=a7c3e3&showRTTPriority=false&showGPSUpdateRate=true&nSamePosErrMeters=300&nDelayForMapReadySecs=10&nGPSUpdatesRateSecs=65535&nGPSSubscriptionsIntervalMinutes=10&nLat=48.311058&nLng=11.636753&nZoomLevel=13.0&strClientServiceVersion=2.1.36.04&bDispatcherEndsSessions=true&nSOSSubscriptionsIntervalMinutes=1&GPSKATime=20&SOSKATime=20&nPathDotsSize=2&nPathWidth=5&bHideAnnounce=false&bHideEmergencyPan=false&bHideDebugLog=false&showMutedColumn=false&strLogFilter=&strMapMarkerLabelMode=name&key=ABQIAAAAfJEcVYS6-jYp2UOUy8Wh5xSCeXAFBxztfWxjY5w1WzTnKjnSVRS7Uu5XoOIwTg2R_tq_c0QSCPxSHw" type=​"application/​x-shockwave-flash">​
]

最佳答案

你能跑吗:

function sendToActionscript(str) 
{
var swf = jQuery("#IPRS_Dispatcher", parent.document);
console.log('step1');
console.log(swf);
console.log('step2');
console.log.(swf.html());
console.log('step3');

swf.LogAddItem(30, str);
console.log('step4');
}

好的,下一步调试:运行这个:

function sendToActionscript(str) 
{
var swf = parent.top.$(“#IPRS_Dispatcher”);
console.log('step1');
console.log($);
console.log('step2');
console.log.(jQuery);
console.log('step3');
console.log(parent.document);
console.log('step4');
}

编辑

步骤输出

step1 
function (j,s){return new b.fn.init(j,s)} iframecontent.html:49
step2
[
<embed src=​"DispatcherMain.swf" width=​"100%" height=​"100%" align=​"middle" id=​"IPRS_Dispatcher" quality=​"high" name=​"IPRS_Dispatcher" wmode=​"opaque" allowfullscreen=​"true" allowscriptaccess=​"sameDomain" pluginspage=​"http:​/​/​www.adobe.com/​go/​getflashplayer" flashvars=​"strOEM=mt&strSplashImage=./​assets/​loadinglogo.jpg&strLang=english&strSelectableLangs=english,chinese, portuguese_brazil,german,french,spanish&strIPRSSrvHost=85.118.26.10&strGPSSrvHost=85.118.26.16&strGPSSrvSoapPort=8081&strGPSSrvFwdPort=26000&strLoginMode=simple&strUserSIP=&strUserPswd=&strSOSSrvHost=85.118.26.17&strSOSSrvSoapPort=8082&strSOSSrvFwdPort=26001&strClientServicePort=&strSOSLoginMode=simple&themeColor=a7c3e3&showRTTPriority=false&showGPSUpdateRate=true&nSamePosErrMeters=300&nDelayForMapReadySecs=10&nGPSUpdatesRateSecs=65535&nGPSSubscriptionsIntervalMinutes=10&nLat=48.311058&nLng=11.636753&nZoomLevel=13.0&strClientServiceVersion=2.1.36.04&bDispatcherEndsSessions=true&nSOSSubscriptionsIntervalMinutes=1&GPSKATime=20&SOSKATime=20&nPathDotsSize=2&nPathWidth=5&bHideAnnounce=false&bHideEmergencyPan=false&bHideDebugLog=false&showMutedColumn=false&strLogFilter=&strMapMarkerLabelMode=name&key=ABQIAAAAfJEcVYS6-jYp2UOUy8Wh5xSCeXAFBxztfWxjY5w1WzTnKjnSVRS7Uu5XoOIwTg2R_tq_c0QSCPxSHw" type=​"application/​x-shockwave-flash">​
]
step3 iframecontent.html:52
#document
step4

好的,现在就试试

function sendToActionscript(str) 
{
var swf = parent.top.$(“#IPRS_Dispatcher”);
swf.LogAddItem(30, str);
}

你的 flex 应用程序有错误 enter image description here

终于解决了

    // get flash movie object
var flashMovie;
function init() {
if (document.getElementById) {
flashMovie = parent.document.getElementById("IPRS_Dispatcher");
}
}

// wait for the page to fully load before initializing
window.onload = init;

function callToFlash(str)
{
var bool = flashMovie.sendToFlash(str);
}

我认为在初始化之前等待页面完全加载是解决方法。

您还可以使用 http://api.jquery.com/ready/

$(document).ready(init);

在 DOM 初始化后让它工作。

关于javascript - 对 Flex 的 Iframe Javascript 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11137676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com