Click to See Complete Forum and Search --> : pulling in a js into flash
ukspudnie
01-09-2007, 02:25 PM
just wondering if it's possible to pull an js file into flash directly, and passing vars from it into flash as u do with php using the loadvars function.?
just trying to improve me knowledge.
Andy.
rdoyle720
01-09-2007, 05:16 PM
You can't exactly "pull" it in. Loading a js file in would be the same as loading in a plain text file and wouldn't do you much good. Flash and Javascript run in the browser and you can communicate in between the two using various methods. Which one you use really depends on what version of Flash you're using. The latest method is called ExternalInterface, here's an example:
http://www.adobe.com/devnet/flash/articles/external_interface.html
ukspudnie
01-11-2007, 06:52 AM
So say if i had a javascript that produced the following vars..
var1 = data
var2 = data
var3 = data
var4 = data
could i port the var values into flash using the external interface by just connecting to the js file?
Andy
rdoyle720
01-11-2007, 11:41 AM
If you're asking if it's as simple as linking to your .js file, no, it isn't. You use ExternalInterface and then you call Javascript or Flash functions to pass data around. The link I posted has examples of how it works.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.