Calling Flex / Actionscript functions from Javascript
Nowadays I am working with Flex projects,that runs on Lotus Notes platform,which consumes data from Lotus Notes backend. Since there is no remote services like BlazeDS to connect to Notes server,am now greatly dependant on HTTPService and Javascript. Calling a javascript function from Flex is quite easy. Just use the?ExternalInterface?API. For those who don’t know the way,this is how it is getting called. In AS3
In Javascript
It is quite easy. But what if you need to call the reverse. ie,calling actionscript function from javascript. We can use the sameExternalInterface?api for achieve this. There is a method calledaddCallback,available in ExternalInterface. addCallback method registers an ActionScript method as callable from the container. After a successful invocation of? Step 1?: Register the call back from actionscript. For eg,call the below method in the creationComplete or initialize event of the component.
Step 2 : Create logic in javascript to invoke the AS3 function.
The?appName?is the name and id of the embedded swf object in the HTML. Like below :
That’s it. Now you can call the?updateFlex?javascript method from your HTML and it will invoke the AS3 callback function. Enjoy Coding guys. Flex Your Life. Cheers.? Reference: http://deviltechie.wordpress.com/2012/05/08/calling-flex-actionscript-functions-from-javascript/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |