控制主 Swf 内的外部 Swf(场景、帧)
我要创建一个百科全书程序,包含许多章节。我在控制主 swf 内的外部 swf 方面遇到困难。这是我在 Actionscript 3
public class utama extends MovieClip {
var loader:Loader;
var urlReq:URLRequest;
public function utama() {
hal1.visible=true;
hal2.visible=true;
hal1.addEventListener(MouseEvent.CLICK, keHal1);
home.addEventListener(MouseEvent.CLICK, backHome);
sebelum.addEventListener(MouseEvent.CLICK, prevPage);
sesudah.addEventListener(MouseEvent.CLICK, nextPage);
}
function prevPage(e:MouseEvent):void {
//this is were I controlled the Prev page
trace(parent.numChildren);
}
function nextPage(e:MouseEvent):void {
//this is were I controlled the Next page
}
function backHome(e:MouseEvent):void {
//If home button clicked then goes here
parent.removeChild(loader);
hal1.visible=true;
hal2.visible=true;
}
function keHal1(e:MouseEvent):void {
//this is were I Load Page 1
var url:String="./hal1.swf";
urlReq=new URLRequest(url);
loader=new Loader();
loader.load(urlReq);
parent.addChild(loader);
hal1.visible=false;
hal2.visible=false;
}
}
Am 中的 Main.as,使用 eksternal 页面作为章节,并且章节由许多页面组成(它使用场景) 例如:
第 1 章 -->第 1 页将表示为 hal1.swf-->Scene 1 第1章-->第2页它将被表示为hal1.swf-->场景2
现在,如何控制它,我还是不明白?
Am gonna create an encyclopedia program, consist many of Chapter. I have difficulties about controlling external swf inside my Main swf. This is my Main.as in Actionscript 3
public class utama extends MovieClip {
var loader:Loader;
var urlReq:URLRequest;
public function utama() {
hal1.visible=true;
hal2.visible=true;
hal1.addEventListener(MouseEvent.CLICK, keHal1);
home.addEventListener(MouseEvent.CLICK, backHome);
sebelum.addEventListener(MouseEvent.CLICK, prevPage);
sesudah.addEventListener(MouseEvent.CLICK, nextPage);
}
function prevPage(e:MouseEvent):void {
//this is were I controlled the Prev page
trace(parent.numChildren);
}
function nextPage(e:MouseEvent):void {
//this is were I controlled the Next page
}
function backHome(e:MouseEvent):void {
//If home button clicked then goes here
parent.removeChild(loader);
hal1.visible=true;
hal2.visible=true;
}
function keHal1(e:MouseEvent):void {
//this is were I Load Page 1
var url:String="./hal1.swf";
urlReq=new URLRequest(url);
loader=new Loader();
loader.load(urlReq);
parent.addChild(loader);
hal1.visible=false;
hal2.visible=false;
}
}
Am using eksternal page as a Chapter, and A Chapter consist of many Pages (it using Scene)
For an example :
Chapter 1 --> Page 1 it will be represented as hal1.swf-->Scene 1
Chapter 1 --> Page 2 it will be represented as hal1.swf-->Scene 2
Now, How to control it, I still didn't get it ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加载后检查swf的类型。如果是MovieClip,您可以从中调用gotoAndStop(frameNumber)来设置当前帧。如果它是AVM1Movie,它就是AS2 swf,你无法控制它。
Check the type of swf after loading. If it is MovieClip, you can call gotoAndStop(frameNumber) from it to set current frame. If it is AVM1Movie, it is AS2 swf and you cannot control it.