Re: [Flashcoders] Custom DrawRectangle Question

2008-03-26 Thread Allandt Bik-Elliott (Receptacle)
It seems to me that that would work as a Sprite too - less memory  
overheads (not by much, mind, but it'll help if there's a lot of them)


also, would you be better off making your class variables protected  
or private? Those variables are being set by the constructor, anyway,  
and if you use get() and set() methods on them you could add tweens  
and variable checking (for instance) etc if they're changed once the  
shape is initialised



On 25 Mar 2008, at 20:55, Omar Fouad wrote:


Yeah A good method to do rectangles fast

On Tue, Mar 25, 2008 at 9:30 PM, Cor [EMAIL PROTECTED] wrote:


Mmm, 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, 0xFF);
   MC.graphics.beginFill(0xFF, .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
Flashcoders@chattyfig.figleaf.com
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
Flashcoders@chattyfig.figleaf.com
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
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


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-26 Thread Omar Fouad
Oh yeah I'll make the variables private and make their setters and getters.

Any ways thanks for the help everybody.

Hasta!

On Wed, Mar 26, 2008 at 1:07 PM, Allandt Bik-Elliott (Receptacle) 
[EMAIL PROTECTED] wrote:

 It seems to me that that would work as a Sprite too - less memory
 overheads (not by much, mind, but it'll help if there's a lot of them)

 also, would you be better off making your class variables protected
 or private? Those variables are being set by the constructor, anyway,
 and if you use get() and set() methods on them you could add tweens
 and variable checking (for instance) etc if they're changed once the
 shape is initialised


 On 25 Mar 2008, at 20:55, Omar Fouad wrote:

  Yeah A good method to do rectangles fast
 
  On Tue, Mar 25, 2008 at 9:30 PM, Cor [EMAIL PROTECTED] wrote:
 
  Mmm, 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, 0xFF);
 MC.graphics.beginFill(0xFF, .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
  Flashcoders@chattyfig.figleaf.com
  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
  Flashcoders@chattyfig.figleaf.com
  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
  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




-- 
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

RE: [Flashcoders] Custom DrawRectangle Question

2008-03-25 Thread Cor
Mmm, 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, 0xFF);
MC.graphics.beginFill(0xFF, .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
Flashcoders@chattyfig.figleaf.com
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-25 Thread Omar Fouad
Yeah A good method to do rectangles fast

On Tue, Mar 25, 2008 at 9:30 PM, Cor [EMAIL PROTECTED] wrote:

 Mmm, 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, 0xFF);
