You can't draw directly on an mx:Image component. As suggested below, you need to add a Sprite on top of the image and draw on that sprite. The best way would probably be to inherit from mx:Image and do the drawing in updateDisplayList(). For example:
<?xml version="1.0" encoding="utf-8"?> <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ private var yourSprite:Sprite; override protected function createChildren():void { super.createChildren(); if (!yourSprite) yourSprite = new Sprite(); } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); // Do the drawing on yourSprite.graphics here addChild(yourSprite); } ]]> </mx:Script> </mx:Image> Also, if you need to clear the image, just set Image.source to null. -- Laurent Cozic Flash, Flex and Web Application development http://pogopixels.com --- On Thu, 2/19/09, christophe_jacquelin <[email protected]> wrote: From: christophe_jacquelin <[email protected]> Subject: [flexcoders] Re: Drawing graphics on an image To: [email protected] Date: Thursday, February 19, 2009, 4:53 PM It is OK for drawing the lines but when I draw a new line I would like to erase the preceeding lines that are on the image. I clear the sprite but it is not working. Thank you for your help. Christophe, --- In flexcod...@yahoogro ups.com, "jer_ela" <g...@...> wrote: > > The graphics object for the image or the container it is in, is below > the content so it is hidden behind the image. Stick a display object > such as a sprite on top or it and draw on its graphics object. > > --- In flexcod...@yahoogro ups.com, "christophe_ jacquelin" > <christophe_ jacquelin@ > wrote: > > > > Hello, > > > > I want to draw graphics (graphics.lineto) on an existing image, but > > the lines does not appear. Is it possible to make graphics on an > image ? > > > > Thank you, > > Christophe, > > >

