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
chirrup / Play.hx
100644 75 lines (65 sloc) 1.845 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
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.external.ExternalInterface;
import flash.media.Video;
import flash.net.NetStream;
import haxe.Timer;
 
class PlayOnPng extends BitmapData {}
class PlayOffPng extends BitmapData {}
 
class Play extends Base {
 
  static var url : String;
  static var file : String;
  static var re : EReg = ~/\/(\w{2}\/\w+)$/;
  static var re2 : EReg = ~/^(\w{2})(\w+)$/;
  static var solid : MovieClip;
  static var fader : Timer;
  static var start : Float = 0;
 
  static function playRecording(e) {
    solid.alpha = 1.0;
    fader = new Timer(100);
    start = Timer.stamp();
    fader.run = function() {
      var used = Timer.stamp() - start;
      solid.alpha = 1.0 - (used / 1.0);
      if (used >= 1.0)
      {
        solid.alpha = 0.0;
        fader.stop();
      }
    };
    Base.play(Base.server + "/" + file + ".flv");
  }
 
  static function main() {
    //
    // Figure out the file's chirrp id
    //
    url = ExternalInterface.call("window.location.href.toString");
    file = flash.Lib.current.loaderInfo.parameters.file;
    if (file == null && re.match(url))
      file = re.matched(1);
    else if (re2.match(file))
      file = re2.matched(1) + "/" + re2.matched(2);
 
    //
    // Play button
    //
    var play_off = new PlayOffPng(0, 0);
    var play_on = new PlayOnPng(0, 0);
    var play_hit = new MovieClip();
    play_hit.graphics.beginFill(0);
    play_hit.graphics.drawRect(0, 0, 70, 15);
 
    var playButton =
      Base.addBitmapButton(
        play_off,
        play_on,
        play_hit,
        playRecording
      );
 
    var mc = Base.movieBitmap(play_off);
    playButton.upState = mc;
    playButton.overState = mc;
    solid = Base.movieBitmap(play_on);
    solid.alpha = 0;
    mc.addChild(solid);
 
    flash.Lib.current.addChild(playButton);
  }
}