我正在尋找一種方法來調用在ActionScript 2.0中的不同框架中定義的函數。細節如下:如何使用ActionScript 2.0從不同的框架調用函數?
如在幀1中的按鈕事件,我有:
var vlist:XML = new XML(); //Creating an XML variable
vlist.ignoreWhite = true; //Ignoring the white spaces in the xml
vlist.load("videoList.xml"); //Loading a list of videos from the xml.
vlist.onLoad = function()
{
var videos:Array = this.firstChild.childNodes;
for (i = 0; i < videos.length; i++)
{
vidList.addItem({label:videos[i].attributes.desc, data:videos[i].attributes.url});
}
vid.load(vidList.getItemAt(0).data);
vidList.selectedIndex = 0;
//Notes:
//vid: is an instance of (FLVPlayback) component.
//vidList: is an instance of a (List) component.
};
function selectVideo(index:Number)
{
//Here is the function that i want to call from frame 1 but it is not getting called.
vidList.selectedIndex = index;
}
var listHandler:Object = new Object();
listHandler.change = function(evt:Object)
{
vid.load(vidList.getItemAt(vidList.selectedIndex).data);
};
vidList.addEventListener("change",listHandler);
:
on (release)
{
_root.gotoAndStop(2); //Going to Frame 2.
selectVideo(5); //Calling a function defined in Frame 2.
//Calling this function is not working in the way i wrote it above.
}
在第2幀,我已在該幀本身上下面的腳本
出於某種原因,第2幀上的代碼自行工作,但從另一個框架的列表中選擇索引不起作用。換句話說,我無法在第2幀中定義selectVideo()
,但在第2幀中定義它。
程序的目的,就像暗示的,指的是來自不同幀的列表中的某個視頻。整個代碼工作沒有錯誤,我只是無法從列表中選擇一個視頻,並播放它,如果它最初在不同的先前幀。
任何想法,建議或解決方案,高度讚賞! 在此先感謝您的幫助!
@Dairo編輯帖子時,請修正所有內容,而不只是一個錯字。 –