Or try static methods...

//
//      IN FLA
//


var myBox:DrawBox = DrawBox.newBox ( "boxname", _root );
myBox._y = 100;
myBox._alpha = 50;


//
//      IN DrawBox.as
//


class DrawBox extends MovieClip 
{

        public function DrawBox ( )
        {
        }

        public static function newBox ( boxname, boxtarget ):DrawBox
        {

                var mc = boxtarget.createEmptyMovieClip ( boxname,
boxtarget.getNextHighestDepth());
                mc.__proto__ = DrawBox.prototype;
                mc.INIT ();
                return mc;
        }
        
        private function INIT()
        {
                with ( this )
                {
                                beginFill(0xFF0000,100);
                                moveTo(0,0);
                                lineTo(100,0);
                                lineTo(100,100);
                                lineTo(0,100);
                                lineTo(0,0);
                                endFill();
                }
        }
}



_____________________________

Jesse Graupmann
www.jessegraupmann.com 
www.justgooddesign.com/blog/ 
_____________________________



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Glen Pike
Sent: Friday, June 08, 2007 3:58 PM
To: [email protected]
Subject: Re: [Flashcoders] Having MovieClip behaviours in a class..

Hi,
   
    If you are extending a movie-clip, why can't you just draw in there??

    e.g.

class DrawBox extends MovieClip {

      public function drawBox() {
       beginFill(0xFF0000,100);
       moveTo(0,0);
       lineTo(100,0);
       lineTo(100,100);
       lineTo(0,100);
       lineTo(0,0);
       endFill();
   }
}

attachMovie("DrawBox", "myBox", 1);

myBox.drawBox();

myBox._y = ...

HTH

Glen
   

O. Fouad wrote:
> Ok, this is just frustrating me... somebody help me please :(
>
> i've got this class DrawBox that as it says, draws a box on the stage..
>
> class DrawBox extends MovieClip {
>    var myMC:MovieClip;
>
>    public function DrawBox(boxName:String) {
>        this.myMC =
> _root.createEmptyMovieClip(boxName,_root.getNextHighestDepth());
>        this.myMC.beginFill(0xFF0000,100);
>        this.myMC.moveTo(0,0);
>        this.myMC.lineTo(100,0);
>        this.myMC.lineTo(100,100);
>        this.myMC.lineTo(0,100);
>        this.myMC.lineTo(0,0);
>        this.myMC.endFill();
>    }
> }
>
> this works so fine and in fact i've got a 100x100 red box on my stage, 
> and i
> thought that extending MovieClip, this class, should get the same 
> behaviours
> of a MovieClip like this:
>
> var myBox:DrawBox("boxname");
> myBox._y = 100;
> myBox._alpha = 50;
>
> but desperately it doesnt work as in the box alpha and y doesnt change...
>
> is there something Missing?
> Thanks :)
>

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to