我试图使用Adobe Flash CS5.5开发课件。我的课件有几个教训,在各个闪存(瑞士法郎
)的文件制定每节课。我已经添加的下一步&放大器; previous 按钮加载下一个和previous教训。但是,这件事情如果我设置发布preVIEW 作为 HTML 只工作。这里是code我用:
I was trying to develop courseware using Adobe Flash CS5.5. My courseware has several lesson and each lesson developed in individual flash (.swf
) file. I've added Next & Previous button to load next and previous lesson. But, this thing only work if I set Publish Preview as HTML. Here is the code I've used:
function gotoChap1(event:MouseEvent):void {
navigateToURL(new URLRequest ("chap1.html"),("_self"));
}
chap1_btn.addEventListener(MouseEvent.CLICK , gotoChap1);
现在,我怎么可以加载瑞士法郎(或其它课程)文件,并单击下一步/ previous按钮时发布preVIEW 设置为闪存?我GOOGLE了它,但没有运气!谢谢!
now, how can I load .swf (or another lesson) file by clicking Next/Previous button when the Publish Preview is set to Flash? I googled it, but no luck! thank you!
您需要使用的,而不是在 navigateToURL 功能装载机。您可以创建一个主要电影加载每个外部SWF,并添加在主舞台时,下载完成。
You need to use a Loader instead of the navigateToURL function. You can create a Main movie to load each external swf and add in the main stage when the download complete.
使用下面的code自动化过程:
Use the following code to automate the process:
import flash.display.Loader;
import flash.events.Event;
import flash.events.MouseEvent;
// Vars
var currentMovieIndex:uint = 0;
var currentMovie:Loader;
// Put your movies here
var swfList:Array = ["swf1.swf", "swf2.swf", "swf3.swf"];
// Add the event listener to the next and previous button
previousButton.addEventListener(MouseEvent.CLICK, loadPrevious);
nextButton.addEventListener(MouseEvent.CLICK, loadNext);
// Loads a swf at secified index
function loadMovieAtIndex (index:uint) {
// Unloads the current movie if exist
if (currentMovie) {
removeChild(currentMovie);
currentMovie.unloadAndStop();
}
// Updates the index
currentMovieIndex = index;
// Creates the new loader
var loader:Loader = new Loader();
// Loads the external swf file
loader.load(new URLRequest(swfList[currentMovieIndex]));
// Save he movie reference
currentMovie = loader;
// Add on the stage
addChild(currentMovie);
}
// Handles the previous button click
function loadPrevious (event:MouseEvent) {
if (currentMovieIndex) { // Fix the limit
currentMovieIndex--; // Decrement by 1
loadMovieAtIndex(currentMovieIndex);
}
}
// Handles the next button click
function loadNext (event:MouseEvent) {
if (currentMovieIndex < swfList.length-1) { // Fix the limit
currentMovieIndex++; // Increment by 1
loadMovieAtIndex(currentMovieIndex);
}
}
// Load the movie at index 0 by default
loadMovieAtIndex(currentMovieIndex);
在这里下载中心的演示文件: http://cl.ly/Lxj3
上一篇:基于AD组成员资格限制访问一个WPF视图视图、组成员、资格、AD
下一篇:如何实现的StageVideo在Adobe AIR为Android?如何实现、StageVideo、Adobe、AIR