원하는 것은 자바 스크립트에서 Actionscript로 HTML (DOM 객체)을 전달하는 것입니다.HTML의 DOM을 Flex의 액션 스크립트에 전달하십시오.
나는 this article on the net을보고 유사한 코드를 시도했다. 하지만 IE에서 코드를 실행할 때 "18 행의 메모리가 부족합니다"라는 경고가 표시됩니다. 나는 어제부터 여기에서 붙어있다.
내가 MXML 여기에 HTML을 게시합니다..
MXML :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
public function init() : void
{
if (ExternalInterface.available)
{
try {
ExternalInterface.addCallback("populateFlashFile", populateFlashFile);
} catch (error:SecurityError) {
} catch (error:Error) {
}
}
}
public function populateFlashFile(window:*) : void
{
log.text = window.toString(); // just for checking if window has come to the function.
window.document.write("Hello");
}
]]>
</mx:Script>
<mx:TextArea x="10" y="23" width="712" height="581" id="log"/>
</mx:Application>
html로 : 내가 어떤 DOM 객체 통과 할 때 문제는 occors
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body scroll="no">
<input type="button" onclick="document.getElementById('Test').populateFlashFile(window);"/>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="Test" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="Test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
</object>
</body>
</html>
, 만약 내가 어떤 문자열을 전달하면 작동합니다. !!! 예 :
<input type="button" onclick="document.getElementById('Test').populateFlashFile('some text here');"/>
위대한 작품!
또는 js에서 as로 DOM을 전달하는 다른 대안이있는 경우 제안하십시오. – raj