Guest User

Untitled

a guest
Aug 5th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.display.Sprite;
  2.  
  3. var ex:Sound;
  4. var ns:Sound;
  5. var position:int;
  6. var max:int;
  7. var speed:int = 4096;
  8.  
  9. var lclip:Sprite = new Sprite();
  10. lclip.graphics.beginFill(0x000000, 1);
  11. lclip.graphics.drawRect(50, 50, 50, 50);
  12. addChild(lclip);
  13.  
  14. var c1:Sprite = new Sprite();
  15. c1.graphics.beginFill(0x000000, 1);
  16. c1.graphics.drawRect(150, 50, 50, 50);
  17. addChild(c1);
  18.  
  19. var c2:Sprite = new Sprite();
  20. c2.graphics.beginFill(0x000000, 1);
  21. c2.graphics.drawRect(150, 150, 50, 50);
  22. addChild(c2);
  23.  
  24. var c3:Sprite = new Sprite();
  25. c3.graphics.beginFill(0x000000, 1);
  26. c3.graphics.drawRect(150, 200, 50, 50);
  27. addChild(c3);
  28.  
  29. var c4:Sprite = new Sprite();
  30. c4.graphics.beginFill(0x000000, 1);
  31. c4.graphics.drawRect(150, 250, 50, 50);
  32. addChild(c4);
  33.  
  34. var loadmusic:Sprite = new Sprite();
  35. loadmusic.graphics.beginFill(0x0000FF, 1);
  36. loadmusic.graphics.drawRect(250, 50, 50, 50);
  37. addChild(loadmusic);
  38.  
  39.  
  40. c1.addEventListener(MouseEvent.CLICK, function(){speed=-8192;});
  41. c2.addEventListener(MouseEvent.CLICK, function(){speed=-4096;});
  42. c3.addEventListener(MouseEvent.CLICK, function(){speed=4096;});
  43. c4.addEventListener(MouseEvent.CLICK, function(){speed=8192;});
  44.  
  45. lclip.visible = false;
  46. c1.visible = false;
  47. c2.visible = false;
  48. c3.visible = false;
  49. c4.visible = false;
  50.  
  51. loadmusic.addEventListener(MouseEvent.CLICK, init);
  52.  
  53. function init(e:Event):void
  54. {
  55.     position = 0;
  56.     loadmusic.visible = false;
  57.     lclip.visible = true;
  58.     ex = new fodgang();
  59.     ex.addEventListener(Event.COMPLETE, onComplete);
  60.     ns = new Sound();
  61.     ns.addEventListener(SampleDataEvent.SAMPLE_DATA, onDat);
  62. }
  63.  
  64. function onComplete(e:Event):void
  65. {
  66.     lclip.visible = false;
  67.     c1.visible = true;
  68.     c2.visible = true;
  69.     c3.visible = true;
  70.     c4.visible = true;
  71.     max = 44100 * (ex.length/1000) - 4096;
  72.     position = max;
  73.     ns.play();
  74. }
  75.  
  76. function onDat(e:SampleDataEvent):void
  77.  
  78. {
  79.     var bytes:ByteArray = new ByteArray();
  80.     ex.extract(bytes, 4096, position);
  81.     e.data.writeBytes(bytes);
  82.     position += speed;
  83.     if(position < 0)
  84.         position = max;
  85.     else if(position > max)
  86.         position = 0;
  87. }
Add Comment
Please, Sign In to add comment