[flexcoders] Drawing on Canvas using Graphics API with backgroundColor

2008-07-19 Thread Vijay Ganesan

I'm trying to draw a line on a Canvas using the Graphic API as follows:

myCanvas.graphics.clear();
myCanvas.graphics.lineStyle(2);
myCanvas.graphics.moveTo(0,0);
myCanvas.graphics.lineTo(100,100);

This works fine as long as the Canvas does not have a backgroundColor
style property set. Once the backgroundColor property is set, my drawn
line is behind the background color. If I change the backroundAlpha
to a value closer to 0, I can see my drawn line through the background.

How can I draw my line on top of the background? I tried using a Shape
object to draw into and add the Shape object as a child to the Canvas
but get an exception:
TypeError: Error #1034: Type Coercion failed: cannot convert
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent.
I guess children of Canvas have to be IUIComponentS.

What is the best strategy for drawing on a Canvas with a backgroundColor?

Thanks
Vijay




[flexcoders] Drawing on canvas

2005-09-02 Thread Prasad Dhananjaya
Hi All,

I want to draw some dots on the canvas(which are going to use as codinates)
and I did it. But when I move scrollbar(vScrollbar or HScrollbar)
these dots are not moving. They are fixed(may be not on the canvas).
But image12.jpgis on the canvas and when I move scrollbar it also moves.
Plesae tell me how can I draw these dots on the canves.

Thanks
Prasad

---
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml;
 mx:Script
![CDATA[
  function drawDots(){
  var xx:Number=35;
  var yy:Number=35;
  var ref_mc = this.Canves1.createEmptyObject(square, 
this.getNextHighestDepth());
  for (var i:Number=0;i=15;i++){
  ref_mc.fillRect(xx, yy, xx+5, yy+5, 0x00, 100);
  xx=xx+75;
  yy=yy;75;
}
}
]]
/mx:Script

  mx:Panel width=100% height=100% title=Panel1
   mx:Canvas id=Canves1 x=0 y=110  width=100% height=225 
backgroundColor=#DEE0FE vScrollPolicy=auto creationComplete=drawDots() 
visible=true
   mx:Image x=2205 y=2382  source=image12.jpg width=32 
height=32 /
  /mx:Canvas
  /mx:Panel
/mx:Application
-



 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Drawing on canvas

2005-09-02 Thread Abdul Qabiz
Try this:

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml;
 mx:Script
![CDATA[
  function drawDots(event){
  var xx:Number=35;
  var yy:Number=35;
  //var ref_mc = Canves1.createEmptyObject(square,
this.getNextHighestDepth());
  var ref_mc = Canves1.createChild(mx.containers.Canvas,
undefined,{percentWidth:100, percentHeight:100});
  for (var i:Number=0;i=15;i++){
  ref_mc.fillRect(xx, yy, xx+5, yy+5, 0x00, 100);
  xx=xx+75;
  yy=yy;75;
}
}
]]
/mx:Script

  mx:Panel width=100% height=100% title=Panel1
   mx:Canvas id=Canves1 x=0 y=110  width=100% height=225
backgroundColor=#DEE0FE vScrollPolicy=auto
creationComplete=drawDots() visible=true
   mx:Image x=2205 y=2382  source=image12.jpg width=32
height=32 /
  /mx:Canvas
  /mx:Panel
/mx:Application



I need to investigate to find out why your approach is not working.

-abdul 

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Prasad Dhananjaya
Sent: Friday, September 02, 2005 11:50 AM
To: FlexML
Subject: [flexcoders] Drawing on canvas

Hi All,

I want to draw some dots on the canvas(which are going to use as
codinates)
and I did it. But when I move scrollbar(vScrollbar or HScrollbar)
these dots are not moving. They are fixed(may be not on the canvas).
But image12.jpgis on the canvas and when I move scrollbar it also
moves.
Plesae tell me how can I draw these dots on the canves.

Thanks
Prasad

---
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml;
 mx:Script
![CDATA[
  function drawDots(){
  var xx:Number=35;
  var yy:Number=35;
  var ref_mc = this.Canves1.createEmptyObject(square,
this.getNextHighestDepth());
  for (var i:Number=0;i=15;i++){
  ref_mc.fillRect(xx, yy, xx+5, yy+5, 0x00, 100);
  xx=xx+75;
  yy=yy;75;
}
}
]]
/mx:Script

  mx:Panel width=100% height=100% title=Panel1
   mx:Canvas id=Canves1 x=0 y=110  width=100% height=225
backgroundColor=#DEE0FE vScrollPolicy=auto
creationComplete=drawDots() visible=true
   mx:Image x=2205 y=2382  source=image12.jpg width=32
height=32 /
  /mx:Canvas
  /mx:Panel
/mx:Application

-




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 





 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/