Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do I understand correctly that you want to create an instance of an empty movie clip with class behavior attached and without having to define an empty clip symbol in the library?</p> <p>If that's the case you need to use the packages trick. This is my base class (called View) that I've been using over the years and on hundreds of projects:</p> <pre><code>import mx.events.EventDispatcher; class com.tequila.common.View extends MovieClip { private static var _symbolClass : Function = View; private static var _symbolPackage : String = "__Packages.com.tequila.common.View"; public var dispatchEvent : Function; public var addEventListener : Function; public var removeEventListener : Function; private function View() { super(); EventDispatcher.initialize( this ); onEnterFrame = __$_init; } private function onInitialize() : Void { // called on the first frame. Event dispatchers are // ready and initialized at this point. } private function __$_init() : Void { delete onEnterFrame; onInitialize(); } private static function createInstance(symbolClass, parent : View, instance : String, depth : Number, init : Object) : MovieClip { if( symbolClass._symbolPackage.indexOf("__Packages") &gt;= 0 ) { Object.registerClass(symbolClass._symbolPackage, symbolClass); } if( depth == undefined ) { depth = parent.getNextHighestDepth(); } if( instance == undefined ) { instance = "__$_" + depth; } return( parent.attachMovie(symbolClass._symbolPackage, instance, depth, init) ); } public static function create(parent : View, instance : String, depth : Number, init : Object) : View { return( View( createInstance(_symbolClass, parent, instance, depth, init) ) ); } } </code></pre> <p>So, all you have to do to use this class is to subclass it:</p> <pre><code>class Foo extends View { private static var _symbolClass : Function = Foo; private static var _symbolPackage : String = "__Packages.Foo"; private function Foo() { // constructor private } private function onInitialize() : Void { // implement this to add listeners etc. } public static function create(parent : View, instance : String, depth : Number, init : Object) : Foo { return( Foo( createInstance(_symbolClass, parent, instance, depth, init) ) ); } } </code></pre> <p>You can now create an instance of Foo like this;</p> <pre><code>var foo : Foo = Foo.create( this ); </code></pre> <p>Assuming that 'this' is some type of MovieClip or View.</p> <p>If you need to use this with a library symbol then just leave out the __Packages prefix on the _symbolPackage member.</p> <p>Hope this helps...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload