Not yet rated

Problem

I want to access HTML element or Javascript function in flex

Solution

Using ExternalInterface class we can call javascript method from flex and also javascript can call actionscript method. Using ExternalInterface.addCallback and ExternalInterface.call method we can do that. if ExternalInterface is available.

Detailed explanation

Example..


// Add the javascript block in HTML file
        <script type="text/javascript">

function getUserName()
{
return "Adobe Flex";
}
</script>
  
 
// ActionScript part

        if (ExternalInterface.available)
{
var name:String = ExternalInterface.call('getUserName');
}
 
----
Regards,
Virat Patel

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes