Hi!
I have a preloader that works fine when I test i with flash. I publish it and then go to View and Simulate Download. Everything works fine.
But when I upload it to my server it works fine util I hit the reload button, all it does is do the short intro animation to display the preloader and just sits there.
I have attatched the preloader class wich is pretty straight forward.
Any comments are welcome.
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.MovieClip;
import flash.text.Font;
import com.leebrimelow.drawing.Wedge;
import caurina.transitions.Tweener;
public class Preloader extends Sprite
{
private var Image:String = "LES.swf";
private var preLoader:Loader;
private var percent:Number;
private var ph_mc:PreloaderHolder;
private var tf:TextField;
private var tFormat:TextFormat;
private var preLoadFont:Font = new Helvetica();
private var preNum:Number = 0;
private var counter:Number = 1;
private var maxCount:Number = 5;
private var arcAngle:Number = 0;
private var sp:MovieClip = new MovieClip();
private var circleMask:MaskCircle = new MaskCircle();
public function Preloader() {
init();
}
private function init() {
preLoader = new Loader();
preLoader.load(new URLRequest(Image));
//Adds the preloader graphics to the stage
ph_mc = new PreloaderHolder();
ph_mc.x = 523;
ph_mc.y = 240;
addChild(ph_mc);
}
public function preloaderAnimDone() {
//this function is called from the preloader graphics movieclip timeline
createWedge();
preLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
preLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
ph_mc.animNumberPercent_mc.visible = false;
//adds a textfield to display progress
tFormat = new TextFormat();
tFormat.font = preLoadFont.fontName;
tFormat.align = "right";
tFormat.color = 0xffffff;
tFormat.size = 12;
tFormat.bold = true;
tf = new TextField();
tf.defaultTextFormat = tFormat;
tf.embedFonts = true;
tf.width = 40;
tf.height = 16;
tf.x = 562;
tf.y = 234;
addChild(tf);
}
private function createWedge():void {
//function to draw the wedge
sp.radius = 27;
sp.color = 0xFBB03B;
sp.count = 0;
sp.rotation = -90;
sp.alpha = .9;
sp.blendMode = "multiply";
sp.addEventListener(Event.ENTER_FRAME, drawWedge);
addChild(sp);
circleMask.x = 535;
circleMask.y = 241;
addChild(circleMask);
sp.mask = circleMask;
}
private function showProgress(event:ProgressEvent):void {
percent = Math.round((event.bytesLoaded / event.bytesTotal) * 100);
tf.text = percent + " " + "%";
//trace("PERCENT: " + percent);
}
function drawWedge(e:Event):void {
//draws the wedge
var sp:MovieClip = e.target as MovieClip;
sp.graphics.clear();
sp.graphics.beginFill(sp.color);
Wedge.draw(sp, -240, 535, sp.radius, sp.count, arcAngle);
sp.count = Math.ceil(percent * 3.6);
//trace("sp.count: " + sp.count)
}
private function showImage(event:Event):void {
// when percent recheas 99 I remove Masks and textfield....
// tells the preloader graphic to play the outro animation
if (percent >= 99) {
trace("Preloading done");
percent = 0;
circleMask.x = -40;
ph_mc.animNumberPercent_mc.visible = true;
ph_mc.animNumberPercent_mc.gotoAndStop(2);
ph_mc.gotoAndPlay("endAnim");
tf.x = -40;
}
}
public function preloaderDone() {
//this function is called from the preloader graphics class when outro is done
removeChild(ph_mc);
sp.removeEventListener(Event.ENTER_FRAME, drawWedge);
Tweener.addTween(preLoader, {time:3, alpha:1, transition:"linear"} );
trace("I am done");
addChild(preLoader);
}
}
}