2011-04-16 38 views
1

我在一個按鈕內放置了一個影片剪輯實例,並且我想在釋放按鈕時播放此影片剪輯。我使用的是包含按鈕在框架上的代碼:通過一個可能未定義的屬性theMC的訪問:在按鈕實例內播放影片剪輯實例

function playMovie(event:MouseEvent) 
{ 
    this.theButton.theMC.gotoAndPlay(3); 
} 

theButton.addEventListener(MouseEvent.MOUSE_UP, playMovie); 

當我嘗試測試Flash影片,我得到這個消息:

1119引用靜態類型flash.display:SimpleButton。

我可以有點理解爲什麼它不喜歡它,但我不知道如何解決這個問題。

回答

0

如果你是theButton裏面已經那麼你就不需要調用「this.theButton」,因爲「theButton」是「這個」 嘗試

this.theMC.gotoAndPlay(3); 

,如果你仍然不確定對象的父子關係,並且您正在使用閃存IDE,在您的操作面板中,單擊操作面板頂部的藍色目標,找到您想要引用的MC,並讓閃存IDE找出您的關係。

0

在您的按鈕中給movieclip一個實例名稱「theMC」。然後使用以下代碼:

function playMovie(e:MouseEvent) 
{  
    this.theButton.getChildByName("theMC").gotoAndPlay(3); 

}// end function 

theButton.addEventListener(MouseEvent.MOUSE_UP, playMovie);