5 Replies Latest reply on Dec 10, 2013 9:24 PM by rossfranks

    Accessing variables from a symbol?

    rossfranks Level 1

      Hey there guys, sorry I'm not much of a coder and am a designer but here's my issue.

       

      I have a character who is a student who is going to enter a chemistry lab, but before he does, the user has a choice to put on a coat and goggles on the character, so when the goggles are chosen the gogglesVar == false, etc and then when you click on the door the character will walk through the door and then get to this code (which is inside a symbol)

       

      if( sym.getComposition().getStage().gogglesVar == false ){

       

      sym.play("goggles");

       

      }

       

      if( sym.getComposition().getStage().coatVar == false ){

       

      sym.play("coat");

       

      }else{

       

      sym.play("noCoatNoGoggles");

       

      }

       

      but no matter what i choose the code always goes to sym.play("noCoatNoGoggles");

       

      is that because it's in a symbol and doesn't see the gogglesVar == false anymore?

       

      Hope that makes sense, and thanks in advance.

       

      Ross.

        • 1. Re: Accessing variables from a symbol?
          rossfranks Level 1

          I also have the variables set in stage.compositionReady event

           

          sym.coatVar = true;

          sym.gogglesVar = true;

          • 2. Re: Accessing variables from a symbol?
            resdesign Adobe Community Professional & MVP

            I would handle things differently. I assume goggles, coat, and noCoatNoGoggles are labels on the timeline.

            I would put all the code in compositionReady and try this:

             

            var gogglesVar = true;

            var coatVar = true;

             

            if ( gogglesVar == false ){

                 sym.play("goggles");

            }

             

            if (coatVar == false ){

                 sym.play("coat");

            } else {

                 sym.play("noCoatNoGoggles");

            }

            1 person found this helpful
            • 3. Re: Accessing variables from a symbol?
              rossfranks Level 1

              Thanks resdesign,

               

              yes you are correct, they are labels, but within the character's symbol timeline, I guess an image would help show what I want to do, so here it is...

               

              chem001.jpg

               

              So the user can click on the coat, goggles or door. And here's what I want: if the user just clicks on the door then the character walks through the door and runs out on fire and his eyes melting (ie label  "noCoatNoGoggles"), if they click on the goggles only, then he walks through and runs out on fire (ie label  "goggles"), and if they click on the coat only, then he walks through and runs out with his eyes melting (ie label  "coat"). If the character clicks on both the coat and goggles, then the character walks through the door and the screen fades and goes to another scene.

               

              So at the moment I have the goggles and coat change to false when you click on them, and then when the character walks through the door it should then check to see what each variable is set at and then jump to the appropriate frame label and thus the appropriate animation. But unforunately it's not working.

               

              Unfortunately I dont think the code you gave me will work for what I'm after too because where do I place the false statement for the coat and goggles?

               

              I hope that explains what I'm trying to do better.

              • 4. Re: Accessing variables from a symbol?
                resdesign Adobe Community Professional & MVP

                I think that you should use setVariable and getVariable because it works across the composition. I am very busy with some deadline right now but if you post a link to you files, I am sure someone can help you further.

                Also check out the samples here for the setVariable usage:

                http://www.adobe.com/devnet/edge-animate/articles/showcase-sample-files.html

                1 person found this helpful
                • 5. Re: Accessing variables from a symbol?
                  rossfranks Level 1

                  Ok thanks resdesign,

                   

                  I'll look into that.