Menu

[r328]: / cairngorm3 / trunk / libraries / TaskTest / src / samples / TaskFlowPreloader.as  Maximize  Restore  History

Download this file

186 lines (146 with data), 5.1 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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package samples
{
import com.adobe.cairngorm.task.ITaskGroup;
import com.adobe.cairngorm.task.TaskEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
import mx.events.FlexEvent;
import mx.preloaders.IPreloaderDisplay;
public class TaskFlowPreloader extends Sprite implements IPreloaderDisplay
{
private var labelText:TextField;
public function TaskFlowPreloader()
{
super();
}
//------------------------------------------------------------------------
//
// Implementation : IPreloaderDisplay
//
//------------------------------------------------------------------------
// Define a Loader control to load the SWF file.
// Specify the event listeners.
public function set preloader(preloader:Sprite):void
{
// Listen for the relevant events
preloader.addEventListener(ProgressEvent.PROGRESS, handleProgress);
preloader.addEventListener(Event.COMPLETE, handleComplete);
preloader.addEventListener(FlexEvent.INIT_PROGRESS, handleInitProgress);
preloader.addEventListener(FlexEvent.INIT_COMPLETE, handleInitComplete);
}
// Initialize the Loader control in the override
// of IPreloaderDisplay.initialize().
public function initialize():void
{
labelText = new TextField();
labelText.scaleX = 5;
labelText.scaleY = 5;
labelText.width = 600;
labelText.y = 330;
labelText.x = 300;
addChild(labelText);
labelText.text = "Loading Flex Framework";
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private var counter:Number = 0;
private function onEnterFrame(event:Event):void
{
counter += 0.09;
graphics.clear();
var angle:Number = counter;
var color:Number = 0x000000;
for (var i:uint = 0; i < 60; i++)
{
angle -= 0.03;
color += 0x040404;
graphics.lineStyle(1, color);
graphics.moveTo(Math.cos(angle) * stageWidth + stageWidth / 2, Math.sin(angle) * stageHeight + stageHeight / 2);
graphics.lineTo(Math.cos(angle + 10) * stageWidth + stageWidth / 2,
Math.sin(angle + 10) * stageHeight + stageHeight / 2);
}
}
public function get backgroundColor():uint
{
return 0;
}
public function set backgroundColor(value:uint):void
{
}
public function get backgroundAlpha():Number
{
return 0;
}
public function set backgroundAlpha(value:Number):void
{
}
public function get backgroundImage():Object
{
return undefined;
}
public function set backgroundImage(value:Object):void
{
}
public function get backgroundSize():String
{
return "";
}
public function set backgroundSize(value:String):void
{
}
public function get stageWidth():Number
{
return _stageWidth;
}
private var _stageWidth:Number;
public function set stageWidth(value:Number):void
{
_stageWidth = value;
}
private var _stageHeight:Number;
public function get stageHeight():Number
{
return _stageHeight;
}
public function set stageHeight(value:Number):void
{
_stageHeight = value;
}
//------------------------------------------------------------------------
//
// Event Handlers
//
//------------------------------------------------------------------------
private function handleProgress(event:ProgressEvent):void
{
}
private function handleComplete(event:Event):void
{
}
private function handleInitProgress(event:Event):void
{
}
private function handleInitComplete(event:Event):void
{
var taskgroup:ITaskGroup = new ExampleTasks();
taskgroup.addEventListener(TaskEvent.CHILD_START, onChildStart);
taskgroup.addEventListener(TaskEvent.TASK_PROGRESS, onTaskProgress);
taskgroup.addEventListener(TaskEvent.TASK_COMPLETE, onTaskComplete);
taskgroup.start();
}
private function onChildStart(event:TaskEvent):void
{
labelText.text = event.task.label ? event.task.label : "";
}
private function onTaskProgress(event:TaskEvent):void
{
}
private function onTaskComplete(event:TaskEvent):void
{
dispatchEvent(new Event(Event.COMPLETE));
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.