Hello :)

Use this code :

var pv:MovieClip = _root.createEmptyMovieClip( "pixViewer", 180);

pv.__proto__ = PixViewer.prototype ; // change inherit

PixViewer.call( pv ) ; // launch the constructor over the new instance.

PS1 : i uppercase the first character of your class.. is a better notation
if you respect the ECMAScript/ActionScript notation ;)

PS2 : In my opensource framework you can use the class ConstructorUtil :
http://svn1.cvsdude.com/osflash/vegas/AS2/trunk/src/vegas/util/ConstructorUtil.as

you can use now the method createVisualInstance :

{{{

import vegas.util.ConstructorUtil ;

var pv:PixViewer = ConstructrorUtil.createVisualInstance( PixViewer ,
createEmptyMovieClip( "pixViewer", 180) , { _x : 25 , _y : 25 } ) ;

}}}

or you can use my vegas.util.factory.DisplayFactory class :
http://svn1.cvsdude.com/osflash/vegas/AS2/trunk/src/vegas/util/factory/DisplayFactory.as

Examples :

1 - with movieclip :

import vegas.util.factory.DisplayFactory ;

var pv:PixViewer = DisplayFactory .createChild( PixViewer , "pixViewer", 180
, this ,  { _x : 25 , _y : 25 } ) ;

2 - with textfield :

import vegas.util.factory.DisplayFactory ;

var myField:CustomTextField = DisplayFactory .createChild( CustomTextField ,
"myField", 180 , this ,  { _width : 400 , _height : 150 } ) ;

PS : This class can change to the depth of all visual instances in AS2
(Video, TextField, MovieClip in the Stage or your code)

More information about my framework :
http://code.google.com/p/vegas/
http://code.google.com/p/vegas/wiki/InstallVEGASwithSVN

EKA+ :)




2008/4/25 Mendelsohn, Michael <[EMAIL PROTECTED]>:

> Hi list...
>
> I have a class (pixViewer extends MovieClip) and an empty MovieClip
> (linkage:emptyMC, not registered to any class in the linkage dialog).  I
> want attached this emptyMC to the stage and I want it to be an instance
> of pixViewer.
>
> __proto__ works, but why won't prototype or registerClass?
>
> //works:
> var pv:MovieClip = _root.createEmptyMovieClip("pixViewer", 180);
> pv.__proto__ = new pixViewer();
> pv.onLoad();
>
> /*
> Why doesn't this work:
> pv.prototype = new pixViewer();
> pv.registerClass(pixViewer);
> */
>
>
> Thanks,
> - MM
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to