6/19/2010 11:02:56 PM
Title:
Call ActionScript function from JavaScript
I am in an AIR application.
htmltext poperty only works in Flex.
I have an HTML control with id as "html" and an HTML page is loaded inside it.
I want to invoke an ActioScript function inside my AIR application from the javascript inside that HTML page
(eg : If I have a button inside HTML page when I click on it it should invoke an AS function inside the mx:Script).
PLease provide an example using the HTML control inside AIR
PLease anyone Help
6/20/2010 7:05:25 AM
The loaded URL in HTML control for Adobe AIR can be of any domain , so its security restriction to not allow the execution of java script to access the flex and vice verse. i.e you can load a yahoo page and execute there java script inside there page to do something and this would be security breach.
6/20/2010 9:40:38 AM
you can capture the link click of html inside HTML component Adobe AIR and attach a listener to it in the actionscript. See this example to capture link click in HTML component AIR in actionscript:
// your html link inside Adobe AIR html component
html.data = 'Go to <a href="mySite.com" id="myLinkID">This is a link</a>';
// actionscript code in adobe air application
var linkRef:Object = html.htmlLoader.window.document.getElementById("myLinkID");
if (linkRef!=null){
linkRef.addEventListener("click", LinkClickHandler);
}
//link click handler function
private function LinkClickHandler(obj:Object):void {
trace("myLinkID link is clicked in ")
}