vendredi 23 septembre 2016

Possible color error in AS3

I wrote an AS3 program (.swf output) about a board moving with the mouse, but when I set the color to blue, the result is a yellow outer area of the board surrounding the blue inner area. It only becomes totally blue when the user click the screen. How can I modify the program so that the board becomes blue at the start of the program without clicking once? The program is uploaded onto this link : http://ift.tt/2d5UsRE

And here is the source code, all of it.

package 
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class FlashTest extends Sprite 
    {
        public var board:Sprite;
        public function FlashTest() 
        {
            board = new Sprite();
            addChild(board);
            board.graphics.beginFill(0x0099ff);
            board.graphics.drawRect(0,stage.stageWidth-20,100,10);
            board.graphics.endFill();
            board.x = stage.stageWidth /2 - board.width/2;
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseEvent);
            stage.focus = board;
        }
        public function onMouseEvent(event:MouseEvent):void
        {
            board.x = event.localX - board.width/2;
            if(board.x <0)
                board.x = 0;
            if(board.x > stage.stageWidth - board.width)
                board.x = stage.stageWidth - board.width;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire