I wanted to write down some information that i found hard to find when trying to implement simple JavaScript actions to a ActionScript Flash CS3 link.
We will start by making a button that calls a popup from JavaScript within Flash CS3
Start by creating a new flash-file (CTRL+N) and choose ActionScript 3.0
Then create some simple object, maby something like this:
Now select your object and press F8. Rename the object “button” and choose Type: Button.
Now we need to give the new object an “Instance Name”, we will call it “btn”
Now we need to create a new layer for the ActionScript, so press Insert Layer and rename the new layer to “action”.
This was the easy part, now we are beginning the ActionScripting. make sure you have selected the keyframe in your action layer then open up your Actions panel by pressing F9 and insert the following code:
var js:URLRequest=new URLRequest(); js.url=”javascript:window.open(’sitepop.html’,'popup’,'width=550,height=400′);newWindow.focus(); void(0);”; btn.addEventListener(MouseEvent.CLICK,openPopUp); function openPopUp(evt:MouseEvent):void { navigateToURL(js,’_self’); }
This will popup sitepop.html in a new window with set height and width.




I have been working on a similar project, just a bit more complex. I have an AS3 MP3 player that I am trying to use javascript to play songs in the MP3 player from an html page. I would be interested in knowing how to do this.
Thanks.
Forrest, take a look at this page here:
http://www.flepstudio.org/forum/tutorials/894-actionscript-calls-javascript-externalinterface-class-flash-cs3.html
maby that can help.
Hello. Your post ipt for Flash CS3 ActionScript 3.0 Part 1 at Samuel Tilly is very interesting for me. My written English is not so good so I write in German: “Lieber den Spatz in der Hand, als die Taube auf dem Dach.” Yours sincerely Friday Samuel
Hey, I came across this blog post while searching for help with JavaScript. I have recently switched browsers from Chrome to Firefox 3.2. After the change I seem to have a problem with loading JavaScript. Every time I browse site that needs Javascript, the site doesn’t load and I get a “runtime error javascript.JSException: Unknown name”. I cannot seem to find out how to fix it. Any help is very appreciated! Thanks