I am curious about code in my action script project:
public var _p:Object ...
in a function:
public function WObject(pp:MovieClip) { _p = pp; _p.Play(); }
The Play() function is in MovieClip but not Object, can action script allow such syntax?
I am curious about code in my action script project:
public var _p:Object ...
in a function:
public function WObject(pp:MovieClip) { _p = pp; _p.Play(); }
The Play() function is in MovieClip but not Object, can action script allow such syntax?
Since any AS3 object is a child of Object, downcasting a MovieClip to Object is possible. This is possible due to the dynamic nature of AS3 objects (since AS3 is based on ECMAScript) which would allow you to invoke methods such as play() on an Object that contains a MovieClip without having the compiler/player throw sharp objects at you.
Having said the above, it is generally a good practice not to downcast in such a manner unless absolutely necessary since this tends to make code harder to understand and thus maintain.
Other considerations are compile-time type checking and code-hinting (argument hints, code completion, etc). These would not be available to you should you choose to downcast to Object.