Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

draw line on top of bitmap

346 views
Skip to first unread message

finecur

unread,
Sep 26, 2007, 10:23:43 AM9/26/07
to
Hi, I am trying to draw bitmap on canvas and then lines on top of the
bitmap. My code is attached. I found that the lines is alwasy
underneath the bitmap and thus not visuable. How can I fix it?

Thanks,

var loader:Loader = Loader(event.target.loader);
var image:Bitmap = Bitmap(loader.content);
var bitmapHolder:UIComponent = new UIComponent();
var mySprite:Sprite = new Sprite();
mySprite.addChild(image);
bitmapHolder.addChild(mySprite);
canvas.height = image.height;
canvas.width = image.width;
canvas.addChild(loader);

canvas.graphics.lineStyle(2, 0xff0000, 1);
canvas.graphics.moveTo(-100, -100);
canvas.graphics.lineTo(200, 200);

Munkii

unread,
Oct 5, 2007, 5:43:49 PM10/5/07
to
What I did to solve this problem was make the background of my
Drawable Component transparent, and then position it on top of another
canvas with the desired background colour.

This works nicely, and means you can use your drawable component to
draw over anything aswell.

There is a sample application and sample code on my blog:
http://www.munkiihouse.com/?p=4

Hope that helps
Tony

baberuth

unread,
Oct 6, 2007, 8:02:24 AM10/6/07
to

Wow! What a simple and useful tool. Any idea about how to save that
drawing as an image or swf with the click of a button. I am working
on a social network and would like to allow users to draw a logo for
themselves. I would like to add flash like drawing and text
features. With the powerful actionscript 3 classes, I bet this
wouldn't be terribly difficult. Can someone try to implement these
features?

Munkii

unread,
Oct 10, 2007, 9:03:47 PM10/10/07
to
In Flex3 you can do this through the ImageSnapshot class. This is a
convenience class to capture the appearance of any control

In Flex2 this is a little more complicated. You have to create a
BitmapData class, and then call draw function on the bitmap data
object to get an image of the control. From there you can turn it
into an image or save it out to a server etc

0 new messages