-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionScript Preloader Class.as
More file actions
44 lines (39 loc) · 1.14 KB
/
Copy pathActionScript Preloader Class.as
File metadata and controls
44 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ${PACKAGE_NAME}#if (${PACKAGE_NAME} != "") #end{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.utils.getDefinitionByName;
/*
* In the Project Structure -> Modules -> Flex Compiler Settings, set ${NAME} as Main Class
*/
public class ${NAME} extends MovieClip
{
public function ${NAME}()
{
addEventListener(Event.ENTER_FRAME, checkFrame);
loaderInfo.addEventListener(ProgressEvent.PROGRESS, progress);
// show loader
}
private function progress(e:ProgressEvent):void
{
// update loader
}
private function checkFrame(e:Event):void
{
if (currentFrame == totalFrames)
{
removeEventListener(Event.ENTER_FRAME, checkFrame);
startup();
}
}
private function startup():void
{
// hide loader
stop();
loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progress);
var mainClass:Class = getDefinitionByName("${MAINCLASS}") as Class;
addChild(new mainClass() as DisplayObject);
}
}
}