Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3外部预加载程序在Flash CS5中工作,但不在浏览器(chrome、Ff或IE)中工作-保持100%_Actionscript 3_Flash_External_Preloader - Fatal编程技术网

Actionscript 3 AS3外部预加载程序在Flash CS5中工作,但不在浏览器(chrome、Ff或IE)中工作-保持100%

Actionscript 3 AS3外部预加载程序在Flash CS5中工作,但不在浏览器(chrome、Ff或IE)中工作-保持100%,actionscript-3,flash,external,preloader,Actionscript 3,Flash,External,Preloader,我已经看到一些问题已经解决了,但是没有一个是针对我正在使用的代码的,所以我想知道是否有人可以帮助我 我正在使用外部预加载程序loader.swf加载电影ayproj.swf。当在flash player中运行.swf文件和在flash cs5中模拟下载时,预加载程序工作正常,但当我将其上载到internet并打开index.html(其中flash处于100%帧中)时,预加载程序会在100%Ff和IE上粘贴,或者只在动态百分比文本框中显示pl chrome(初始文本) 预加载程序的代码为: st

我已经看到一些问题已经解决了,但是没有一个是针对我正在使用的代码的,所以我想知道是否有人可以帮助我

我正在使用外部预加载程序loader.swf加载电影ayproj.swf。当在flash player中运行.swf文件和在flash cs5中模拟下载时,预加载程序工作正常,但当我将其上载到internet并打开index.html(其中flash处于100%帧中)时,预加载程序会在100%Ff和IE上粘贴,或者只在动态百分比文本框中显示pl chrome(初始文本)

预加载程序的代码为:

stop();

import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import com.greensock.TweenNano;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, onStageResize);
addEventListener(Event.ENTER_FRAME, onFrame);

var barcomp:Number = stage.stageWidth;
percentContainer.x = stage.stageWidth/2 - percentContainer.width/2;
percentContainer.y = stage.stageHeight/2 - percentContainer.height/2;

function onStageResize(evt:Event):void {

    bar_mc.x = 0;
    bar_mc.y = (stage.stageHeight) - 3;
    bar_mc.height = 20;
    barcomp = stage.stageWidth;

    percentContainer.x = stage.stageWidth/2 - percentContainer.width/2;
    percentContainer.y = stage.stageHeight/2 - percentContainer.height/2;

}



function onFrame(evt:Event):void {

    bar_mc.x = 0;
    bar_mc.y = (stage.stageHeight) - 3;
    bar_mc.height = 20;
    barcomp = stage.stageWidth;

    percentContainer.x = stage.stageWidth/2 - percentContainer.width/2;
    percentContainer.y = stage.stageHeight/2 - percentContainer.height/2;   
}

var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
loader.load(new URLRequest("ayproj.swf"));
loader.visible = false;

function loop(e:ProgressEvent):void {

    var perc:Number = e.bytesLoaded / e.bytesTotal;
    var s:String = Math.ceil(perc*100).toString()+"%";
    percentContainer.percent.text = s
    bar_mc.width = perc * barcomp;
}

function done(e:Event):void { 

    removeChildAt(getChildIndex(percentContainer)); 
    removeChildAt(getChildIndex(bar_mc));

    percentContainer.percent = null; 

    stage.addChild(loader);

    TweenNano.delayedCall(0.5, fadeInAyproj);
}

function fadeInAyproj():void {

    loader.visible = true;
    TweenNano.to(loader, 0.8, {alpha:0});
    TweenNano.from(loader, 0.8, {alpha:0});
}

如果有人能帮忙,我将不胜感激

您还必须检查ProgressEvent处理程序中是否100%加载。完整事件有时不会触发

function loop(e:ProgressEvent):void {

    var perc:Number = e.bytesLoaded / e.bytesTotal;
    if (perc >= 100) done (e);

//...more code
}

另外,请确保ayproj.swf与index.html位于同一文件夹中,或者使请求url相对于index.html的路径

也许不是你的Flash代码,而是嵌入。你能把你的Html代码放在这里吗?是的,我发现我的预加载程序swf文件中的ayproj.swf应该是flash/ayproj.swf,这是它在网站上的位置。它也可以在没有上述代码的情况下工作。谢谢你的帮助:D