14 Replies Latest reply on Nov 16, 2006 2:41 PM by cutie369

    Reading FlashVars in SWF File.

    cutie369 Level 1
      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.
        • 1. Reading FlashVars in SWF File.
          derobinson Level 1
          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!
          • 2. Re: Reading FlashVars in SWF File.
            2m Level 2
            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!
            • 3. Re: Reading FlashVars in SWF File.
              cutie369 Level 1
              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.
              • 4. Re: Reading FlashVars in SWF File.
                2m Level 2
                Hi,
                sorry for asking stuoid questions, the reason wasn't the time it took you to answer, but the fact that you opened a new thread - which disturbed me.

                Right now I don't see anything, because I miss the promised URL. Is it me, the forum mechanics or did you forget to put it in?
                • 5. Re: Reading FlashVars in SWF File.
                  2m Level 2
                  BTW: as it seems to become more of a very "specific" case that might not be of greater interest to the rest, you can contact me directly if you wish: markusmathieu[AT]mac[.]com
                  • 6. Re: Reading FlashVars in SWF File.
                    cutie369 Level 1
                    Hi, I did not forget to put the link in. Here it is.
                    http://www.graphicartsworld.com/test.cfm
                    • 7. Re: Reading FlashVars in SWF File.
                      2m Level 2
                      Hi,
                      Thank you for giving me the link. As far as I can see everything works as expected - that means that the main time-line is sent to frame 2, why the "pflipper.gotoPage(4);" doesn't execute in the way you (most likely) want it to, I can't seen right now. As It is a component aka a compiled clip, I don't know/have come across yet, I guess that it has problems dealing with the command.
                      Do you follow my reasoning, or am I totally off track here?
                      • 8. Re: Reading FlashVars in SWF File.
                        cutie369 Level 1
                        Yes, I follow your reasonings. My question is, why does it work in Flash Player when I hardcode the values in AS?
                        • 9. Re: Reading FlashVars in SWF File.
                          2m Level 2
                          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...
                          • 10. Re: Reading FlashVars in SWF File.
                            cutie369 Level 1
                            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.
                            • 11. Re: Reading FlashVars in SWF File.
                              2m Level 2
                              @ 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
                              • 12. Re: Reading FlashVars in SWF File.
                                cutie369 Level 1
                                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,
                                • 13. Re: Reading FlashVars in SWF File.
                                  2m Level 2
                                  So I gather that you haver solved your problem and no further assistance is neede?

                                  If that's the case - you're welcome.

                                  cu
                                  • 14. Re: Reading FlashVars in SWF File.
                                    cutie369 Level 1
                                    Marcus, I still have a small problem.
                                    Please go to this url
                                    http://www.graphicartsworld.com/test.cfm

                                    Then click the link which says Link to Frame 2
                                    Then click on page 1or 2 or 3 and see how it loops back to frame 2.

                                    What is in my action script that is causing that?

                                    stop();
                                    myButton1.onRelease = function()
                                    {
                                    pflipper.gotoPage(1);
                                    gotoAndStop(1);
                                    }
                                    myButton2.onRelease = function()
                                    {
                                    pflipper.gotoPage(2);
                                    }
                                    myButton3.onRelease = function()
                                    {
                                    pflipper.gotoPage(3);
                                    gotoAndStop(1);
                                    }
                                    myButton4.onRelease = function()
                                    {
                                    pflipper.gotoPage(4);
                                    gotoAndStop(2);
                                    }
                                    myButton5.onRelease = function()
                                    {
                                    pflipper.gotoPage(5);
                                    gotoAndStop(2);
                                    }
                                    myButton6.onRelease = function()
                                    {
                                    pflipper.gotoPage(6);
                                    gotoAndStop(3);
                                    }
                                    myButton7.onRelease = function()
                                    {
                                    pflipper.gotoPage(7);
                                    gotoAndStop(3);
                                    }
                                    myButton8.onRelease = function()
                                    {
                                    pflipper.gotoPage(8);
                                    gotoAndStop(3);
                                    }
                                    myButton9.onRelease = function()
                                    {
                                    pflipper.gotoPage(9);
                                    gotoAndStop(3);
                                    }
                                    myButton10.onRelease = function()
                                    {
                                    pflipper.gotoPage(10);
                                    gotoAndStop(3);
                                    }
                                    myButton11.onRelease = function()
                                    {
                                    pflipper.gotoPage(11);
                                    gotoAndStop(3);
                                    }
                                    myButton12.onRelease = function()
                                    {
                                    pflipper.gotoPage(12);
                                    gotoAndStop(4);
                                    }
                                    myButton13.onRelease = function()
                                    {
                                    pflipper.gotoPage(13);
                                    gotoAndStop(4);
                                    }
                                    myButton14.onRelease = function()
                                    {
                                    pflipper.gotoPage(14);
                                    gotoAndStop(4);
                                    }
                                    myButton15.onRelease = function()
                                    {
                                    pflipper.gotoPage(15);
                                    gotoAndStop(4);
                                    }
                                    pflipper.onPageFlip = function() {
                                    if(pflipper.getLeftPageNum() == 4)
                                    {
                                    gotoAndStop(2);
                                    }
                                    else if (pflipper.getLeftPageNum() == 6)
                                    {
                                    gotoAndStop(3);
                                    }
                                    else if (pflipper.getLeftPageNum() == 10)
                                    {
                                    gotoAndStop(3);
                                    }
                                    else if (pflipper.getLeftPageNum() == 12)
                                    {
                                    gotoAndStop(4);
                                    }
                                    else if (pflipper.getRightPageNum() == 1)
                                    {
                                    gotoAndStop(1);
                                    }
                                    else if (pflipper.getRightPageNum() == 2)
                                    {
                                    gotoAndStop(1);
                                    }
                                    else if (pflipper.getRightPageNum() == 3)
                                    {
                                    gotoAndStop(1);
                                    }
                                    else if (pflipper.getRightPageNum() == 4)
                                    {
                                    gotoAndStop(2);
                                    }
                                    else if (pflipper.getRightPageNum() == 6)
                                    {
                                    gotoAndStop(3);
                                    }
                                    else if (pflipper.getRightPageNum() == 10)
                                    {
                                    gotoAndStop(3);
                                    }
                                    else if (pflipper.getRightPageNum() == 12)
                                    {
                                    gotoAndStop(4);
                                    }
                                    }
                                    if (_level0.myURL == "1"){
                                    pflipper.gotoPage(0);
                                    gotoAndStop(1);
                                    }
                                    else if (_level0.myURL == "2") {
                                    pflipper.gotoPage(4);
                                    gotoAndStop(2);
                                    }
                                    else if (_level0.myURL == "3") {
                                    pflipper.gotoPage(6);
                                    gotoAndStop(3);
                                    }
                                    else if (_level0.myURL == "4") {
                                    pflipper.gotoPage(12);
                                    gotoAndStop(4);
                                    }
                                    else { // this servers for undefined
                                    pflipper.gotoPage(0);
                                    gotoAndStop(1);
                                    }
                                    var my_cm:ContextMenu = new ContextMenu();
                                    my_cm.hideBuiltInItems();
                                    this.menu = my_cm;
                                    loadMovie("cimages/FinalGEMs_Techie05VP6_Lg.swf", this.opener);
                                    for ( i in _level0)
                                    {
                                    trace(i);
                                    }
                                    myTextBox="The flashvar 'myURL' had the value:"+this.myURL;