[flexcoders] Newbie in need of help with graphics

2007-05-05 Thread williamkusumo
Please forgive this stupid question. I can't seem to figure out how to
draw a simple rectangle in a Flex app...:(

I know it involve the graphics object and I have to call drawRect at
some point. But where do I put this code, and how do I attach this
rectangle into one of the container?

Any help is much appreciated. I can't seem to find any tutorial that
is actually working either.

Thanks!



Re: [flexcoders] Newbie in need of help with graphics

2007-05-05 Thread Daniel Freiman

check out:

http://livedocs.adobe.com/flex/201/html/05_Display_Programming_162_07.html

Daniel Freiman
nondocs http://nondocs.blogspot.com

On 5/5/07, williamkusumo [EMAIL PROTECTED] wrote:


  Please forgive this stupid question. I can't seem to figure out how to
draw a simple rectangle in a Flex app...:(

I know it involve the graphics object and I have to call drawRect at
some point. But where do I put this code, and how do I attach this
rectangle into one of the container?

Any help is much appreciated. I can't seem to find any tutorial that
is actually working either.

Thanks!

 



Re: [flexcoders] Newbie in need of help with graphics

2007-05-05 Thread Manish Jethani
On 5/5/07, williamkusumo [EMAIL PROTECTED] wrote:
 Please forgive this stupid question. I can't seem to figure out how to
 draw a simple rectangle in a Flex app...:(

 I know it involve the graphics object and I have to call drawRect at
 some point. But where do I put this code, and how do I attach this
 rectangle into one of the container?

Here's a simple component that draws a 100x100 rectangle.

  package {
import flash.display.*;
import mx.core.*;

public class RectangleComponent extends UIComponent {
  override protected function updateDisplayList(w:Number, h:Number):void
  {
super.updateDisplayList();

var g:Graphics = this.graphics;
g.clear();
g.beginFill(0xFF);
g.drawRect(0, 0, w, h);
g.endFill();
  }
}
  }

In your application's MXML code:

 mx:VBox
   local:RectangleComponent xmlns:local=* width=100 height=100 /
 /mx:VBox

Note that in Flex components should ideally delegate any graphics work
to a skin class, and any colours, etc., should come from CSS styles
(as opposed to being hard-coded in the component's code).

http://livedocs.adobe.com/flex/2/langref/flash/display/Graphics.html