1 Reply Latest reply on Jun 24, 2006 2:40 AM by Peter Lorent

    MovieClip question

    sneskid
      This will seem like a dump question, but I'm having a hard time cracking the enigma.

      Say you have a blank fla file and you add this code:
      var mc:MovieClip = new MovieClip();
      mc.loadMovie("A_Movie.swf");

      Raises the error: Target not found: Target="undefined" Base="_level0"
      The error happens because there isn't yet a MovieClip on the main timeline... so can mc become part of the timeline after being declared in this way?
      Ofcourse you can use _root.createEmptyMovieClip("mc", 1); but I'm inquiring about something along the lines of mc.attachMeTo(_root, 1); or _root.attachMovieClipFromVariable(mc, 1);

      Overall the only use for MovieClip variables when declared in AS seems to be to reference existing movie clips or ones made with the attachMovie function. The variable itself doesn't seem to be able to become part of the timeline.

      I guess what I'm also trying to figure out is how to share 1 movie clip instance across several other movie clip instances.
      Is it possible to make properties shared? For example say you have a class that extends the movie clip class, it has the _alpha property. Can that property be static, so all instances of that class will be affected?

      Hope that makes sense, any insight would help.
        • 1. Re: MovieClip question
          Peter Lorent Level 2
          No, you can't use the constructor function. You can only create movieclip instances with attachMovie, duplicateMovieClip or createEmptyMovieClip.

          When you extend the movieclip class there is a one-to-one relationship between a movieclip in the library and a AS2 class (a single movieclip symbol is associated with a single movieclip subclass). You can attach that class to other mc's in your library too so eventhough the visual appearance is different, the objects can share the same behaviour.