5

I have two MovieClip symbols in my library and I want them to share the same class, but Flash doesn't allow me to assign the same class to any two different MC symbols, so instead I created two bogus classes which extend the class I wished to share initially.

So having two MC symbols defined by 2 different classes extending a different class allows me to share the same piece of code.

My Question: is there a better was to share a class between 2 or more different library symbols?

IneedHelp
  • 1,630
  • 1
  • 27
  • 58
  • 1
    You didn't create bogus classes. See my comment on @Cameron's answer. Whether you define a class or not, every single library item already IS a unique class and if you don't specify the class identifier, flash creates one automatically. –  Jan 01 '12 at 05:18
  • @BoltClock you're wrong to have removed the Flash CS5/CS4/CS3 tags. This is specifically related to the IDE. –  Jan 01 '12 at 05:26
  • Yes, you're right. I should've chosen my words better. When I said bogus I was actually thinking about proxies. Also, thanks for the information regarding the fact that Flash automatically creates classes for every single library item, I thought Flash creates classes automatically only for symbols containing code and that it would place those in an automatically created package which bares the name of the exported swf file prefixed with _fla (e.g. ExportedSwfName_fla). – IneedHelp Jan 01 '12 at 05:57

1 Answers1

4

Whatever you're doing, you don't understand the concept of "using" a class associated with a movie clip object. It is impossible for you to assign the same class name to both objects and even if you are, believe me the IDE is actually creating two different objects which extend the original class. You can assign a library item directly to a class, or you can define a new class name which EXTENDS the .as file/class you're referencing as the base class. The latter is the solution intended for simply applying a base class with base-functionality to several objects.

An example of this would be to define a basic class that catches roll over and roll out events and makes the clip grow and shrink on roll in/out. You then make 10 different types of buttons in your movieclip and assign the class you made as the base class, while giving a unique name to the library object itself.