PDA

View Full Version : Flash and Javascript


wwwluckyro
09-14-2004, 07:39 PM
Hello! :p

How do i change a dynamic text in Flash using Javascript? :confused:



Please :)

ShawnJC
09-20-2004, 08:27 PM
Here is a good function list that I have built up over time when using Flash and Javascript. I usually load this in the <HEAD> of my page:

/*-----------------------Controlling Flash Movies Functions-------------------------------
__________________________________________________ ______________________________________*/

/*
Function Description
Access the movie object depending on the browser
Accepts:
Required:
- movieName : The id name of the embedded Flash movie
*/
function thisMovie(movieName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[movieName];
} else {
return document[movieName];
}
}
/*
Function Description
Check to see if movie is loaded
Accepts:
Required:
- movieName : The id name of the embedded Flash movie
*/
function movieIsLoaded (movieName) {
if (typeof(movieName) != "undefined") {
return movieName.PercentLoaded() == 100;
} else {
return false;
}
}
/*
Function Description
Skip to a specified frame
Accepts:
Required:
- movieName : The id name of the embedded Flash movie
- frame : The frame number to skip to in the movie
*/
function playMovie (movieName, frame) {
if (movieIsLoaded (thisMovie(movieName))) {
thisMovie (movieName).GotoFrame (frame);
thisMovie (movieName).Play();
}
}

function flashVar (movieName,variableName,value) {
if (movieIsLoaded (thisMovie(movieName))) {
thisMovie (movieName).SetVariable( variableName, value );
}
}
/*_________________________________________________ _______________________________________
__________________________________________________ ______________________________________*/

I use them so much, I hardly look at my descriptions for them heh..but anyway, put that in your head and when you wanna say set the variable for a textfield do this:

flashVar ('htmlMovieInstance', 'textFieldVariable' , 'Hello World' );

Hope that helps...