Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call external javascript file in actionscript file

 
Raaja Gotluru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use ExternalInterface.call() method, 1st argument is the name of the javascript function.

 
Raaja Gotluru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karthik,

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



and in Javascript I used

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic