Pass HTML-DOM to Flex's actionscript.

Posted by raj on Stack Overflow See other posts from Stack Overflow or by raj
Published on 2010-03-16T06:30:43Z Indexed on 2010/03/16 6:36 UTC
Read the original article Hit count: 373

Filed under:
|
|

Hi, All i want is to pass a HTML-Form (DOM object) from javascript to Actionscript.

i saw this article on the net and tried a similar code. But when i execute the code in IE, it alerts : "Out of memory at line 18". I'm stuck here from yesterday.

i'll post the mxml and html here..

The 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>

The HTML :

<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>

The problem occors only when i pass some DOM object, if i pass some String it works.!!! i.e :
<input type="button" onclick="document.getElementById('Test').populateFlashFile('some text here');"/>
works great!

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript