Right. I guess I was trying to address your issue about having to add it to the display list twice. You'd still need to addChild( <instance of DrawRectangle> ); But having DrawRectangle extend Sprite and then drawing directly on this.graphics solves the problem of doing it twice.
-jonathan On Tue, Mar 25, 2008 at 4:55 PM, Omar Fouad <[EMAIL PROTECTED]> wrote: > Yeah A good method to do rectangles fast > > On Tue, Mar 25, 2008 at 9:30 PM, Cor <[EMAIL PROTECTED]> wrote: > > > Mmmmmmmmmmm, sounds familiair. :-) > > It has to be added to the Displaylist otherwise it isn't visible. > > > > Cor > > > > -----Oorspronkelijk bericht----- > > Van: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] Namens Omar Fouad > > Verzonden: maandag 24 maart 2008 22:01 > > Aan: Flash Coders List > > Onderwerp: [Flashcoders] Custom DrawRectangle Question > > > > I am creating a custom Class that draws a simple rectangle for an > > application. Here is the class > > > > DrawRectangle.as > > > > public class DrawRectangle extends MovieClip { > > > > public var _w:Number; > > public var _h:Number; > > public var _x:Number; > > public var _y:Number; > > > > public function DrawRectangle(w:Number, h:Number, x:Number, > > y:Number) { > > this._w = w; > > this._h = h; > > this._x = x; > > this._y = y; > > Init(); > > } > > private function Init():void { > > var MC:MovieClip = new MovieClip(); > > MC.graphics.lineStyle(1, 0xFF0000); > > MC.graphics.beginFill(0xFF0000, .3); > > MC.graphics.drawRect(_x,_y,_w,_h); > > addChild(MC); > > } > > > > } > > } > > > > I wrote it without the last line ( addChild(MC) ) and it didnt work. It > > did > > not work Event when In the Main Class I added the addChild() like this: > > > > > > var M:DrawRectangle = new Rectangle(100,100,20,100); > > > > addChild(M); > > > > > > I thought The addChild should be put outside the class. And No It only > > worked when I add the addChild() in the class and out the class... It > > works > > But I want to understand Why?? > > How can I set it to draw from the class iteself?? > > > > Thanks. > > > > > > -- > > Omar M. Fouad - Digital Emotions > > http://www.omarfouad.net > > > > This e-mail and any attachment is for authorised use by the intended > > recipient(s) only. It may contain proprietary material, confidential > > information and/or be subject to legal privilege. It should not be > copied, > > disclosed to, retained or used by, any other party. If you are not an > > intended recipient then please promptly delete this e-mail and any > > attachment and all copies and inform the sender. Thank you. > > _______________________________________________ > > Flashcoders mailing list > > [email protected] > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > -- > > No virus found in this incoming message. > > Checked by AVG. > > Version: 7.5.519 / Virus Database: 269.22.0/1342 - Release Date: > 25-3-2008 > > 10:26 > > > > No virus found in this incoming message. > > Checked by AVG. > > Version: 7.5.519 / Virus Database: 269.22.0/1342 - Release Date: > 25-3-2008 > > 10:26 > > > > > > No virus found in this outgoing message. > > Checked by AVG. > > Version: 7.5.519 / Virus Database: 269.22.0/1342 - Release Date: > 25-3-2008 > > 10:26 > > > > > > _______________________________________________ > > Flashcoders mailing list > > [email protected] > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > > > -- > Omar M. Fouad - Digital Emotions > http://www.omarfouad.net > > This e-mail and any attachment is for authorised use by the intended > recipient(s) only. It may contain proprietary material, confidential > information and/or be subject to legal privilege. It should not be copied, > disclosed to, retained or used by, any other party. If you are not an > intended recipient then please promptly delete this e-mail and any > attachment and all copies and inform the sender. Thank you. > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101 _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

