What more can be done if I extend MainClass with MovieClip rather than Sprite. I know that MovieClip extends Sprite and it has Timeline defined under it. but still how it will be usable to me by MovieClip ?
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.MovieClip;
import flash.text.TextFieldType;
public class MainClass extends Sprite{
public function MainClass() {
var m:Module=new Module("Admin","John");
var tf:TextField=new TextField();
tf.text=m.info;
tf.border=true;
tf.type=TextFieldType.INPUT;
var myFormat:TextFormat = new TextFormat();
myFormat.size = 3;
tf.defaultTextFormat=myFormat;
addChild(tf);
this.width=500;
this.height=300;
this.x=0;
this.y=10;
}
}
}
class Module{
private var m_mName:String;
private var m_owner:String;
public function Module(mName:String,owner:String):void{
m_mName=mName;
m_owner=owner;
}
public function get info():String{
return owner+' is owner of '+mName;
}
public function get mName():String{
return m_mName;
}
public function get owner():String{
return m_owner;
}
}
Another little question, How to use Timeline if I replace Sprite by MovieClip ?
Quoting from an AS3 book:
MovieClip is a dynamic class that retains backwards compatibility with AS2. That means that if, while not recommended, require you add a property to a MovieClip, you can simply say
myMC.myCustomProperty = "someValue", whereas with a Sprite, that will throw an error.For this reason, they also say that using Sprites is more effective in terms of performance. You can find a discussion about this in this Adobe Forum post.