Menu

[r217]: / cairngorm3 / trunk / libraries / TaskTest / src / samples / LoadStylesheet.as  Maximize  Restore  History

Download this file

75 lines (62 with data), 2.3 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
package samples
{
import com.adobe.cairngorm.task.Task;
import mx.events.StyleEvent;
import mx.styles.StyleManager;
/**
* A task that loads a runtime stylesheet.
*/
public class LoadStylesheet extends Task
{
//------------------------------------------------------------------------
//
// Private properties
//
//------------------------------------------------------------------------
private var loader:IEventDispatcher;
//------------------------------------------------------------------------
//
// Public properties
//
//------------------------------------------------------------------------
//-------------------------------
// Simple bindables
//-------------------------------
[Bindable]
public var url:String;
//------------------------------------------------------------------------
//
// Implementation : TaskflowTask
//
//------------------------------------------------------------------------
override protected function performTask():void
{
if (url == null)
fault();
loader = StyleManager.loadStyleDeclarations(url);
loader.addEventListener(StyleEvent.COMPLETE, onLoadingComplete);
loader.addEventListener(StyleEvent.ERROR, onLoadingError);
}
//------------------------------------------------------------------------
//
// Event listeners
//
//------------------------------------------------------------------------
private function onLoadingComplete(event:StyleEvent):void
{
loader.removeEventListener(StyleEvent.ERROR, onLoadingError);
cleanUp();
complete();
}
private function onLoadingError(event:StyleEvent):void
{
cleanUp(); // TODO Don't clean-up fault listener due to framework bug!
fault();
}
private function cleanUp():void
{
loader.removeEventListener(StyleEvent.COMPLETE, onLoadingComplete);
loader = null;
}
}
}
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.