Warning: All instances will be automatically declared as…

Sometimes it’s useful to have two Flash symbols which use the same Base Class which references symbols within the clip, that could be differently symbols. For example, a symbol of base class ‘Menu’ could contains symbols, of base class ‘menuItem’. You might want this to occur in two symbols, ‘MainMenu’ and ‘SubMenu’ which reuse the same ‘Menu’ class for reuse, because they contain exactly the same functionality.i.e.:

the movieClip MainMenu, has the base class Menu

the movieClip SubMenu has the base class Menu

However, you’ll encounter a warning:

Warning: All instances named ‘xxx’ will be automatically declared as xxx in symbols that use xxx as their base class. In symbols that are linked to user-defined base classes, instances with the same name must be of the same type.

In our example, all items called ‘menuItem1’ within the ‘menu’ class will all be visually the same, because their class is assumed to be the same.

Now googling this problem seems to result in only one possible solution, to uncheck ‘Automatically declare stage instances’ in the advanced actionscript 3.0 settings, but really this makes life more difficult in other areas. There are also calls for Adobe to automatically declare instances as the base class rather than the super class, but I believe this would introduce other problems, as the symbols contained in the superclass would not be available.

My solution is probably obvious to some, but here it is. To avoid Flash automatically declaring the instance as the superclass and therefore typing all symbols the same, we just need to create a simple unique base class for each unique symbol that extends our class. This is a little confusing to explain, so to return to the example:

the symbol MainMenu, has the base class MainMenu, which just extends the ‘Menu’ class.

the symbol SubMenu, has the base class SubMenu, which just extends the ‘Menu’ class.

This way the menu items are not automatically typed to be the same symbol.

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with: ,
Posted in Flash

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: