Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.display.Sprite;
- var ex:Sound;
- var ns:Sound;
- var position:int;
- var max:int;
- var speed:int = 4096;
- var lclip:Sprite = new Sprite();
- lclip.graphics.beginFill(0x000000, 1);
- lclip.graphics.drawRect(50, 50, 50, 50);
- addChild(lclip);
- var c1:Sprite = new Sprite();
- c1.graphics.beginFill(0x000000, 1);
- c1.graphics.drawRect(150, 50, 50, 50);
- addChild(c1);
- var c2:Sprite = new Sprite();
- c2.graphics.beginFill(0x000000, 1);
- c2.graphics.drawRect(150, 150, 50, 50);
- addChild(c2);
- var c3:Sprite = new Sprite();
- c3.graphics.beginFill(0x000000, 1);
- c3.graphics.drawRect(150, 200, 50, 50);
- addChild(c3);
- var c4:Sprite = new Sprite();
- c4.graphics.beginFill(0x000000, 1);
- c4.graphics.drawRect(150, 250, 50, 50);
- addChild(c4);
- var loadmusic:Sprite = new Sprite();
- loadmusic.graphics.beginFill(0x0000FF, 1);
- loadmusic.graphics.drawRect(250, 50, 50, 50);
- addChild(loadmusic);
- c1.addEventListener(MouseEvent.CLICK, function(){speed=-8192;});
- c2.addEventListener(MouseEvent.CLICK, function(){speed=-4096;});
- c3.addEventListener(MouseEvent.CLICK, function(){speed=4096;});
- c4.addEventListener(MouseEvent.CLICK, function(){speed=8192;});
- lclip.visible = false;
- c1.visible = false;
- c2.visible = false;
- c3.visible = false;
- c4.visible = false;
- loadmusic.addEventListener(MouseEvent.CLICK, init);
- function init(e:Event):void
- {
- position = 0;
- loadmusic.visible = false;
- lclip.visible = true;
- ex = new fodgang();
- ex.addEventListener(Event.COMPLETE, onComplete);
- ns = new Sound();
- ns.addEventListener(SampleDataEvent.SAMPLE_DATA, onDat);
- }
- function onComplete(e:Event):void
- {
- lclip.visible = false;
- c1.visible = true;
- c2.visible = true;
- c3.visible = true;
- c4.visible = true;
- max = 44100 * (ex.length/1000) - 4096;
- position = max;
- ns.play();
- }
- function onDat(e:SampleDataEvent):void
- {
- var bytes:ByteArray = new ByteArray();
- ex.extract(bytes, 4096, position);
- e.data.writeBytes(bytes);
- position += speed;
- if(position < 0)
- position = max;
- else if(position > max)
- position = 0;
- }
Add Comment
Please, Sign In to add comment