Created
April 2, 2010 14:35
-
-
Save mrinalwadhwa/353185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mrinalwadhwa | |
{ | |
import flash.display.DisplayObject; | |
import flash.display.MovieClip; | |
import flash.display.StageAlign; | |
import flash.display.StageScaleMode; | |
import flash.events.Event; | |
import flash.events.TimerEvent; | |
import flash.utils.Dictionary; | |
import flash.utils.Timer; | |
import flash.utils.getDefinitionByName; | |
import mx.core.IFlexModuleFactory; | |
public class ApplicationLoader extends MovieClip implements IFlexModuleFactory | |
{ | |
public function ApplicationLoader() | |
{ | |
stage.scaleMode = StageScaleMode.NO_SCALE; | |
stage.align = StageAlign.TOP_LEFT; | |
stop(); | |
addEventListener(Event.ENTER_FRAME, onEnterFrame); | |
} | |
private function onEnterFrame(event:Event):void | |
{ | |
graphics.clear(); | |
if(framesLoaded == totalFrames) | |
{ | |
removeEventListener(Event.ENTER_FRAME, onEnterFrame); | |
nextFrame(); | |
var app:Object = create(); // create's your application | |
addChild(app as DisplayObject); | |
} | |
else | |
{ | |
// your preloader | |
var percent:Number = | |
root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal; | |
graphics.beginFill(0x444444); | |
graphics.drawRect(0, stage.stageHeight / 2 - 10, | |
stage.stageWidth * percent, | |
10); | |
graphics.endFill(); | |
} | |
} | |
/** | |
* All the methods below this point are from IFlexModuleFactory, | |
* you can leave them as is for most simple applications, you may | |
* need to modify them if your application loads other modules or | |
* in case you application is an AIR app, if you do need them, | |
* check out flex's mx.core.SystemManager to understand how they | |
* are used | |
*/ | |
public function create(... params):Object | |
{ | |
var mainClassName:String = info()["mainClassName"]; | |
if(mainClassName == null) | |
{ | |
var url:String = loaderInfo.loaderURL; | |
var dot:int = url.lastIndexOf("."); | |
var slash:int = url.lastIndexOf("/"); | |
mainClassName = url.substring(slash + 1, dot); | |
} | |
var mainClass:Class = Class(getDefinitionByName(mainClassName)); | |
return mainClass ? new mainClass() : null; | |
} | |
public function callInContext(fn:Function, thisArg:Object, | |
argArray:Array, returns:Boolean = true):* | |
{ | |
return undefined; | |
} | |
public function info():Object | |
{ | |
return {}; | |
} | |
public function get preloadedRSLs():Dictionary | |
{ | |
return null; | |
} | |
public function allowDomain(... domains):void | |
{ | |
} | |
public function allowInsecureDomain(... domains):void | |
{ | |
} | |
public function registerImplementation(interfaceName:String, impl:Object):void | |
{ | |
} | |
public function getImplementation(interfaceName:String):Object | |
{ | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment