Apache flex Flex 4自定义预加载程序不工作
我按照此帮助页面创建自定义预加载程序扩展精灵以加载动画SWF,但它不工作(动画SWF未显示): 69084-7e3c.html#WS2DB45490E96A9E51E63E3D11C0BF62D75-7feb 我知道Animation.swf文件没有问题,因为如果我将其加载到主应用程序中,它会显示并运行 如果图像由预加载程序而不是动画SWF加载,则预加载程序将工作 ---------------------test.mxml(主应用程序)----------------- 顺便说一句,我通常在应用程序中有更多的ComboBox行来强制预加载程序显示,但这里限制了行数 ---------custompreload.SparkAnimationProgressBar.as---------------- 包预加载程序 { 导入flash.display。; 导入flash.events。; 导入flash.net。; 导入flash.utils }Apache flex Flex 4自定义预加载程序不工作,apache-flex,flex4,Apache Flex,Flex4,我按照此帮助页面创建自定义预加载程序扩展精灵以加载动画SWF,但它不工作(动画SWF未显示): 69084-7e3c.html#WS2DB45490E96A9E51E63E3D11C0BF62D75-7feb 我知道Animation.swf文件没有问题,因为如果我将其加载到主应用程序中,它会显示并运行 如果图像由预加载程序而不是动画SWF加载,则预加载程序将工作 ---------------------test.mxml(主应用程序)----------------- 顺便说一句,我通常在应
}我记得对自定义预加载程序有严格的限制。 它(assets/Animation.swf)应该是100张幻灯片的Flash动画。
这可能就是原因。尝试在加载程序上侦听Event.INIT而不是Event.COMPLETE(如果动画中有任何actionscript)。对于预加载程序,我不会在运行时加载动画,而是使用嵌入标记嵌入动画,在库中指定动画的符号。让主swf专注于加载自身。
import mx.events.*;
import mx.preloaders.*;
public class SparkAnimationProgressBar extends Sprite
implements IPreloaderDisplay{
// Loader instance to load the animation SWF file.
private var animationLdr:flash.display.Loader;
public function SparkAnimationProgressBar() {
super();
}
// Add event listeners.
public function set preloader(preloader:Sprite):void {
preloader.addEventListener(
ProgressEvent.PROGRESS, handleProgress);
preloader.addEventListener(
Event.COMPLETE, handleComplete);
preloader.addEventListener(
FlexEvent.INIT_PROGRESS, handleInitProgress);
preloader.addEventListener(
FlexEvent.INIT_COMPLETE, handleInitComplete);
}
// Initialize the Loader control in the override
// of IPreloaderDisplay.initialize().
public function initialize():void {
animationLdr = new flash.display.Loader();
animationLdr.contentLoaderInfo.addEventListener(
Event.COMPLETE, loader_completeHandler);
animationLdr.load(new URLRequest("assets/Animation.swf"));
}
// After the SWF file loads, set the size of the Loader control.
private function loader_completeHandler(event:Event):void
{
addChild(animationLdr);
animationLdr.width = 200;
animationLdr.height= 200;
animationLdr.x = 100;
animationLdr.y = 100;
}
// Define empty event listeners.
private function handleProgress(event:ProgressEvent):void {}
private function handleComplete(event:Event):void {}
private function handleInitProgress(event:Event):void {}
private function handleInitComplete(event:Event):void {
var timer:Timer = new Timer(2000,1);
timer.addEventListener(TimerEvent.TIMER, dispatchComplete);
timer.start();
}
private function dispatchComplete(event:TimerEvent):void {
dispatchEvent(new Event(Event.COMPLETE));
}
// IPreloaderDisplay interface methods.
public function get backgroundColor():uint {
return 0;
}
public function set backgroundColor(value:uint):void {}
public function get backgroundAlpha():Number {
return 0;
}
public function set backgroundAlpha(value:Number):void {}
public function get backgroundImage():Object {
return undefined;
}
public function set backgroundImage(value:Object):void {}
public function get backgroundSize():String {
return "";
}
public function set backgroundSize(value:String):void {}
public function get stageWidth():Number {
return 200;
}
public function set stageWidth(value:Number):void {}
public function get stageHeight():Number {
return 200;
}
public function set stageHeight(value:Number):void {}