In app development their are many steps where we have to hang on for a while, like we are waiting for the server response, or the loading of assets or any other function to complete. Sometime to manage these such task we need a loading screen, which will appear during gap and after completion of program it will removed.
So here is the code to make a loading screen.
1- We add a quad
_overlay = new Quad(Starling.current.stage.stageWidth,Starling.current.stage.stageHeight , 0x000000);
_overlay.alpha = 0.9;
addChild(_overlay);
2- loading image
loadinImage= new Image(AssetLoader.getTexture("LoadingCircle"));
loadinImage.pivotX=loadinImage.width/2;
loadinImage.pivotY=loadinImage.height/2;
this.addChild(loadinImage);
loadinImage.x=stage.stageWidth/2 - loadinImage.width/2;
loadinImage.y=stage.stageHeight/2 - loadinImage.height /2;
loadinImage.scaleX = Constant.SCALE;
loadinImage.scaleY = Constant.SCALE;
timer= new Timer(10);
timer.addEventListener(TimerEvent.TIMER, rotate);
timer.start();
private function rotate(evt:TimerEvent):void
{
loadinImage.rotation+=.1;
}
0 Comment(s)