Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

punkyep

problema em loader

Recommended Posts

o código é o seguinte:

package Loader_fla{
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.system.ApplicationDomain;
    import flash.net.URLVariables;
    import flash.events.Event;
    import flash.display.Loader;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
    import flash.system.LoaderContext;
    import flash.events.ProgressEvent;
    import flash.system.Security;
    import flash.events.*;
    import flash.display.*;
    import flash.net.*;
    import flash.system.*;
    import adobe.utils.*;
    import flash.accessibility.*;
    import flash.errors.*;
    import flash.external.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.media.*;
    import flash.printing.*;
    import flash.profiler.*;
    import flash.sampler.*;
    import flash.text.*;
    import flash.ui.*;
    import flash.utils.*;
    import flash.xml.*;

    public dynamic class MainTimeline extends MovieClip {
	
        public var mcLoading:MovieClip;
        public var sFile;
        public var sTitle;
        public var sBG:String;
        public var sURL:String;
        public var versionURL:String;
        public var loader:URLLoader;
        public var titleDomain:ApplicationDomain;
		public var loadBar:MovieClip;
		public var bg:MovieClip;
		
        public function MainTimeline(){
            addFrameScript(0, frame1);
        }
		
		public function fl_FadeSymbolIn(_arg1:Event){
            this.bg.alpha = (this.bg.alpha + 0.004);
            if (this.bg.alpha >= 0.120)
            {
                this.bg.removeEventListener(Event.ENTER_FRAME, this.fl_FadeSymbolIn);
            };
        }
		
		public function fl_FadeSymbolIn_2(_arg1:Event){
            this.mcLoading.alpha = (this.mcLoading.alpha + 0.020);
            if (this.mcLoading.alpha >= 1)
            {
                this.mcLoading.removeEventListener(Event.ENTER_FRAME, this.fl_FadeSymbolIn_2);
            };
        }
		
		public function FadeOutX_Tick(_arg1:TimerEvent){
            this.mcLoading.alpha = (this.mcLoading.alpha - 0.1);
            this.bg.alpha = (this.bg.alpha - 0.1);
            
        }
		
		public function FadeOutX_Complete(_arg1:TimerEvent){
            this.bg.visible = false;
            this.mcLoading.visible = false;
			this.FadeOutX.stop();
        }

        public function onDataComplete(evt:Event):void{
            trace(("onDataComplete:" + evt.target.data));
            var vars:URLVariables = new URLVariables(evt.target.data);
            if (vars.status == "success")
            {
                sFile = vars.sFile;
                sTitle = vars.sTitle;
                sBG = vars.sBG;
                loadTitle();
                loadGame();
            }
            else
            {
                trace(vars.strReason);
            };
        }

        public function loadTitle():void{
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onTitleComplete);
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
            loader.load(new URLRequest(((sURL + "gamefiles/title/") + sBG)), new LoaderContext(false, titleDomain));
        }

        public function onTitleComplete(e:Event):void{
            trace("Title Loaded");
        }

        public function loadGame():void{
		    mcLoading.strLoad.text = "Carregando ..";
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
            loader.load(new URLRequest(((sURL + "gamefiles/") + sFile)));
            
        }

        public function onProgress(evt:ProgressEvent){
		   var _local2:* = (evt.bytesLoaded / evt.bytesTotal);
            this.loadBar.scaleX = _local2;
            mcLoading.strLoad.text = (("Carregando " + Math.round((_local2 * 100)).toString()) + "%");
			//mcLoading.strLoad.text = ("Carregando " + (_local2 * 100) + "%");
		
          //  var percent:int = ((evt.currentTarget.bytesLoaded / evt.currentTarget.bytesTotal) * 100);
           // mcLoading.strLoad.text = (("Carregando " + percent) + "%");
        }
		
		
		public function onComplete(e:Event):void{
            var v:*;
            var stg:* = stage;
            stg.removeChildAt(0);
            var game:* = stg.addChild(MovieClip(Loader(e.target.loader).content));
            for (v in root.loaderInfo.parameters)
            {
                trace(((v + ": ") + root.loaderInfo.parameters[v]));
                game.params[v] = root.loaderInfo.parameters[v];
            };
            game.params.sURL = sURL;
            game.params.sTitle = sTitle;
            game.titleDomain = titleDomain;
			game.chatF.chn.event.col = "00FF00";
            game.chatF.chn.event.tag = "";
            game.chatF.chn.event.str = "event";
            game.chatF.chn.event.typ = "message";
            game.chatF.chn.event.rid = 0;
            game.chatF.chn.event.act = 1;
        }

        public function onError(e:IOErrorEvent):void{
            trace(("Preloader IOError: " + e));
        }
		
		function frame1(){
		    this.bg.addEventListener(Event.ENTER_FRAME, this.fl_FadeSymbolIn);
            this.bg.alpha = 0;
            this.mcLoading.addEventListener(Event.ENTER_FRAME, this.fl_FadeSymbolIn_2);
            this.mcLoading.alpha = 0;
			this.FadeOutX = new Timer(1, 10);
			this.FadeOutX.addEventListener(TimerEvent.TIMER, this.FadeOutX_Tick);
            this.FadeOutX.addEventListener(TimerEvent.TIMER_COMPLETE, this.FadeOutX_Complete);
			Security.allowDomain("*");
            sURL = this.loaderInfo.url.substring(0, this.loaderInfo.url.lastIndexOf("gamefiles/"));
            trace(("sURL: " + sURL));
            versionURL = "gameversion.asp";
            versionURL = (sURL + versionURL);
			trace(("versionURL: " + versionURL));
            loader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, onDataComplete);
            loader.load(new URLRequest(versionURL));
            titleDomain = new ApplicationDomain();
			
			
			
			
        }


    }
}

ele não esta executando a function onProgress que destaquei em vermelho, ou seja ele não mostra a porcentagem, como posso resolver?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.