Hi Ramesh,

Create a sprite and add it to the diplaylist over the image loader.
Then add the drawing items into that sprite. I hope this will solve
your issue.

Thanks,
Abinash

On Feb 28, 6:51 am, Ramesh Vavila <[email protected]> wrote:
> Hi Friends,
>
> Is it possible to draw on an image that is loaded in the panel instead of
> the whiteboard itself? If so, what’s the code for that. I’ve been trying to
> do that, but it draws behind the image instead of on the image. The image is
> loaded in the panel, but the drawing is behind it. please help me in this
> its very urgent
>
> Thanks in Advance
> ramesh v
>
> <?xml version="1.0"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
>                xmlns:s="library://ns.adobe.com/flex/spark"
>                xmlns:mx="library://ns.adobe.com/flex/mx"
>                viewSourceURL="srcview/index.html">
>
>   <s:Panel id="p" title="Flex Paint 4" top="5" horizontalCenter="0"
> width="400" height="400">
>
>     <DrawingArea id="drawingArea" xmlns="*" width="100%" height="100%"/>
>
>     <s:controlBarContent>
>         <mx:ColorPicker change="drawingArea.drawColor =
> event.target.selectedColor"/>
>         <s:Button label="Erase" click="drawingArea.erase()"/>
>         <s:Button label="Save Image" click="drawingArea.save()"/>
>     </s:controlBarContent>
>   </s:Panel>
>
> </s:Application>
>
> package
> {
>   import flash.display.BitmapData;
>   import flash.display.Loader;
>   import flash.events.Event;
>   import flash.events.MouseEvent;
>   import flash.net.FileReference;
>   import flash.net.URLRequest;
>   import flash.utils.ByteArray;
>
>   import mx.core.UIComponent;
>   import mx.events.FlexEvent;
>   import mx.graphics.codec.PNGEncoder;
>
>   public class DrawingArea extends UIComponent
>   {
>     private var isDrawing:Boolean = false;
>     private var x1:int;
>     private var y1:int;
>     private var x2:int;
>     private var y2:int;
>         private var loader:Loader;
>
>     public var drawColor:uint = 0x000000;
>
>     public function DrawingArea()
>     {
>       super();
>
>           loader = new Loader();
>           loader.load(new URLRequest("skin_20.JPG"));
>           loader.height =150;
>           addChild(loader);
>
>       addEventListener(FlexEvent.CREATION_COMPLETE,
> function(event:FlexEvent):void {
>         erase();
>       });
>
>       addEventListener(MouseEvent.MOUSE_DOWN, function(event:MouseEvent):void 
> {
>         x1 = mouseX;
>         y1 = mouseY;
>         isDrawing = true;
>       });
>
>       addEventListener(MouseEvent.MOUSE_MOVE, function(event:MouseEvent):void 
> {
>         if (!event.buttonDown)
>         {
>           isDrawing = false;
>         }
>
>         x2 = mouseX;
>         y2 = mouseY;
>         if (isDrawing)
>         {
>           graphics.lineStyle(2, drawColor);
>           graphics.moveTo(x1, y1);
>           graphics.lineTo(x2, y2);
>           x1 = x2;
>           y1 = y2;
>         }
>       });
>
>       addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void {
>         isDrawing = false;
>       });
>     }
>
>     public function erase():void
>     {
>       graphics.clear();
>
>       graphics.beginFill(0xffffff, 0.00001);
>       graphics.drawRect(0, 0, width, height);
>       graphics.endFill();
>     }
>
>     public function save():void
>     {
>       var bd:BitmapData = new BitmapData(width, height);
>       bd.draw(this);
>
>       var ba:ByteArray = (new PNGEncoder()).encode(bd);
>       (new FileReference()).save(ba, "doodle.png");
>     }
>
>   }}

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to