Personally, I'm of the opinion that any time you have hard coded
information in a class, you should often avoid doing so and put it in an
external source (like an XML config file), but if it's a minor thing to
have it in the class (which it often is, you don't need to take the time
to make everything dynamic, though in a perfect world, you would), then
you don't have to, but it should/could (again, in a more perfect world)
be a constant. So:
package
{
class MyClass
{
public static const MYVAR_DEFAULT:Number = 10;
private var _myVar:Number;
public function MyClass()
{
_myVar = MyClass.MYVAR_DEFAULT;
}
private function resetValues():void
{
_myVar = MyClass.MYVAR_DEFAULT
}
}
}
You can change the value of _myVar as much as you want later, but you
have the inital value as a constant, which you can use to reset _myVar
if need be (like in the resetValues method above), or for other classes
to pull. It doesn't have to be this way, I just think it's a good way
to handle hard coded values in a class sometimes.
Jason Merrill
Bank of America
Enterprise Technology & Global Risk L&LD
Instructional Technology & Media
Join the Bank of America Flash Platform Developer Community
Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal GT&O Innovative Learning Blog & subscribe.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders