AS3: Why does datatype automatically change from TextField to DisplayObject on its own?

You're seeing the difference between compile time and run-time type. In this code.

You're seeing the difference between compile time and run-time type. In this code: trace( active_button. UpState ); // object TextField You're passing the object to trace and trace is going to show the actual object type that exists at run-time.

However, in this case: active_button.upState. TextColor = 0x000000; You're writing code that uses the object in upState. UpState is defined as DisplayObject and all DisplayObject don't have a textColor property, so it has to give you an error.

UpState is allowed to actually contain anything that is a DisplayObject or a subclass of DisplayObject like a TextField. You can tell the compiler that you know for sure it's a TextField by casting it. TextField(active_button.

UpState). TextColor = 0x000000; There is another form of casting using the as keyword which will return the object, typed as specified, or null. You want to use this keyword to test if an object is a certain type and then conditionally use it (via a!

= null check). Var textField:TextField = active_button. UpState as TextField; if (textField!

= null) { textField. TextColor = 0; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions