2011-09-22 27 views
0

有沒有辦法控制滾動窗格組件中的動畫片段的框架?可能控制滾動窗格組件中的MovieClip的框架?

在我的舞臺上,我有四個按鈕設置。

我有下面的動作,但得到一個錯誤。

import flash.events.MouseEvent; 

scrollPane.source = pm_mc; 
scrollPane.setSize(975, 500); 
scrollPane.scrollDrag = true; 

start_but.addEventListener(MouseEvent.CLICK, start); 
function start(e:MouseEvent):void 
{ 
    scrollPane.pm_mc.gotoAndStop(1); 
} 

previous_but.addEventListener(MouseEvent.CLICK, previous); 
function previous(e:MouseEvent):void 
{ 
    scrollPane.pm_mc.prevFrame(); 
} 

next_but.addEventListener(MouseEvent.CLICK, next); 
function next(e:MouseEvent):void 
{ 
    scrollPane.pm_mc.nextFrame(); 
} 

end_but.addEventListener(MouseEvent.CLICK, end); 
function end(e:MouseEvent):void 
{ 
    scrollPane.pm_mc.gotoAndStop(31); 
} 

stop(); 

我得到的錯誤都是一樣的:通過靜態類型fl.containers參考可能未定義的屬性pm_mc的 訪問:滾動窗格

我仍然非常學習AS3。

在此先感謝您的回覆。

回答

0

您需要參考的影片剪輯爲:

scrollPane.source.gotoAndStop(1); 

因此,在你的代碼:
更換scrollPane.pm_mcscrollPane.source

更新
我想我明白你現在要做的是什麼。你的庫中有一個符號(它不在你的舞臺上),你想創建它的一個實例並將它添加到scrollPane中。如果我是對的,試試這個。

import flash.events.MouseEvent; 

scrollPane.source = new pm_mc(); 
scrollPane.setSize(975, 500); 
scrollPane.scrollDrag = true; 

start_but.addEventListener(MouseEvent.CLICK, start); 
function start(e:MouseEvent):void 
{ 
    scrollPane.source.gotoAndStop(1); 
} 

previous_but.addEventListener(MouseEvent.CLICK, previous); 
function previous(e:MouseEvent):void 
{ 
    scrollPane.source.prevFrame(); 
} 

next_but.addEventListener(MouseEvent.CLICK, next); 
function next(e:MouseEvent):void 
{ 
    scrollPane.source.nextFrame(); 
} 

end_but.addEventListener(MouseEvent.CLICK, end); 
function end(e:MouseEvent):void 
{ 
    scrollPane.source.gotoAndStop(31); 
} 

stop(); 

請注意new pm_mc()。它創建一個庫符號的實例(一個MovieClip)。你

也可以指到滾動內容這樣

((MovieClip)(scrollPane.content)).nextFrame(); 

無論是contentsource應該爲你的目的工作。

+0

感謝您的答覆。 當我添加「...源」。我得到一個錯誤,說「nextFrame不是函數」或「prevFrame不是函數」等。 任何其他提示? – peeDee

+0

@peeDee我試過了,它正在工作。你確定pm_mc是一個MovieClip的實例嗎? – danishgoel

+0

Hi danishgoel - pm_mc正在從庫中導出到實例名稱爲pm_mc的AS中。 單擊其中一個按鈕時,輸出中的錯誤將彈出。如果這些按鈕完全重量的話,這些按鈕就是簡單的按鈕。 在點擊任何按鈕之前,一切正常。 – peeDee

0

由於您以錯誤的方式從scrollPane獲取影片剪輯,因此出現錯誤。檢查下面的代碼。

start_but.addEventListener(MouseEvent.CLICK, start); 
function start(e:MouseEvent):void 
{ 
    (Object(scrollPane.content)).gotoAndStop(1); 
} 

我希望它會工作...............

+0

這也適用。感謝您的迴應。 – peeDee

+0

你應該糾正我的答案。檢查我的回答時間。 – hardik

+0

我希望我可以選擇正確的答案,但它不會讓我。另一位用戶首先發布了一個答案,並花了大量時間糾正我。 – peeDee