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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/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
Flex 3预加载程序与Flash 11/11.5一起死亡_Flash_Apache Flex_Flex3_Flash Builder_Flex4.5 - Fatal编程技术网

Flex 3预加载程序与Flash 11/11.5一起死亡

Flex 3预加载程序与Flash 11/11.5一起死亡,flash,apache-flex,flex3,flash-builder,flex4.5,Flash,Apache Flex,Flex3,Flash Builder,Flex4.5,我真的需要帮助,我已经处理这件事好几个月了。基本上,我有一个旧的Flex3应用程序和一个定制的预加载程序。一旦每个人都升级到Flash 11和11.5,预加载程序就消失了。我正试图让Flash Builder 4.7在3.6库中链接,但遗憾的是,它似乎悄悄地失败了。即使是标准预加载程序也与“加载0的库”相关联(不过它确实显示了)…我正在使用现在经典的“DownloadProgressBar”扩展自定义预加载程序模式 package com.timberdesignco.preloader {

我真的需要帮助,我已经处理这件事好几个月了。基本上,我有一个旧的Flex3应用程序和一个定制的预加载程序。一旦每个人都升级到Flash 11和11.5,预加载程序就消失了。我正试图让Flash Builder 4.7在3.6库中链接,但遗憾的是,它似乎悄悄地失败了。即使是标准预加载程序也与“加载0的库”相关联(不过它确实显示了)…我正在使用现在经典的“DownloadProgressBar”扩展自定义预加载程序模式

package com.timberdesignco.preloader
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    import mx.events.FlexEvent;
    import mx.preloaders.DownloadProgressBar;

    public final class CustomPreloader extends DownloadProgressBar {
        public  var loader : LoadScreen;
        private var _timer : Timer;

        public function CustomPreloader() 
        {
            super(); 
        }

        override public function initialize() : void
        {
            super.initialize();

            this.loader = new LoadScreen();
            this.addChild(this.loader);

            this._timer = new Timer(10);
            this._timer.addEventListener(TimerEvent.TIMER, handleTimerTick);
            this._timer.start();
        }

        override public function set preloader(preloader : Sprite):void 
        {                   
            preloader.addEventListener(ProgressEvent.PROGRESS,  SWFDownLoadScreen);
            preloader.addEventListener(Event.COMPLETE,          SWFDownloadComplete);
            preloader.addEventListener(FlexEvent.INIT_PROGRESS, FlexInitProgress);
            preloader.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete);
        }

        private function SWFDownLoadScreen(event : ProgressEvent) : void
        {
            var prog : Number = event.bytesLoaded / event.bytesTotal * 100;
            if (this.loader)
            {
                this.loader.progress = prog;
            }
        }

        private function handleTimerTick(event : TimerEvent) : void
        {
            this.stage.addChild(this);
            this.loader.x = (this.stage.stageWidth  - this.loader.width)  / 2 - 35;
            this.loader.y = (this.stage.stageHeight - this.loader.height) / 2;
            this.loader.refresh();
        }

        private function SWFDownloadComplete(event : Event) : void {}

        private function FlexInitProgress(event : Event) : void {}

        private function FlexInitComplete(event : Event) : void 
        {      
            this.loader.ready = true;
            this._timer.stop();
            this.dispatchEvent(new Event(Event.COMPLETE));
        }

        override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean
        {
            return true;
        }

        override protected function showDisplayForDownloading(elapsedTime:int,
                                                  event:ProgressEvent):Boolean
        {
            return true;
        }
    }
}


所以我得到了你的预加载程序的简化版本

这是我的密码。然后我们可以讨论哪些部分应该用另一种方式完成(如果有的话)

//应用

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute" minWidth="955" 
minHeight="600" 
preloader="com.timberdesignco.preloader.CustomPreloader">

<mx:Script>
    <![CDATA[
        [Embed("/assets/bmw.png") ]
        [Bindable] public var Office:Class;
    ]]>
</mx:Script>

<mx:Image source="{Office}" horizontalCenter="0" verticalCenter="0"/>

</mx:Application>
//LoadScreenV2

package com.timberdesignco.preloader
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;

import mx.preloaders.IPreloaderDisplay;

public class LoadScreenV2 extends Sprite
{
    private var _progress:Number;
    private var g : Graphics;

    private var startX:Number;
    private var endX:Number;
    private var startY:Number; 
    private var endY:Number;

    private var text:TextField;

    [Embed(source="/assets/Pahuenga.otf", fontFamily="Pahuenga")]
    private var CreightonEmbedded:Class;
    private var creightonEmbeddedFont:Font = new CreightonEmbedded();

    [Embed(source="/assets/LoadingBar-Bark.png")]
    private var MyLogoClass: Class;

    public function LoadScreenV2()
    {
        super();

        init();
    }

    public function get progress():Number
    {
        return _progress;
    }

    public function set progress(value:Number):void
    {
        _progress = value;

        refresh();
    }

    private function init():void
    {
        g = this.graphics;

        startX = this.width / 2 + 5;
        endX = startX + 50;
        startY = (this.height / 2); 
        endY = 50;

        var textFormat:TextFormat = new TextFormat();
        textFormat.color = 0xa1865e;
        textFormat.font = creightonEmbeddedFont.fontName;
        textFormat.size = 14;
        textFormat.letterSpacing = 2;

        text = new TextField();
        text.defaultTextFormat = textFormat;
        text.embedFonts = true;

        text.x = endX + 28;
        text.y = endY - 14;
        text.textColor = 0xa1865e;
        text.width = 100;
        text.height = 20;
        addChild(text);
    }

