File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Flex and the fly likes How to call external javascript file in actionscript file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "How to call external javascript file in actionscript file" Watch "How to call external javascript file in actionscript file" New topic
Author

How to call external javascript file in actionscript file

Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 112
Hi,

I want to call a function in an external javascript file from actionscript file. This javascript function is common to most of the pages so we separated that code and saved it as a .js file. Now I want to call this from action script, so that I can get the value received by javascript function in actionscript and set that value to datagrid.

for example the location of the .js file is in webcontent/scripts folder. And actionscript file is in src/com/abc.flex/result.as

Can anyone guide me in acheiving this.
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

You can use ExternalInterface.call() method, 1st argument is the name of the javascript function.

Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 112
HI Karthik,

Thanks for the reply. Does this will call a js file from other location. How the actionscript will know the location of the JS file. Some where we need to refer right.

Please clarify me.
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

Sorry for late reply.

You need to include javascript file in your html template file. Template file will be most likely in Project folder-->html-template-->index.template.html
Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 112
Hi Karthik,

Thanks for the solution. But I solved it in the reverse way using



and in Javascript I used

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call external javascript file in actionscript file