2013-09-26 66 views
0

我是新的Flash和動作腳本。 這裏是問題所在。 我已經創建了一個簡單的應用程序。並增加了兩個項目的舞臺。一個影片剪輯對象和一個按鈕對象。影片剪輯對象具有設置爲在其上繪製的鼠標事件偵聽器。但是當我繪製時,線條繪製在影片剪輯對象後面(在舞臺上),我想繪製它在對象上。 這裏是我的代碼動作腳本3在電影剪輯前繪製?

var write: Boolean; 

write = false; 
board.addEventListener(MouseEvent.MOUSE_DOWN, startWriting); 
board.addEventListener(MouseEvent.MOUSE_MOVE, continueWriting); 
board.addEventListener(MouseEvent.MOUSE_UP, stopWriting); 
board.addEventListener(MouseEvent.MOUSE_OUT, stopWriting); 
btnHide.addEventListener(MouseEvent.MOUSE_DOWN, hideBoard); 

var g:Graphics = graphics; 
g.lineStyle(1, 0x0000ff); 

function startWriting(e:MouseEvent):void { 
    g.moveTo(mouseX, mouseY); 
    write = true; 
} 

function continueWriting(e:MouseEvent):void { 
    if(write) { 
     g.lineTo(mouseX, mouseY); 
    } 
} 

function stopWriting(e:MouseEvent):void { 
    write = false; 
} 

function hideBoard(e:MouseEvent):void { 
    if (board.visible){ 
     board.visible = false; 
    } 
    else { 
     board.visible = true; 
    } 
} 

所以,問題是我如何繪製影片剪輯對象上

回答

0

每個影片剪輯都有自己的圖形性能。您添加的內容始終位於當前動畫片段圖形的前面。

該解決方案只需添加一個形狀您的影片剪輯的孩子:

var shape : Shape = new Shape; 
addChild(shape); 
var g:Graphics = shape .graphics; 
g.lineStyle(1, 0x0000ff); 

function startWriting(e:MouseEvent):void { 
    g.moveTo(mouseX, mouseY); 
    write = true; 
} 

function continueWriting(e:MouseEvent):void { 
    if(write) { 
     g.lineTo(mouseX, mouseY); 
    } 
} 
相關問題