    override public function get width() : Number 
    {
        return 300;
    }

    override public function get height() : Number 
    {
        return 300;
    }

    public function refresh():void
    {
        g.clear();
        draw();
    }

    protected function draw():void
    {
        g.lineStyle(2, 0xa1865e);

        for(var i:int = this.progress; i > 0; i--) {
            g.drawCircle(this.width / 2 + 5, this.height / 2, (5 * (int)(i  / 10) + 1));
        } 

        g.moveTo(startX, startY);
        g.lineTo(endX, endY);
        g.lineTo(endX + 20, endY);

        text.text = Math.ceil(progress) + "%";
    }


}
}

嗨,我试着理解你的问题,如果它仍然是真实的。您能告诉我为什么使用Loader作为LoadScreen的基类吗?在这种情况下,LoadScreen的用途是什么?我已经更正了您的代码,并得到以下结果。这是你的目标吗?是的,这正是我需要的。你介意分享固定代码吗?好的,我当然会。我只是想知道这是你想要的。
package com.timberdesignco.preloader
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.core.Application;
import mx.events.FlexEvent;
import mx.preloaders.DownloadProgressBar;

public final class CustomPreloader extends DownloadProgressBar 
{
    public  var loader : LoadScreenV2;
    private var _timer : Timer;

    public function CustomPreloader() 
    {
        super(); 
    }

    override public function initialize() : void
    {
        super.initialize();

        loader = new LoadScreenV2();
        this.addChild(this.loader);

        loader.x = (this.stage.stageWidth  - this.loader.width)  / 2 - 35;
        loader.y = (this.stage.stageHeight - this.loader.height) / 2;

        this._timer = new Timer(10);
        this._timer.addEventListener(TimerEvent.TIMER, handleTimerTick);
        this._timer.start();
    }

    override public function set preloader(preloader : Sprite):void 
    {                   
        preloader.addEventListener(ProgressEvent.PROGRESS,  SWFDownLoadScreen);
        preloader.addEventListener(Event.COMPLETE,          SWFDownloadComplete);
        preloader.addEventListener(FlexEvent.INIT_PROGRESS, FlexInitProgress);
        preloader.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete);
    }

    private function SWFDownLoadScreen(event : ProgressEvent) : void
    {
        var prog : Number = event.bytesLoaded / event.bytesTotal * 100;

        if (this.loader)
        {
            this.loader.progress = prog;
        }
    }

    private function handleTimerTick(event : TimerEvent) : void
    {
        this.loader.refresh();
    }

    private function SWFDownloadComplete(event : Event) : void 
    {
    }

    private function FlexInitProgress(event : Event) : void {}

    private function FlexInitComplete(event : Event) : void 
    {      
        this._timer.stop();
        this.dispatchEvent(new Event(Event.COMPLETE));
    }

    override protected function showDisplayForInit(elapsedTime:int, count:int):Boolean
    {
        return true;
    }

    override protected function showDisplayForDownloading(elapsedTime:int, event:ProgressEvent):Boolean
    {
        return true;
    }
}
}
package com.timberdesignco.preloader
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;

import mx.preloaders.IPreloaderDisplay;

public class LoadScreenV2 extends Sprite
{
    private var _progress:Number;
    private var g : Graphics;

    private var startX:Number;
    private var endX:Number;
    private var startY:Number; 
    private var endY:Number;

    private var text:TextField;

    [Embed(source="/assets/Pahuenga.otf", fontFamily="Pahuenga")]
    private var CreightonEmbedded:Class;
    private var creightonEmbeddedFont:Font = new CreightonEmbedded();

    [Embed(source="/assets/LoadingBar-Bark.png")]
    private var MyLogoClass: Class;

    public function LoadScreenV2()
    {
        super();

        init();
    }

    public function get progress():Number
    {
        return _progress;
    }

    public function set progress(value:Number):void
    {
        _progress = value;

        refresh();
    }

    private function init():void
    {
        g = this.graphics;

        startX = this.width / 2 + 5;
        endX = startX + 50;
        startY = (this.height / 2); 
        endY = 50;

        var textFormat:TextFormat = new TextFormat();
        textFormat.color = 0xa1865e;
        textFormat.font = creightonEmbeddedFont.fontName;
        textFormat.size = 14;
        textFormat.letterSpacing = 2;

        text = new TextField();
        text.defaultTextFormat = textFormat;
        text.embedFonts = true;

        text.x = endX + 28;
        text.y = endY - 14;
        text.textColor = 0xa1865e;
        text.width = 100;
        text.height = 20;
        addChild(text);
    }

    override public function get width() : Number 
    {
        return 300;
    }

    override public function get height() : Number 
    {
        return 300;
    }

    public function refresh():void
    {
        g.clear();
        draw();
    }

    protected function draw():void
    {
        g.lineStyle(2, 0xa1865e);

        for(var i:int = this.progress; i > 0; i--) {
            g.drawCircle(this.width / 2 + 5, this.height / 2, (5 * (int)(i  / 10) + 1));
        } 

        g.moveTo(startX, startY);
        g.lineTo(endX, endY);
        g.lineTo(endX + 20, endY);

        text.text = Math.ceil(progress) + "%";
    }


}
}