GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: the flash recorder for chirrp, written with haXe
Homepage: http://chirrp.net/
Clone URL: git://github.com/why/chirrup.git
Wrapped up the miniature player.  The recorder wipes the "sounds good" 
movie after OK.
why (author)
Thu Apr 17 23:03:07 -0700 2008
commit  5c056792207413245e7ab9acefe44a7688cd6f53
tree    774c7aa9f637e378358bb11803ea44671ba15885
parent  d7120a4ff128b4b337a2d886d41e0132a74a9fdb
...
12
13
14
 
15
16
17
...
73
74
75
76
 
77
78
79
...
95
96
97
98
 
99
100
101
102
103
104
 
105
106
107
...
12
13
14
15
16
17
18
...
74
75
76
 
77
78
79
80
...
96
97
98
 
99
100
101
102
103
104
 
105
106
107
108
0
@@ -12,6 +12,7 @@ class Base {
0
 
0
   static var rtmp = "rtmp://chirrp.net";
0
   static var server = "http://chirrp.net";
0
+ static var seconds : Float = 8;
0
 
0
   static var nc : NetConnection;
0
   static var ns : NetStream;
0
@@ -73,7 +74,7 @@ class Base {
0
     sb.downState = movieBitmap(bmpOn);
0
     sb.hitTestState = bmpHit;
0
     sb.useHandCursor = true;
0
- sb.addEventListener(flash.events.MouseEvent.CLICK, onClick);
0
+ sb.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, onClick);
0
     flash.Lib.current.addChild(sb);
0
     return sb;
0
   }
