Problem in drawing in sprite


hi,

 

i draw line on sprite object moveto , lineto. line drawn on or under other elements in application.

how make sprite or label keep line contained within itself?

 

 

this exemple,

 

 

 

    import flash.display.sprite;
    import flash.events.mouseevent;
   
    import mx.controls.label;
    import mx.core.uicomponent;
    import mx.managers.cursormanager;
    public class sketchnoteclass extends label
    {
        private var sprite:sprite = new sprite();
        private var draw:boolean = false;

        private var color:uint = 0x000000;      

        private var size:uint = 80;

 

 

       
        public function sketchnote()
        {
            super();
            init();
        }

 

        private function init():void
        {
            var comp:uicomponent = new uicomponent();
            cont.addchild(sprite);
            this.addchild(comp);
            sprite.addeventlistener(mouseevent.mouse_down, startdraw);
            sprite.addeventlistener(mouseevent.mouse_move, draw);
            sprite.addeventlistener(mouseevent.mouse_up, stop);
            sprite.addeventlistener(mouseevent.mouse_out, stop);

 

         
        }
       
        private function startdraw(evtdown:mouseevent):void
        {           
             
            sprite.graphics.linestyle(size, color);                      
            sprite.graphics.moveto(sprite.mousex, sprite.mousey);
            draw= true;
            
        }
       
        private function draw(evtmove:mouseevent):void
        {
            if (draw){
                sprite.graphics.lineto(sprite.mousex, sprite.mousey);
               
            }
        }
       
        private function stop(evtup:mouseevent)
        {
            draw= false;           
        }
       
           
    }

 

 

 

thanks,

well, there're couple of "strange" things do...

1. cannot set functions true or false, so, whenever do:

draw = true or draw = false wouldn't work (not sure have tried achieve doing that).

2. don't understand why need create internal sprite, uicomponent etc inside extends sprite (you access label's graphics property draw on it...

3. intending have line's size more 0xffffff (16777215 decimal) pixels (and never flip it?) why type size uint?

4. can elaborate, what's "contained within itself"? line draw it... belongs graphics object of display object containing it... once draw can clear using graphics#clear(). untill it, remain part of display object drawn.



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts