Using JavaScript framework in Flash
I want to be able to use pluins from JavaScript frameworks开发者_运维知识库 such as jQuery and etc. Is it possible to port it into flash? Sorry, i am looking for AS 3 solutions. Apologize in advance
It would not make sense to port a lot of the popular JavaScript frameworks to flash since they work against the DOM and flash is independent of that. However, you can call JavaScript functions from flash.
First you would update your OBJECT/EMBED script in the host HTML page to include:
<param name="allowscriptaccess" value="always" />
Then from your code you can execute JavaScript method calls like:
getUrl('javascript:method()');
If you want to call and make sure of jQuery, you don't need to port them per say. You can simply call them by using the ExternalInterface in Actionscript. Using jQuery with Flash is actually pretty awesome as you can speed up development quite a bit if you have a lot of existing code in JavaScript that you simply don't want to replicate either in Flash or the server-side.
if(ExternalInterface.available){ ExternalInterface.call('function(){ YourFunctionName(); }'); }
And finally if you are really looking to port, there are some projects ongoing;
Check out http://ajaxian.com/archives/as3query-jquery-port-to-actionscript
Hopefully that helps.
精彩评论