3 Replies Latest reply on Jan 27, 2007 2:35 PM by Left-brained

    Instance Names to Variables

    Left-brained
      Hi,

      I'm very new to Flash and ActionScript, but I do have a background in programming server and client-side web applications, so at least I'm not completely clueless.

      I'm trying to figure out when an Instance Name actually becomes available to the ActionScript, so I can modify it.

      I've got a Movie Clip in Scene 1 -> Frame 10, in that Movie Clip, on Frame 10 I've got an empty Movie clip that I'm trying to load a .swf into. I can actually load the .swf into it if I put the code to load it into the same frame that I'm displaying the .swf in, but, I want it to be completely loaded before I move into that frame.

      Through trial and error I actually managed to get it to act like I need by putting the instance in frame 1 and setting it's alpha to 0, so it isn't visble. That solution doesn't seem very portable to me.

      Is there a "correct" way to load a file into a Movie Clip before it gets instantiated? Or, what are the various ways people work-around this issue? This "solution" I've found works in this particular case, but there are a few similar cases in this project where this would be just too cumbersome.

      Thanks,
      Chris
        • 1. Re: Instance Names to Variables
          Level 7
          Chris,

          > Through trial and error I actually managed to get it to act
          > like I need by putting the instance in frame 1 and setting
          > it's alpha to 0, so it isn't visble.

          That's the way to do it, for better or worse. The timeline metaphor is
          a powerful one for animation, but it can be confusing in terms of
          programming. The instance name becomes a variable automatically for you,
          and that occurs when the playhead enters that frame.

          > That solution doesn't seem very portable to me.

          I can see that. ;) One of the quirks.

          > Is there a "correct" way to load a file into a Movie Clip before
          > it gets instantiated?

          Before it's instantiated, there's nothing (no MovieClip instance) to
          load the content into.

          > Or, what are the various ways people work-around this
          > issue? This "solution" I've found works in this particular
          > case, but there are a few similar cases in this project where
          > this would be just too cumbersome.

          The MovieClip.createEmptyMovieClip() method lets you create a MovieClip
          instance at runtime. That may be a way to go. You could also extend
          MovieClip and associate your sub class with that particular movie clip asset
          in the Library (right click and look at Properties or Linkage...). That way
          your sub class could set this instance invisible until otherwise needed.

          But the solution you've already found is a typical no-frills approach.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Instance Names to Variables
            Peter Lorent Level 2
            >>Is there a "correct" way to load a file into a Movie Clip before it gets instantiated
            Well, how can you load something in a non-existing object? Like you did you can set the mc to invisible or you use a preloader on frame 10 of the mc.
            • 3. Re: Instance Names to Variables
              Left-brained Level 1
              quote:

              Originally posted by: Newsgroup User
              Chris,

              > Through trial and error I actually managed to get it to act
              > like I need by putting the instance in frame 1 and setting
              > it's alpha to 0, so it isn't visble.

              That's the way to do it, for better or worse. The timeline metaphor is
              a powerful one for animation, but it can be confusing in terms of
              programming. The instance name becomes a variable automatically for you,
              and that occurs when the playhead enters that frame.

              > That solution doesn't seem very portable to me.

              I can see that. ;) One of the quirks.

              > Is there a "correct" way to load a file into a Movie Clip before
              > it gets instantiated?

              Before it's instantiated, there's nothing (no MovieClip instance) to
              load the content into.

              > Or, what are the various ways people work-around this
              > issue? This "solution" I've found works in this particular
              > case, but there are a few similar cases in this project where
              > this would be just too cumbersome.

              The MovieClip.createEmptyMovieClip() method lets you create a MovieClip
              instance at runtime. That may be a way to go. You could also extend
              MovieClip and associate your sub class with that particular movie clip asset
              in the Library (right click and look at Properties or Linkage...). That way
              your sub class could set this instance invisible until otherwise needed.

              But the solution you've already found is a typical no-frills approach.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."





              Ok, thanks. That's not exactly the answer I was hoping for, but it's the answer I needed :)

              Off to do weird stuff with invisible movie clips now.

              Thanks very much,
              Chris