0
votes

In AS3, if I already have some movieclips on the stage, is it possible, to add a class to that movieclip?

Usually I do it from directly from Flash by linking an AS class to the symbol, but if the sprite/movieclip has been imported from another swf file, may I add a class the this movieclip?

2
I fail to see why in the world you would want to do this, but you could type cast it as the type you want but that type would also need to extend MovieClip if you need frame support.The_asMan
Also I would highly recommend you reading up on classes in AS3 and how inheritance works. This scenario of "adding" a class to a movieclip is jut a bad idea.The_asMan

2 Answers

3
votes

add a class to that movieclip?

Add class?.. If you have some display object on the scene, and you want to give them some behaviour. Wrap them in your custom class, I mean use composition

var myCleverClass: MyCleverClass = new MyCleverClass();
myCleverClass.initiateWith(stage.getChildByName("someSimpleMovieClipOnScene"));

//And do whatever you want
myCleverClass.getMyPoints();
0
votes

Yes of course you can. I assume your library movieclip name is : LibHomePage so your class structure should be like :

package 
{
  public class HomePage extends LibHomePage
  {
      public function HomePage() 
      {
      }
  }

}

and it goes without saying LibHomePage must be MovieClip or Sprite.