0 Replies Latest reply on Nov 17, 2006 9:18 AM by alanskinner

    help with attachMovie AS2 Linkage Classes

    alanskinner Level 1



      attachMovie woes

      Hi I am having some trouble with Classes with respect to a movieclips 'As 2.0 class' in the linkage settings.
      After an attachMovie i am expecting my Class members to exist but they are not

      OK, This is what i was doing...

      I create a MovieClip called Class1_mc and another called Class2_mc, original eh.
      i then stick an instance of class2_mc INSIDE of Class1_mc, call it clipinner

      ok so i assign Class1 to Class1_mc and Class2 to Class2_mc via the linkage settings.

      I then create Class1.as and Class2.as.

      class Class2 extends MovieClip
      {

      function Class2()
      {
      }

      function onLoad()
      {
      trace(this + " Loaded.");
      }
      }

      and

      class Class1 extends MovieClip
      {

      function Class1()
      {
      }

      function onLoad()
      {
      trace(this + " Loaded.");
      }
      }


      ok in first frame i write


      stop();
      attachMovie("Class1_mc", "clip", 20);
      trace("class should be loaded and ready to use by now!!! " + clip);


      so i attach my MovieClip and print some text out, this is what the output window says...


      //*********************************************
      class should be loaded and ready to use by now!!!
      _level0.clip Loaded.
      _level0.clip.clipinner Loaded.
      //*********************************************


      WOW! look at the order of the traces, the inner clips are LAST!


      ok so my point is this

      [**CONFUSED RANT** I KNOW movie clips arent always available straight away as they need to load in etc usually but i thought ATTACHMOVIE

      always returned the object straight away without loading delays, there is nothing to LOAD here??]


      Anyway, What i was wanting to do was......


      stop();
      var myClip = attachMovie("Class1_mc", "clip", 20);
      myClip.clipinner.ClassMethodCall('somevalue');

      but i couldnt because it didnt exist

      the following,

      trace(myClip.clipinner.ClassMethodCall); == undefined

      why is this undefined???




      If i am going about this totally wrong PLEASE tell me.

      What are the 'best practises' for attaching Classes to MovieClips? is this the best way?
      I am expecting the code to work like c++, if i create a class all inherited classes get created before new returns.

      I know this is FLASH and i know i didnt do NEW it was ATTACHMOVIE but i dont see the point in being able to link to a class when it isnt

      available until some random point i the future. There must be a better way to do this?

      Right get your thinking hats on, this is driving me mental

      I ended up creating the classes with new and passing in the MovieClip instance, that works but the other way just seemed so convenient!

      Cheers