对不起,如果这已经在其他地方得到解答,但我找不到任何匹配的内容。
我有两个swfs;预加载器(让我们称之为A)和一些内容(B)。加载B并将其作为孩子添加。一切都很美好(你甚至可以看到here)。
我只有一个小问题。通常在使用URLLoader类加载(例如图像)到flash时,我将+ "?" + new Date().getTime()
添加到URLRequest以强制flash加载目标的最新版本,换句话说,使用缓存版本来停止它。现在,当我尝试将B添加到A的Loader时,它找不到URL(#2035 URL not found
)。所以我的问题是:我正在尝试做什么,或者我应该采取另一种方法来阻止B缓存?
这是预加载器代码:
package
{
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.net.URLLoader;
import flash.text.TextField;
public class claude_loader extends MovieClip
{
public var main_movie:Loader = new Loader();
public var rss_loader:URLLoader;
private var perc_text:TextField = new TextField();
public function claude_loader()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
with (perc_text)
{
x = this.stage.stageWidth / 2;
y = this.stage.stageHeight / 2;
}
addChild(perc_text);
main_movie.load(new URLRequest("claudia_summers.swf"+ "?" + new Date().getTime()));
main_movie.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, load_progress);
main_movie.contentLoaderInfo.addEventListener(Event.COMPLETE,on_complete);
}
public function load_progress(e:ProgressEvent):void
{
var perc:Number = Math.round((e.bytesLoaded/e.bytesTotal)*100);
perc_text.text = "Loading " + perc + "%";
if (e.bytesLoaded == e.bytesTotal)
{
perc_text.text = "Loading done";
}
}
public function on_complete(e:Event):void
{
rss_loader = new URLLoader(new URLRequest("http://news.sulsc.org/feed"));
rss_loader.addEventListener(Event.COMPLETE,rss_complete);
perc_text.text = "Loading RSS";
}
public function rss_complete(e:Event):void
{
MovieClip(main_movie.content).rss_xml = XML(e.target.data);
addChild(main_movie);
}
}
}
答案 0 :(得分:0)
不确定如何/为什么,但在String()
周围添加new Date().getTime()
并为main_movie提供IOErrorEvent
侦听器可以解决问题。我想我在某个地方有一个错误,因为这肯定应该没有这些添加,但不是吗?无论如何感谢为你提供所有帮助!
工作代码:
package
{
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.net.URLLoader;
import flash.text.TextField;
import flash.events.IOErrorEvent;
public class claude_loader extends MovieClip
{
public var main_movie:Loader = new Loader();
public var rss_loader:URLLoader;
private var perc_text:TextField = new TextField();
public function claude_loader()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
with (perc_text)
{
x = this.stage.stageWidth / 2;
y = this.stage.stageHeight / 2;
textColor = 0xFFFFFF;
}
addChild(perc_text);
main_movie.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,catch_error);
main_movie.load(new URLRequest("claudia_summers.swf" + "?" + String(new Date().getTime())));
function catch_error(e:IOErrorEvent):void
{
main_movie.load(new URLRequest("claudia_summers.swf"));
perc_text.text = "Failed non-cache load"
}
main_movie.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, load_progress);
main_movie.contentLoaderInfo.addEventListener(Event.COMPLETE,on_complete);
}
public function load_progress(e:ProgressEvent):void
{
var perc:Number = Math.round((e.bytesLoaded/e.bytesTotal)*100);
perc_text.text = "Loading " + perc + "%";
if (e.bytesLoaded == e.bytesTotal)
{
perc_text.text = "Loading done";
}
}
public function on_complete(e:Event):void
{
rss_loader = new URLLoader(new URLRequest("http://news.sulsc.org/feed"));
rss_loader.addEventListener(Event.COMPLETE,rss_complete);
perc_text.text = "Loading RSS";
}
public function rss_complete(e:Event):void
{
MovieClip(main_movie.content).rss_xml = XML(e.target.data);
addChild(main_movie);
}
}
}