MC.graphics.beginFill(0xFF, .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
 Flashcoders@chattyfig.figleaf.com
 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
 Flashcoders@chattyfig.figleaf.com
 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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-25 Thread jonathan howe
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:

  Mmm, 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, 0xFF);
 MC.graphics.beginFill(0xFF, .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
  Flashcoders@chattyfig.figleaf.com
  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
  Flashcoders@chattyfig.figleaf.com
  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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread Omar Fouad
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, 0xFF);
MC.graphics.beginFill(0xFF, .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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread Merrill, Jason
Because within your class which extends MovieClip, you are creating a
new MovieClip, which you draw on, and thus also has to be added to the
display list.

Also, you do know about :

sprite.graphics.drawRect() 

right?  So what is this class going to accomplish?

Any reason you are using MovieClip over Sprite? MovieClip just adds
unecessary overhead in this case.


Jason Merrill
Bank of America  
GTO and Risk LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community


Are you a Bank of America associate interested in innovative learning
ideas and technologies? 
Check out our internal  GTO Innovative Learning Blog  subscribe.




 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Omar Fouad
Sent: Monday, March 24, 2008 5:01 PM
To: Flash Coders List
Subject: [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, 0xFF);
MC.graphics.beginFill(0xFF, .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
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


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread Cory Petosky
To clarify Jason's response:

You're adding two different things. In the first case, you're adding a
child movieclip (with a rectangle drawn inside it) to the empty
DrawRectangle instance. In the second case, you're adding the
DrawRectangle instance to the screen.

You should rewrite your init function so that it draws directly to the instance:

   private function Init():void {
   graphics.lineStyle(1, 0xFF);
   graphics.beginFill(0xFF, .3);
   graphics.drawRect(_x,_y,_w,_h);
   graphics.endFill();
   }

Finally, since this class does not have frames, it should extend
Sprite, not MovieClip.

On Mon, Mar 24, 2008 at 4:01 PM, Omar Fouad [EMAIL PROTECTED] wrote:
 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, 0xFF);
 MC.graphics.beginFill(0xFF, .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
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
Cory Petosky : Lead Developer : PUNY
1618 Central Ave NE Suite 130
Minneapolis, MN 55413
Office: 612.216.3924
Mobile: 240.422.9652
Fax: 612.605.9216
http://www.punyentertainment.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread Omar Fouad
Aha I get it... But can I make a work out in order not to put addChild() in
the main Class? I mean that once I Make an Instance of the class it adds it
on the stage by itself.


Thanks

On Mon, Mar 24, 2008 at 11:27 PM, Cory Petosky [EMAIL PROTECTED]
wrote:

 To clarify Jason's response:

 You're adding two different things. In the first case, you're adding a
 child movieclip (with a rectangle drawn inside it) to the empty
 DrawRectangle instance. In the second case, you're adding the
 DrawRectangle instance to the screen.

 You should rewrite your init function so that it draws directly to the
 instance:

   private function Init():void {
   graphics.lineStyle(1, 0xFF);
   graphics.beginFill(0xFF, .3);
graphics.drawRect(_x,_y,_w,_h);
graphics.endFill();
   }

 Finally, since this class does not have frames, it should extend
 Sprite, not MovieClip.

 On Mon, Mar 24, 2008 at 4:01 PM, Omar Fouad [EMAIL PROTECTED]
 wrote:
  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, 0xFF);
  MC.graphics.beginFill(0xFF, .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
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 Cory Petosky : Lead Developer : PUNY
 1618 Central Ave NE Suite 130
 Minneapolis, MN 55413
 Office: 612.216.3924
 Mobile: 240.422.9652
 Fax: 612.605.9216
 http://www.punyentertainment.com
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread jonathan howe
You could just draw the rectangle directly on the graphics of the
DrawRectangle:

   graphics.lineStyle(1, 0xFF);
   graphics.beginFill(0xFF, .3);
   graphics.drawRect(_x,_y,_w,_h);

Because it extends MovieClip (or Sprite, hopefully, as Steven suggests, it
has its own graphics property.

Then you can think about renaming your class from DrawRectangle to
Rectangle, since it not only draws it, it is one.

-jonathan


On Mon, Mar 24, 2008 at 6:59 PM, Omar Fouad [EMAIL PROTECTED] wrote:

 Aha I get it... But can I make a work out in order not to put addChild()
 in
 the main Class? I mean that once I Make an Instance of the class it adds
 it
 on the stage by itself.


 Thanks

 On Mon, Mar 24, 2008 at 11:27 PM, Cory Petosky [EMAIL PROTECTED]
 
 wrote:

  To clarify Jason's response:
 
  You're adding two different things. In the first case, you're adding a
  child movieclip (with a rectangle drawn inside it) to the empty
  DrawRectangle instance. In the second case, you're adding the
  DrawRectangle instance to the screen.
 
  You should rewrite your init function so that it draws directly to the
  instance:
 
private function Init():void {
graphics.lineStyle(1, 0xFF);
graphics.beginFill(0xFF, .3);
 graphics.drawRect(_x,_y,_w,_h);
 graphics.endFill();
}
 
  Finally, since this class does not have frames, it should extend
  Sprite, not MovieClip.
 
  On Mon, Mar 24, 2008 at 4:01 PM, Omar Fouad [EMAIL PROTECTED]
  wrote:
   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, 0xFF);
   MC.graphics.beginFill(0xFF, .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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
 
 
 
  --
  Cory Petosky : Lead Developer : PUNY
  1618 Central Ave NE Suite 130
  Minneapolis, MN 55413
  Office: 612.216.3924
  Mobile: 240.422.9652
  Fax: 612.605.9216
  http://www.punyentertainment.com
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom DrawRectangle Question

2008-03-24 Thread Omar Fouad
Nothing Changed..The Code is the same and it is not autoadding...

By the way I Know that There is allready drawRect() but I will be adding
some more functionalities to the class that drawRect has not.


On Tue, Mar 25, 2008 at 1:36 AM, jonathan howe [EMAIL PROTECTED]
wrote:

 You could just draw the rectangle directly on the graphics of the
 DrawRectangle:

   graphics.lineStyle(1, 0xFF);
   graphics.beginFill(0xFF, .3);
   graphics.drawRect(_x,_y,_w,_h);

 Because it extends MovieClip (or Sprite, hopefully, as Steven suggests, it
 has its own graphics property.

 Then you can think about renaming your class from DrawRectangle to
 Rectangle, since it not only draws it, it is one.

 -jonathan


 On Mon, Mar 24, 2008 at 6:59 PM, Omar Fouad [EMAIL PROTECTED]
 wrote:

  Aha I get it... But can I make a work out in order not to put addChild()
  in
  the main Class? I mean that once I Make an Instance of the class it adds
  it
  on the stage by itself.
 
 
  Thanks
 
  On Mon, Mar 24, 2008 at 11:27 PM, Cory Petosky 
 [EMAIL PROTECTED]
  
  wrote:
 
   To clarify Jason's response:
  
   You're adding two different things. In the first case, you're adding a
   child movieclip (with a rectangle drawn inside it) to the empty
   DrawRectangle instance. In the second case, you're adding the
   DrawRectangle instance to the screen.
  
   You should rewrite your init function so that it draws directly to the
   instance:
  
 private function Init():void {
 graphics.lineStyle(1, 0xFF);
 graphics.beginFill(0xFF, .3);
  graphics.drawRect(_x,_y,_w,_h);
  graphics.endFill();
 }
  
   Finally, since this class does not have frames, it should extend
   Sprite, not MovieClip.
  
   On Mon, Mar 24, 2008 at 4:01 PM, Omar Fouad [EMAIL PROTECTED]
   wrote:
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, 0xFF);
MC.graphics.beginFill(0xFF, .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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   
  
  
  
   --
   Cory Petosky : Lead Developer : PUNY
   1618 Central Ave NE Suite 130
   Minneapolis, MN 55413
   Office: 612.216.3924
   Mobile: 240.422.9652
   Fax: 612.605.9216
   http://www.punyentertainment.com
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   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