Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bentleykf - javascript question 2

Status
Not open for further replies.

oldnewbie

Technical User
Dec 6, 2000
9,142
CA
You could set a variable in your html's object and embed tags with this:

Then simply set your dynamic text (my_text.text = variable) with that variable.

Or...

Use the flash methods to basically do the same thing.

Regards,

oldman3.gif
 
yeah, i suppose
but because i have a lot of the same flash movies on the same page this is probably gonna get real complicated!!!
 
You could pass location object variables into Flash at runtime by writing the HTML that embeds the Flash object dynamically with javascript and then appending a parameter string to the movie name. This is from a site I built recently that used that principle:

<script language=&quot;JavaScript1.1&quot;>
<!--
var strParams = location.search;
var flName = &quot;load.swf&quot;
var flColor = &quot;#000000&quot;
var flWidth = &quot;730&quot;
var flHeight = &quot;425&quot;

document.write('<object'
+ ' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;'
+ ' codebase=&quot; + ' id=&quot;flash&quot;'
+ ' width=' + flWidth
+ ' height=' + flHeight + '>'
+ ' <param name=&quot;movie&quot; value=&quot;' + flName + strParams + '&quot;>'
+ ' <param name=&quot;quality&quot; value=&quot;high&quot;>'
+ ' <param name=bgcolor value=' + flColor + '>'
+ ' <embed src=&quot;'+ flName + strParams + '&quot;'
+ ' name=&quot;flash&quot;'
+ ' quality=high bgcolor=' + flColor
+ ' width=' + flWidth
+ ' height=' + flHeight
+ ' type=&quot;application/x-shockwave-flash&quot;'
+ ' pluginspage=&quot; + ' </embed></object>'
)
// -->
</script>
 
so, what your saying wangbar is that using the location of the movie i can pass variables into my flash movie, like so;
<param name=&quot;movie&quot; value='file.swf?var1=Var 1 Value'>
...and, lets say, the variable &quot;var1&quot; can be referred to in actionscript by that name???

it would help me a lot if u could send me a copy of the files u use to do this because i am an amateur.
-bentley k. frog
 
That's exactly it. The variables you append to the 'movie' value can be accessed as _root/_global variables within the flash movie as it's running.


Here's a stripped down script:

<script language=&quot;JavaScript1.1&quot;>
<!--
var parameters = location.search;
var movieName = &quot;externalVars.swf&quot;


document.write('<object'
+ ' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;'
+ ' codebase=&quot; + ' id=&quot;flash&quot;'
+ ' width=750'
+ ' height=400>'
+ ' <param name=&quot;movie&quot; value=&quot;' + movieName + parameters + '&quot;>'
+ ' <param name=&quot;quality&quot; value=&quot;high&quot;>'
+ ' <param name=bgcolor value=#ffffff>'
+ ' <embed src=&quot;' + movieName + parameters +'&quot;'
+ ' name=&quot;flash&quot;'
+ ' quality=high bgcolor=#ffffff'
+ ' width=750'
+ ' height=400'
+ ' type=&quot;application/x-shockwave-flash&quot;'
+ ' pluginspage=&quot; + ' </embed></object>'
)
// -->
</script>

There's an example here:


The flash is nothing but a dynamic textbox variable name loadedIn which will display the value of the variable in the parameter string attached to the URL
 
thanks wangbar and oldnewbie, you guys are always helpful :)
i forgot to tell you wangbar that i'm using flash MX on a mac, so appending the variables to the end of the location of the movie doesn't always work for me, but you put me on the right track.

I had a little search through the Macromedia Flash Support Center and came up with this document;


so now i'm using that javascript method you use wangbar to write the movies to the page, but i'm using FlashVars with it instead, and it works :)

Thanks guys again for the help :)
-bentley k. frog
 
ohhhh, did i mention that i think i'm losing my head
huh, it was sitting in front of me all that time, thanks oldnewbie :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top