Skip to main content
November 15, 2006
Question

Reading FlashVars in SWF File.

  • November 15, 2006
  • 3 replies
  • 1311 views
I do have a question in regards to FlashVars and how you test for the existance of a certain value inside a SWF movie?

This code right here works fine for me.
if (_level0.myURL == undefined) {

}
else {
pflipper.gotoPage(3);
gotoAndStop(1);
}

However, it is not what I need. I want to be able to setup an if statement with multiple else if statements. I have tried almost every possible combination except the correct one.

Here is what I would like to do. If myURL == 1 then gotoPage(1) & gotoAndStop(1) else if myURL == 4 then gotoPage(2) & gotoAndStop(4)

Can you please tell me what is the correct syntact for doing this.
This topic has been closed for replies.

3 replies

November 16, 2006
Marcus, here is what I discovered. The JavaScript being generated by Dreamweaver was preventing my FlashVars from being passed from the Object and Embed tags. I could not drop the JavaScript because I would get that nasty highlight around my Flash object on the page in IE. So, I found another JavaScript solution which allows me to pass the FlashVars to the SWF.

http://www.centralquestion.com/archives/2005/03/writeflash_flas.html

The only problem is that when I go to the SWF file page 4 frame 2 I get stuck in a loop when I click on page 1,2,3. Would you find taking a look.

Start at this link.
http://www.graphicartsworld.com/level3.cfm?T1ID=15&T2ID=25&T3ID=16&myURL=2
Now click on page 1 or 2 or 3.

Something in my action script is causing this. Here is the link to my FLA.
http://www.graphicartsworld.com/pageFlipper.fla

Also, here is the link to download the component. Please let me know when you have done that.
http://www.graphicartsworld.com/pageFlipper.zip

Thank you so much for taking the time to help.
2m91_2
Inspiring
November 16, 2006
@ javascript:
Do as you like, but if I was you I would have used swfObject. like in your first version - I've got only the best expiriences with it.

@ fla:
The downloadlink for the fla does not work for me. Please check or mail to markusmathieu[at]mac[.]com.

you're welcome
November 16, 2006
Marcus problem solved with the FlashVars not getting passed. I was using the default JavaScript that Dreamweaver 8 loads when you embed Flash content using the object and embed tag. In the JavaScript I needed to include the vars that were getting passed like FlashVars and myURL=DynamicCintent. Here is the URL.

http://www.graphicartsworld.com/test.cfm

Thanks,
November 16, 2006
Yes, I follow your reasonings. My question is, why does it work in Flash Player when I hardcode the values in AS?
2m91_2
Inspiring
November 16, 2006
It's only a hunch I have, but probably worth a try:

Your component might take some milliseconds to initialize, but your code checking for the flashvar executes very first.
So probably using setTimeout might be worth a try, or loading the component one frame ahead of everything else.

It seems I cannot test it, as the fla won't compile on my system - the component I guess...
derobinson
Participating Frequently
November 16, 2006
You're most of the way there...just keep reading in the help files and you'll discover the ELSE IF statement. So,

if (_level0.myURL == undefined) {

} else if (_level0.myURL == 1) {
pflipper.gotoPage(X);
gotoAndStop(X);
} else {
pflipper.gotoPage(3);
gotoAndStop(1);
}

You can put in as many ELSE IFs as you need and ELSE is the catchall at the end.

Hope that helps!
2m91_2
Inspiring
November 16, 2006
Dear cutie,

did we disappoint you in the other thread?

That is sad, as I'm really sure, that your problem is not inside the flash but with the way you try to submit the flashvars into it.

Once you have the correct values inside your code will work!
November 16, 2006
No 2m you did not disappoint. I had to get some lunch. You are helping get me closer to solving this. I went back to an object and embed tag to place the swf file in the html page. I have the code working in the Flash Player. It is still not working in the browser. Can you please take a look at this URL and see if you see anything out of place. I also removed everything else on the HTML page to see if that was causing problems and it does not appear to be the case. For some reason FlashVars are not getting passed to my swf. Do you see anything.

Everything is hardcoded in the Object and Embed tag so you can't blame it on the ColdFusion.