9 Replies Latest reply on Mar 23, 2012 8:28 AM by kglad

    _global variable

    armandix Level 1

      Hello friends,

      I have a swf page where the external swf will load, there is any way to declare variables who work in all swf.

      What I am trying to do is:

      like a switch , with several options in which all these are listed in the main swf


        • 1. Re: _global variable
          kglad Adobe Community Professional & MVP

          using _global when setting your variable should work.  of course, you can't retrieve that value until after it's set.

          • 2. Re: _global variable
            armandix Level 1

            I have done this:

             

            if(_global.menux == 1){

             

                _root.menu_side.side.lateral.item1.gotoAndPlay("s1");

               _root.menu_side.side.lateral.item2.gotoAndStop(1);

            } else if (_global.menux == 2){

             

                _root.menu_side.side.lateral.item2.gotoAndPlay("s1");

                _root.menu_side.side.lateral.item1.gotoAndStop(1);

            }else{

                trace(_global.menux);

                _root.menu_side.side.lateral.item2.gotoAndStop(1);

                _root.menu_side.side.lateral.item1.gotoAndStop(1);

            }

            but when I click in each button , the trace should be trace the button value

            • 3. Re: _global variable
              kglad Adobe Community Professional & MVP

              i see no button handlers and i see no trace functions and i see nowhere that menux is defined.

              • 4. Re: _global variable
                armandix Level 1

                Kglad in my first frame in time line I have

                 

                _global.menux = null;

                 

                In the third frame I have the following code:

                 

                if(_global.menux == 1){

                 

                    _root.menu_side.side.lateral.item1.gotoAndPlay("s1");

                   _root.menu_side.side.lateral.item2.gotoAndStop(1);

                } else if (_global.menux == 2){

                 

                    _root.menu_side.side.lateral.item2.gotoAndPlay("s1");

                    _root.menu_side.side.lateral.item1.gotoAndStop(1);

                }else{

                    trace(_global.menux);

                    _root.menu_side.side.lateral.item2.gotoAndStop(1);

                    _root.menu_side.side.lateral.item1.gotoAndStop(1);

                }

                 

                the buttons have the following code:

                 

                on(release){

                _global.menux = 1;

                }

                 

                The value should be printed , but shows nothing...

                • 5. Re: _global variable
                  kglad Adobe Community Professional & MVP

                  does your 3rd frame execute after a button is released?  if not, that code's not going to work.

                  • 6. Re: _global variable
                    armandix Level 1

                    action and the button are on the same frame, but yes  execute after release button,and does show nothing

                    • 7. Re: _global variable
                      kglad Adobe Community Professional & MVP

                      if that were true you would see 1 then 2 in the output panel, not 2 then 1:

                       

                      In the third frame I have the following code:

                       

                      trace(1);

                      if(_global.menux == 1){

                       

                          _root.menu_side.side.lateral.item1.gotoAndPlay("s1");

                         _root.menu_side.side.lateral.item2.gotoAndStop(1);

                      } else if (_global.menux == 2){

                       

                          _root.menu_side.side.lateral.item2.gotoAndPlay("s1");

                          _root.menu_side.side.lateral.item1.gotoAndStop(1);

                      }else{

                          trace(_global.menux);

                          _root.menu_side.side.lateral.item2.gotoAndStop(1);

                          _root.menu_side.side.lateral.item1.gotoAndStop(1);

                      }

                       

                      the buttons have the following code:

                       

                      on(release){

                      trace(2);

                      _global.menux = 1;

                      }

                      • 8. Re: _global variable
                        armandix Level 1

                        Tanks, Kglad

                        • 9. Re: _global variable
                          kglad Adobe Community Professional & MVP

                          you're welcome.