PDA

View Full Version : passing variable from javascript to flash help pls



matrix8369@yaho
January 23rd, 2008, 10:49 PM
Hello, I have been looking for a way to do this for a while now but havent really found an easy way of doing this. I want to pass a URL from javascript to my swf file so I can tell it to play a video when a button is clicked on the html page. Can some one show me an example of how to do this because I have to add this to the code flash spits out when you publish it. Any help would be awsome.

matrix8369@yaho
January 23rd, 2008, 11:07 PM
this is what I am using as far as javasript goes

function SendDataToFlashMovie(){
var flashMovie=getFlashMovieObject("SinglePlayer");
flashMovie.SetVariable("/:VideoURL[0]", "SinglePlayer/one.flv");
}

then I set up a button that when pressed, does the function SendDataToFlashMovie

and inside the swf file I have a play button on a video player and when the play button is hit it will play VideoURL[0]. I am using an array atm because I am using a xml file to place the urls into the swf but I want to switch to using javascript so I am trying to make the VideoURL[0] = what ever the javascript makes it = to. I am a novice at javascript so if you can help can you type in an example of how to do what your advice is. Thank you for reading and hopfully helping.