9/11/2010 1:27:59 AM
Title:
"Custom preloader - progress bar flex" article doesn't work with RSL
try to use the preloader from this article (http://askmeflash.com/article/7/custom-preloader-progress-bar-flex),
when u browse a site for the first time, which is using RSL, you will notice it is not working.
i guess that the "dispatchEvent( new Event( Event.COMPLETE ) );" is dispatched too soon,
before the "swz" were downloaded, so the site won't run (the site is being "stucked" with the 100%).
only for the next time you browse the site, it will work o.k. i guess the site, now has the downloaded "swz".
9/11/2010 9:45:02 AM
there is another thread with solution to this problem , I am also using RSL and using the same preloader , but it works absolutely fine. See this thread and the solution is in the answer no 23
http://askmeflash.com/qdetail/877/custom-preloader-progress-bar-flex-by-inder
9/11/2010 2:47:37 PM
sorry, but without even running the example (the last one suggest in the long correspondence), it wouldn't work.
the reason is that there isn't any reference for "RSL Progress Event".
only for the "SWF Progress Event".
9/11/2010 11:25:44 PM
Is the RSL Progress Event required to be captured , I don't think so . RSL loading is automatically handled by flash player and its progress is included in SWF Progress Event. In my case when I delete the RSL from player cache then it takes longer for progress bar to load and when it is cached it loads quickly.
The above progress bar fix worked for me try that Eran
9/12/2010 3:11:13 AM
well, it didn't work for me :-(
u can try it yourself.
go to my site (after u delete the your signed RSL)
www.totohit.com
the code is almost as in the example.
it is not about capturing the rsl even progress.
it is about to know when all the relevant files has finished download,
and send the "event complete" in the right timing.
Inder
Points: 2980
Posts:0
9/12/2010 3:29:22 AM
Hi Eran , I will check the issue as you described and will update you
9/12/2010 10:05:39 PM
@Eran I am using the following code and also using RSL, after reading your post I tried the same by deleting my RSL from player cache. But I could not create the bug. I have altered this class from some places , you can check my code . Also If you find problem in my code also , please tell me . I also want to rectify if there is any such problem
thanks . Here goes my code
package CoreClasses
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.utils.Timer;
import mx.preloaders.DownloadProgressBar;
public class CustomPreloader extends DownloadProgressBar {
private var timer:Timer;
private var txtHead:TextField= new TextField();
[ Embed(source="CSS/Welcome.swf", mimeType="application/octet-stream") ]
public var WelcomeScreenGraphic:Class;
public static var loader:Loader;
public function CustomPreloader()
{
timer = new Timer(10);
timer.addEventListener( TimerEvent.TIMER, drawProgress );
timer.start();
loader= new Loader();
loader.loadBytes( new WelcomeScreenGraphic() as ByteArray );
this.addChild(loader);
}
override public function set preloader( preloader:Sprite ):void
{
txtHead.htmlText="<font face='Arial' color='#000000'><b></b></font>";
txtHead.x=(this.stage.stageWidth-456) / 2;
txtHead.y=(this.stage.stageHeight-134) / 2;
preloader.addEventListener(ProgressEvent.PROGRESS, SWFDownloadProgress);
pBar.x = (this.stage.stageWidth - 475) / 2;
pBar.y = (this.stage.stageHeight - 153) / 2;
loader.x = (this.stage.stageWidth - 475) / 2;
loader.y = (this.stage.stageHeight - 153) / 2;
txt.x=(this.stage.stageWidth-400) / 2;
txt.y=(this.stage.stageHeight+30) / 2;
txt.width=300;
setText("Loading Application ...");
this.addChild(txt);
this.addChild(txtHead);
this.addChild(pBar);
pBar.graphics.lineStyle(10,0xF9FCFE,1,false,"normal","none","round");
pBar.graphics.moveTo(37,118);
pBar.graphics.lineTo(400+37,118);
}
private var pBar:Sprite= new Sprite();
public static var progress:Number=0;
public static function setText(txtString:String):void{
txt.htmlText="<font face='Arial' color='#000000'><b>"+txtString+"</b></font>";
}
public static var txt:TextField= new TextField();
private function SWFDownloadProgress( event:ProgressEvent ):void {
var corePer:Number=2*Number(event.target.loaderInfo.bytesLoaded/event.target.loaderInfo.bytesTotal*100);
progress=corePer;
if(corePer==200){
setText("Configuring Application ...");
}
}
private var currlen:Number=37;
public function drawProgress(event: Event):void{
if(currlen<progress){
pBar.graphics.clear();
currlen+=5
pBar.graphics.lineStyle(10,0xF9FCFE,1,false,"normal","none","round");
pBar.graphics.moveTo(currlen,118);
pBar.graphics.lineTo(400+37,118);
}
if(progress==400){
timer.stop();
dispatchEvent( new Event( Event.COMPLETE ) );
}
}
}
}
9/13/2010 12:14:55 AM
that's strange, but the application is getting stuck in the preloader.
i haven't change a thing in your code (except giving my own swf as the 'WelcomeScreenGraphic')
9/13/2010 11:15:22 PM
hi eran,
i got this debug error on ur website..
ArgumentError: Error #1063: Argument count mismatch on com.falcor.visionary.client.preloader::Preloader/onDownloadComplete(). Expected 0, got 1.
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Inder
Points: 2980
Posts:0
9/16/2010 9:57:53 AM
@Eran I have done some updates to the source of the customPreloader class. Download the latest from following link and give me feedback if it works fine now.
http://askmeflash.com/article/7/custom-preloader-progress-bar-flex