Kerry,

You should turn Strict mode on your FLAs in the publish profile settings. If you click on the language (the place you set your class paths and if you want Flash to auto-declare stage instances), you should see a checkbox for strict mode. Turn it on.

The reason you want strict mode is because it will catch errors that the normal Flash compiler does not. Strict mode will help you quite a bit and expose obvious errors that the normal Flash compiler does not catch, which results in confusing runtime errors that should have been caught during compiling. I wish there was a way to turn Strict mode on by default, but AFAIK, you have to do it manually for every Flash file.

Leaving variables untyped is loose coding and AS3 is all about enforcing strict coding. Using * as a wildcard type is not generally something you want to do, but it's there for you if you need it (notable exceptions include specific game programming situations where it's been proven faster to iterate over certain wildcard variables than typed ones).

In the example given, the proper way of doing that would be to do what I originally said; either have both classes extend the same abstract and cast the var to the abstract, or have both classes implement the same interface and cast the var to that. In this case, you can probably get away with a wildcard, but you should never leave a variable untyped.

At the very least, you're making your code more readable in the sense that you're explicitly setting a type as a wildcard and it's clear in the code that's what you wanted, vs you forgot to set a type.

HTH,
Steven

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to