Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.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 如果加载了内容,Flash AS2预加载程序仍将运行_Actionscript 3_Flash_Actionscript_Actionscript 2 - Fatal编程技术网

Actionscript 3 如果加载了内容,Flash AS2预加载程序仍将运行

Actionscript 3 如果加载了内容,Flash AS2预加载程序仍将运行,actionscript-3,flash,actionscript,actionscript-2,Actionscript 3,Flash,Actionscript,Actionscript 2,通常情况下,我的预加载程序为20帧,如下所示: 第1帧动作脚本: var amountLoaded:Number = _root.getBytesLoaded()/_root.getBytesTotal(); preloader._width = amountLoaded * 200; loadText.text = Math.round(amountLoaded * 100) + "%"; if(_root.getBytesLoaded() == _root.getBytesTotal())

通常情况下,我的预加载程序为20帧,如下所示:

第1帧动作脚本:

var amountLoaded:Number = _root.getBytesLoaded()/_root.getBytesTotal();
preloader._width = amountLoaded * 200;
loadText.text = Math.round(amountLoaded * 100) + "%";

if(_root.getBytesLoaded() == _root.getBytesTotal())  {
     gotoAndPlay(21);
}

else {
     gotoAndPlay(1);
}
在第20帧中,我们显然有:

this.gotoAndPlay(1);
这很好,但它只在主页上播放,我想播放flash的简介。因此,我在主页以外的每一页上使用FlashVar来告诉动画应该跳到哪里

为此,我将其放置在预加载程序后的第一帧上:

gotoAndPlay(AdFrame);
在除主页外的每个页面中,我都添加了以下Flash变量:

<param name="FlashVars" value="AdFrame=39" />
但它仍然不能绕过预加载程序


如果内容已加载,如何完全跳过预加载程序?

如果我理解正确,由于在第一帧上,即使从浏览器缓存加载SWF,由
getBytesLoaded
getByTestTotal
方法返回的值也不相同,因此您的条件的计算结果不会为true

如果是这种情况,您可以尝试在检查负载状态之前等待。只需将代码移到第2帧,并将预加载动画的开始移到第3帧就足够了。(我已经很久没有使用时间线了,但我似乎记得等待帧通常是一个很好的经验法则)

或者,在执行检查之前,您可以在第一帧上暂停一小段时间:

stop();

var interval = setInterval(function() {

    clearInterval(interval);

    var amountLoaded:Number = _root.getBytesLoaded()/_root.getBytesTotal();
    preloader._width = amountLoaded * 200;
    loadText.text = Math.round(amountLoaded * 100) + "%";

    if(_root.getBytesLoaded() == _root.getBytesTotal())  {
         gotoAndStop(3);
    }

    else {
         gotoAndStop(2);
    }
}, 500); 

您可以随意调整间隔时间(半秒可能过多)。请注意,每次播放头返回到第一帧时都会执行间隔,这取决于间隔的长度,可能不是问题。如果这是一个问题,您可以考虑在第一次执行间隔时设置布尔标志,这样您就可以避免在后续循环中再次执行布尔标记。p> 你的脚本中有
enterFrame
吗。你知道这是否有用吗?@mgraph 1)试试
gotoAndStop
where?关于我失败的尝试,第一个IF语句?如果是这样的话,那就没有意义了,因为在我失败的尝试中,条件将转到“else”。2) 添加
stop()到整个动画的最后一个关键帧还是到预加载程序的最后一个关键帧?两者都没有意义。问题是代码:
preload.\u width=amountload*200;loadText.text=Math.round(amountLoaded*100)+“%”无法正确构成已加载(缓存)的内容。我不知道我还能用什么,但如果能在这里添加一行关于“如果缓存”的话,那就太好了!(你知道吗?)你说的“它不会绕过预载器”是什么意思?你的意思是它在帧进展前100%短暂可见吗?
stop();

var interval = setInterval(function() {

    clearInterval(interval);

    var amountLoaded:Number = _root.getBytesLoaded()/_root.getBytesTotal();
    preloader._width = amountLoaded * 200;
    loadText.text = Math.round(amountLoaded * 100) + "%";

    if(_root.getBytesLoaded() == _root.getBytesTotal())  {
         gotoAndStop(3);
    }

    else {
         gotoAndStop(2);
    }
}, 500);