5 Replies Latest reply on Mar 13, 2008 3:58 PM by clbeech

    Dynamically swapping symbols in a movieclip

    Level 7
      Hey guys,

      What I'm trying to do here is dynamically change a symbol displayed in a
      movieclip based on the value of a registry key.

      I created a movieclip called customer_logo, which has five keyframes, each
      with a different image. When the registry key "LogoChoice" is valued at 1,
      I'd like the first frame of the movieclip to show. When the key is valued at
      2, I'd like the second frame to show, and so on. The instance name of the
      movieclip on the stage is "logo."

      Here's the code I put in my actions frame on the stage.

      if (LogoChoice==1){
      logo.gotoAndStop(1);
      }

      if (LogoChoice==2){
      logo.gotoAndStop(2);
      }

      if (LogoChoice==3){
      logo.gotoAndStop(3);
      }

      //this will continue for however many other frames there will be in the
      movieclip

      There are also stop commands (ie. Stop(); ) in each frame of the movieclip.

      When I test this code, however, just the first slide of the movieclip
      appears, no matter what the registry key is. I'm using the .swf file in
      conjunction with MultiMedia Builder, and I've tested my method of calling on
      the registry, and it works. It seems that my problem is with the lines
      "logo.gotoAndStop();" but I don't know what I'm doing wrong.

      Thanks in advance!

      -Chris

        • 1. Re: Dynamically swapping symbols in a movieclip
          clbeech Level 3
          how is the 'registry key' being loaded?
          • 2. Re: Dynamically swapping symbols in a movieclip
            Level 7
            It's being loaded by MultiMedia Builder when the actual program executable
            is run. I've used this method before in the following context, which has
            worked, so this shouldn't be an issue...

            //Turn off/on AdButton button depending on MMB Parameters
            if (ShowAdButton==0){
            delete image_mcl;
            adbut.enabled=false;
            }


            "clbeech" <webforumsuser@macromedia.com> wrote in message
            news:frbtbo$isf$1@forums.macromedia.com...
            > how is the 'registry key' being loaded?
            >

            • 3. Re: Dynamically swapping symbols in a movieclip
              clbeech Level 3
              often with issues like this one it's a matter of 'when' the variable gets it's assignment, it may be that it's getting the value 'after' the condition has executed. which is why i was asking in this case. I'd try throwing a trace on the LoadChoice var previous to the conditionals and see what value your getting at that point.

              Sorry I'm unfamiliar with MultiMedia Builder, but I'm guessing that it's a matter of timing here.

              hmmm... also if this code is in the MC 'logo' it may be that the value is at the root, you may need to reference it as:

              _parent.LogoChoice

              also then you could use: gotoAndStop(n); without the 'logo' preface.
              • 4. Re: Dynamically swapping symbols in a movieclip
                Level 7
                Hi clbeech,

                I tried your suggestion with referencing the value as _parent.LogoChoice,
                and still came up dry. I have to use ActionScript 2 for this, by the way.
                I did a little experimenting, and found out that I can get the registry
                value at the root, but not in the MC (even with _parent.LogoChoice). I tried
                creating a global variable from the registry value, which works at the root,
                but still doesn't work in the MC... Any idea what is causing this? This
                probably isn't the best way of assigning a global variable, but shouldn't it
                still be readable from the MovieClip?

                //this is the code on my actions layer
                if (LogoChoice==1){
                _global.logonumber=1;
                }
                if (LogoChoice==2){
                _global.logonumber=2;
                }
                if (LogoChoice==3){
                _global.logonumber=3;
                }
                //etc, etc, etc...


                //this is the code I put in the first frame of logo, the MC
                if (logonumber==1){
                stop();
                }
                if (logonumber==2){
                gotoAndStop(2);
                }
                if (logonumber==3){
                gotoAndStop(3);
                }
                //etc, etc, etc...

                any thoughts?

                "clbeech" <webforumsuser@macromedia.com> wrote in message
                news:frc1ir$nfr$1@forums.macromedia.com...
                > often with issues like this one it's a matter of 'when' the variable gets
                > it's
                > assignment, it may be that it's getting the value 'after' the condition
                > has
                > executed. which is why i was asking in this case. I'd try throwing a
                > trace on
                > the LoadChoice var previous to the conditionals and see what value your
                > getting
                > at that point.
                >
                > Sorry I'm unfamiliar with MultiMedia Builder, but I'm guessing that it's a
                > matter of timing here.
                >
                > hmmm... also if this code is in the MC 'logo' it may be that the value is
                > at
                > the root, you may need to reference it as:
                >
                > _parent.LogoChoice
                >
                > also then you could use: gotoAndStop(n); without the 'logo' preface.
                >

                • 5. Re: Dynamically swapping symbols in a movieclip
                  clbeech Level 3
                  ok Chris (me too btw lol) now were getting somewhere. try this maybe...

                  assign the incoming ref to a var at the root on frame one, then reference the swf native var from the clip:
                  var choice = LogoChoice;

                  and then in the condition -
                  _parent.choice == n

                  but you know, better yet - why not just do it straight from the root timeline first frame: as in