Groups | Blog | Home
all groups > flash actionscript > december 2004 >

flash actionscript : reading variables into flash via javascript


dlutz22
12/22/2004 7:32:58 PM
I have a problem with a website where I'm using a flash movie for the menubar.
Each web page uses the same SWF file for navigation. I need to pass the button
number from page to page so that the selected button will stay in it's
'pressed' state. I can pass the button number variable out of the swf no
problem, but because the website is limited to only javascript for any
scripting functions, I need to use it to read the passed button variable and
send it back into the same swf when the new page is loaded. I've done this in
both php and asp, but this is a first time using javascript. Does anyone have
any good examples of how I might do this? Here's the site address:
http://www.cafepress.com/shadesvexcel The swf uses a value of '0' for the
pressed button because it is not receiving a button value yet. This causes the
top button to stay in its pressed state regardless of which button you click.
If I can get javascript to pass the button value, then each button will show
its pressed state when clicked.
TimSymons
12/22/2004 8:25:00 PM
One way to do this would be to attach the variable to the URL and then parse it
with JavaScript and then use JavaScript to dynamically create the <OBJECT> and
<EMBED> tags for the SWF with the attach variable. URL for the webpage you
call would look like: http://www.foo.com/mypage.html?mybutton=0 Then using
document.location.href in JS you could parse out the ?mybutton=0 portion and
then using document.write() functions attach it to the end of the Flash file
you want to load. For example, the MOVIE attribute for <OBJECT> tag would look
like: mymovie.swf?myButton=0 This would great a _global variable in your
Flash movie with the String value of '0'. Like I said, this is just one way to
do this. You can also use FlashVars (do a search at Macromedia.com for info on
using them). Hope this gets you started. Tim
AddThis Social Bookmark Button