webstudio Forums

webstudio Forums (http://www.webstudio.com.cn/forum/index.php)
-   flash网站建设技术精粹 (http://www.webstudio.com.cn/forum/forumdisplay.php?f=26)
-   -   【求助】问下关于ActionScript问题,为什么我改变窗口大小,Loading就会失效? (http://www.webstudio.com.cn/forum/showthread.php?t=3355)

happyzqg 2009-03-08 12:46 AM

【求助】问下关于ActionScript问题,为什么我改变窗口大小,Loading就会失效?
 
我刚学制作Flash全站,遇到个问题...本来这个站我设置了窗口自适应的,代码如下

Stage.scaleMode = "noScale";
Stage.align="TL";

var a:Object = new Object();
a.onResize = function(){
onEnterFrame = function(){
//bg是一个背景MC
bg._width = Stage.width;
bg._height = Stage.height;
}
}
Stage.addListener(a);

这样我的bg就可以跟窗口大小改变.之后我做了loading, loading是再库中设置链接后,用attachMovie方式加到场景中.当打开首页就会自动加载根目录名为newsupdate.swf文件到主场景的content_mc里的contentHolder元件里面!
问题来了,当我按2下Ctrl+Enter测试影片加载时,加载是成功的,loading条会跟着百分比走.但是只要我改变测试影片的窗口大小(这个时候窗口自适应),loading条百分比就会马上停止走到?也不再加载!请问这种问题怎么解决?我不想去掉窗口自适应(急)


loading的代码跟书中第五章有效的预载的案例实做一样


//loading主场景中的内容
// 停止显示loading bar.
attachMovie("loading","loading_mc",this.getNextHighestDepth(),{_x:Stage.width/2, _y:Stage.height/2});
loading_mc._visible = false;
//设定onEnterFrame循环事件,以便对下面的内容的进行不断的检测
onEnterFrame = function(){
//计算载入的百分比
var percent_loaded = _root.getBytesLoaded()/_root.getBytesTotal();
//将percent_loaded值赋予loading_mc的 b 变量,这样就可以与loading条的_xscale相关联了。
loading_mc.b = percent_loaded;
if( percent_loaded == 1 ){
// 删除onEnterFrame事件
delete onEnterFrame
loading_mc.removeMovieClip();
// 通知主帧播放
gotoAndStop(3);
}
};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//为载入外部内容准备loading
function startPreload(url){
attachMovie("loading","loading_mc",this.getNextHighestDepth(),{_x:Stage.width/2, _y:Stage.height/2});
//preloader_mc._visible = false;
content_mc.contentHolder.loadMovie(url);

onEnterFrame = preloadContent;

}

function preloadContent(){
//定义对象的bytes_loaded和bytes_total
var bytes_loaded = this.content_mc.contentHolder.getBytesLoaded();
var bytes_total = this.content_mc.contentHolder.getBytesTotal();
//如果子bytes_total 有效且大于0
if( bytes_total > 0 ){
var percent_loaded = bytes_loaded/bytes_total;
//将percent_loaded值传给b;
loading_mc.b = percent_loaded;
//控制content_mc.contentHolder的状态
content_mc.contentHolder.stop();
content_mc.contentHolder._visible = false;
//如果载入完成
if( percent_loaded == 1 ){
//控制content_mc.contentHolder的状态
content_mc.contentHolder.play();
content_mc.contentHolder._visible = true;
loading_mc.removeMovieClip();
delete onEnterFrame;
}
}
}


content_mc里的最后一帧里有自动加载跟目录下的newsupdate.swf文件到contentHolder里

_root.startPreload("newsupdate.swf");


所有时间均为格林尼治时间 +9。现在的时间是 07:37 PM

Powered by vBulletin® 版本 3.8.3
版权所有 ©2000 - 2020,Jelsoft Enterprises Ltd.
增强包 [3.4] 制作: PHP源动力   官方中文站: vBulletin 中文
copyright by webstudio.com.cn. All Rights Reserved.