Professional Web Applications Themes

draw line on top of bitmap - Macromedia Flex General Discussion

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);...

  1. #1

    Default draw line on top of bitmap

    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);

    finecur Guest

  2. #2

    Default Re: draw line on top of bitmap

    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:
    [url]http://www.munkiihouse.com/?p=4[/url]

    Hope that helps
    Tony

    On Sep 27, 3:23 am, finecur <fine...> wrote:
    > 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 Guest

  3. #3

    Default Re: draw line on top of bitmap

    On Oct 5, 2:43 pm, Munkii <tfend...> wrote:
    > 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:[url]http://www.munkiihouse.com/?p=4[/url]
    >
    > Hope that helps
    > Tony
    >
    > On Sep 27, 3:23 am, finecur <fine...> wrote:
    >
    > > 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);
    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?

    baberuth Guest

  4. #4

    Default Re: draw line on top of bitmap

    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

    Munkii Guest

  5. #5

    Default Re: draw line on top of bitmap

    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);
    canv.height = image.height;
    canv.width = image.width;
    canv.addChild(loader);

    Property loader not found on mx.controls.Button and there is no default value . i got this error on a button click
    basava Guest

Similar Threads

  1. Draw line using Acrobat SDK
    By Madhav@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 18
    Last Post: November 25th, 12:26 PM
  2. draw line as a Component
    By ST in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: March 12th, 06:41 AM
  3. Flag for permitting bitmap.draw permission
    By hobnox in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: January 28th, 10:58 AM
  4. 3D Draw Line?
    By connoru in forum Macromedia Director 3D
    Replies: 3
    Last Post: August 4th, 03:27 PM
  5. draw a line
    By hondo3000 webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 2
    Last Post: January 20th, 02:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139