0
@@ -95,13 +96,13 @@ class Base {
0
     var f = new TextFormat();
0
     f.font = "Verdana";
0
     f.size = 12;
0
- f.color = 0x5599AA;
0
+ f.color = 0x4488AA;
0
     f.underline = true;
0
 
0
     var f2 = new TextFormat();
0
     f2.font = "Verdana";
0
     f2.size = 12;
0
- f2.color = 0xAA9955;
0
+ f2.color = 0xAA6633;
0
     f2.underline = true;
0
 
0
     var t = new TextField();
...
 
 
1
2
3
 
 
 
 
4
5
6
...
8
9
10
 
 
 
11
12
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
16
 
 
 
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
25
...
1
2
3
4
5
6
7
8
9
10
11
12
...
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
0
@@ -1,6 +1,12 @@
0
+import flash.display.BitmapData;
0
+import flash.display.MovieClip;
0
 import flash.external.ExternalInterface;
0
 import flash.media.Video;
0
 import flash.net.NetStream;
0
+import haxe.Timer;
0
+
0
+class PlayOnPng extends BitmapData {}
0
+class PlayOffPng extends BitmapData {}
0
 
0
 class Play extends Base {
0
 
0
@@ -8,18 +14,61 @@ class Play extends Base {
0
   static var file : String;
0
   static var re : EReg = ~/\/(\w{2}\/\w+)$/;
0
   static var re2 : EReg = ~/^(\w{2})(\w+)$/;
0
+ static var solid : MovieClip;
0
+ static var fader : Timer;
0
+ static var start : Float = 0;
0
 
0
   static function playRecording(e) {
0
+ solid.alpha = 1.0;
0
+ fader = new Timer(100);
0
+ start = Timer.stamp();
0
+ fader.run = function() {
0
+ var used = Timer.stamp() - start;
0
+ solid.alpha = 1.0 - (used / 1.0);
0
+ if (used >= 1.0)
0
+ {
0
+ solid.alpha = 0.0;
0
+ fader.stop();
0
+ }
0
+ };
0
     Base.play(Base.server + "/" + file + ".flv");
0
   }
0
 
0
   static function main() {
0
+ //
0
+ // Figure out the file's chirrp id
0
+ //
0
     url = ExternalInterface.call("window.location.href.toString");
0
     file = flash.Lib.current.loaderInfo.parameters.file;
0
     if (file == null && re.match(url))
0
       file = re.matched(1);
0
     else if (re2.match(file))
0
       file = re2.matched(1) + "/" + re2.matched(2);
0
- flash.Lib.current.addChild(Base.addLink("chirrp", playRecording));
0
+
0
+ //
0
+ // Play button
0
+ //
0
+ var play_off = new PlayOffPng(0, 0);
0
+ var play_on = new PlayOnPng(0, 0);
0
+ var play_hit = new MovieClip();
0
+ play_hit.graphics.beginFill(0);
0
+ play_hit.graphics.drawRect(0, 0, 70, 15);
0
+
0
+ var playButton =
0
+ Base.addBitmapButton(
0
+ play_off,
0
+ play_on,
0
+ play_hit,
0
+ playRecording
0
+ );
0
+
0
+ var mc = Base.movieBitmap(play_off);
0
+ playButton.upState = mc;
0
+ playButton.overState = mc;
0
+ solid = Base.movieBitmap(play_on);
0
+ solid.alpha = 0;
0
+ mc.addChild(solid);
0
+
0
+ flash.Lib.current.addChild(playButton);
0
   }
0
 }
0
...
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
...
73
74
75
76
77
78
 
 
 
 
 
 
 
 
 
79
80
81
...
201
202
203
204
 
205
206
207
...
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
...
73
74
75
 
 
 
76
77
78
79
80
81
82
83
84
85
86
87
...
207
208
209
 
210
211
212
213
0
@@ -23,25 +23,25 @@ class Rec extends Base {
0
   static var countclip : MovieClip;
0
   static var soundsgood : MovieClip;
0
 
0
- static var seconds : Float = 8;
0
+ static var tokenExp : EReg = ~/^200 token (\w+)$/;
0
 
0
   static var uuid : String;
0
   static var user : String;
0
   static var url : String;
0
   static var clock : Timer;
0
   static var start : Float = 0;
0
+ static var used : Float = 0;
0
 
0
   static function timeRecording() {
0
- var used : Float;
0
     if (Base.elapsedTime() > 0) {
0
       if (start == 0) {
0
         start = Timer.stamp();
0
       }
0
 
0
       used = (Timer.stamp() - start);
0
- countdown.text = "" + Std.int(seconds - used);
0
+ countdown.text = "" + Std.int(Base.seconds - used);
0
       countdown.setTextFormat(countfont);
0
- if (used >= seconds) {
0
+ if (used >= Base.seconds) {
0
         stopRecording(null);
0
         clock.stop();
0
       }
0
@@ -73,9 +73,15 @@ class Rec extends Base {
0
   }
0
 
0
   static function publish(e) {
0
- var r = new haxe.Http(Base.server + "/publish?id=" + uuid + "&user=" + user);
0
- r.onData = function(r) {
0
- ExternalInterface.call("window.location.reload");
0
+ soundsgood.visible = false;
0
+ var r = new haxe.Http(Base.server + "/publish?id=" + uuid + "&user=" + user + "&timing=" + Std.int(used * 1000));
0
+ r.onData = function(r)
0
+ {
0
+ if (tokenExp.match(r))
0
+ {
0
+ var token = tokenExp.matched(1);
0
+ ExternalInterface.call("finishChirrp", token);
0
+ }
0
     };
0
     r.request(false);
0
   }
0
@@ -201,7 +207,7 @@ class Rec extends Base {
0
     soundstxt.height = 50;
0
     soundstxt.setTextFormat(med);
0
 
0
- var okLink = Base.addLink("OK, I am very done!", publish);
0
+ var okLink = Base.addLink("OK, I'm all done!", publish);
0
     var noLink = Base.addLink("Nah, record it again.", reRecord);
0
 
0
     soundsgood = new MovieClip();
...
1
2
 
 
3
...
1
 
2
3
4
0
@@ -1,3 +1,4 @@
0
 #!/bin/sh
0
-swfmill simple library.xml library.swf
0
+swfmill simple chirec.xml chirec-i.swf
0
+swfmill simple chiplay.xml chiplay-i.swf
0
 haxe chirrup.hxml
...
1
2
3
4
 
5
6
7
8
9
10
11
 
 
12
...
1
2
3
 
4
5
6
7
8
9
10
 
11
12
13
0
@@ -1,12 +1,13 @@
0
 -swf chirec.swf
0
 -swf-version 9
0
 -swf-header 400:140:24:FFFFFF
0
--swf-lib library.swf
0
+-swf-lib chirec-i.swf
0
 -main Rec
0
 
0
 --next
0
 
0
 -swf chirplay.swf
0
 -swf-version 9
0
--swf-header 70:22:24:FFFFFF
0
+-swf-header 70:15:24:FFFFFF
0
+-swf-lib chiplay-i.swf
0
 -main Play

Comments

    No one has commented yet.