public
Description: Flying Saucer as3 helper classes
Clone URL: git://github.com/csessions/as3.git
Enhance Mp3, add JS.allow
csessions (author)
Mon Sep 01 23:02:35 -0700 2008
commit  87d8afd7c1bedd4f7541039bec83a7cd9e15a5c3
tree    8d5faddea000d2ce9fb10b041737942ba1d83785
parent  16cbe97e6c6076588cd7187494a47052f134c5bb
...
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
...
82
83
84
 
 
 
 
85
86
87
...
90
91
92
93
 
94
95
96
...
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
...
89
90
91
92
93
94
95
96
97
98
...
101
102
103
 
104
105
106
107
0
@@ -44,32 +44,39 @@ package net.flying_saucer.ui {
0
       } catch (er:Error) {}
0
       _playing = false
0
       _position = 0
0
+ sc = null
0
+ s = null
0
     }
0
     
0
- public function load(url:String = ''):void {
0
+ public function load(url:String = '', autoplay:Boolean = true):void {
0
       clear()
0
       s = new Sound()
0
       s.load(Url.path(url))
0
- play()
0
+ if(autoplay) play()
0
     }
0
 
0
     public function play(offset:int = -1):void {
0
       if(offset < 0) offset = position
0
- sc = s.play(offset)
0
- sc.soundTransform = new SoundTransform(_volume)
0
- sc.addEventListener(Event.SOUND_COMPLETE, mp3_complete, false, 0, true)
0
- _playing = true
0
+ if(s) {
0
+ sc = s.play(offset)
0
+ sc.soundTransform = new SoundTransform(_volume)
0
+ sc.addEventListener(Event.SOUND_COMPLETE, mp3_complete, false, 0, true)
0
+ _playing = true
0
+ }
0
     }
0
     
0
     public function pause():void {
0
- _position = sc.position
0
- _playing = false
0
- sc.stop()
0
+ if(sc) {
0
+ _position = sc.position
0
+ _playing = false
0
+ sc.stop()
0
+ }
0
     }
0
     
0
- public function toggle():void {
0
+ public function toggle():Boolean {
0
       if(_playing) pause()
0
       else play()
0
+ return _playing
0
     }
0
     
0
     // Getters / Setters
0
@@ -82,6 +89,10 @@ package net.flying_saucer.ui {
0
       return sc ? sc.position : 0
0
     }
0
     
0
+ public function get ready():Boolean {
0
+ return s != null
0
+ }
0
+
0
     public function set volume(v:Number):void {
0
       if(sc) sc.soundTransform = new SoundTransform(v)
0
       _volume = v
0
@@ -90,7 +101,7 @@ package net.flying_saucer.ui {
0
     // Event handlers
0
     // =========================================================================
0
     private function mp3_complete(e:Event):void {
0
- dispatch('Mp3::MP3_COMPLETE')
0
+ dispatch('Mp3::COMPLETE')
0
     }
0
 
0
     // Private Methods
...
7
8
9
10
 
11
 
12
13
14
15
16
17
18
19
20
 
 
 
 
21
22
23
24
25
 
 
 
 
 
 
 
26
27
28
...
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
0
@@ -7,22 +7,27 @@
0
 
0
 package net.flying_saucer.util {
0
 
0
- import net.flying_saucer.util.*
0
+ import net.flying_saucer.util.Debug
0
   import flash.external.ExternalInterface
0
+ import flash.system.Security
0
 
0
   public class JS {
0
 
0
- // Properties
0
- // =========================================================================
0
- // private static var instance:DisplayObject = new JS()
0
-
0
     // Public Methods
0
     // =========================================================================
0
+ public static function allow(domain:String):void {
0
+ Security.allowDomain(domain)
0
+ }
0
+
0
     public static function call(method:String, ...params):void {
0
       if(ExternalInterface.available) {
0
- Debug.tt('JS::call ' + method, params)
0
- ExternalInterface.call(method, params)
0
- } else Debug.tt('JS::call Error: ExternalInterface not available.')
0
+ try {
0
+ ExternalInterface.call(method, params)
0
+ Debug.tt('JS::call ' + method, params)
0
+ } catch (e:Error) {
0
+ Debug.warn('JS::call Error: ' + e)
0
+ }
0
+ } else Debug.warn('JS::call Error: ExternalInterface not available.')
0
     }
0
     
0
     public static function analytics(...params):void {

Comments

    No one has commented yet.