Guest User

Untitled

a guest
Nov 21st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.MovieClip;
  4. import flash.events.KeyboardEvent;
  5. import flash.ui.Keyboard;
  6. import flash.events.Event;
  7. import flash.text.*;
  8. import flash.net.URLRequest;
  9. import flash.net.URLLoader;
  10.  
  11.  
  12. public class Main extends MovieClip
  13. {
  14.  
  15.  
  16. var manageShit:NoteManager = new NoteManager();
  17. var ajouteNote:Note = new Note();
  18.  
  19.  
  20.  
  21.  
  22. public function Main ()
  23. {
  24. init();
  25. setXML();
  26.  
  27.  
  28.  
  29.  
  30.  
  31. //Diabled while working on the menu/song selection
  32.  
  33.  
  34. //DISABLED XML IN IT'S OWN CLASS
  35. /*var xmlCall:XmlClass = new XmlClass();*/
  36.  
  37.  
  38. }
  39.  
  40. function init():void
  41. {
  42.  
  43. //Add event listeners
  44. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
  45. stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
  46. /*addEventListener(Event.ENTER_FRAME, onEnterFrame)*/
  47.  
  48.  
  49. }
  50.  
  51. public function callNote():void
  52. {
  53. parent.addChild(ajouteNote);
  54. //Changing the text field of the note
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61. //-When a key is pressed, play the sound and animation
  62. function onKeyDown(event:KeyboardEvent):void
  63. {
  64. if (event.keyCode == 83)
  65. {
  66. //THE ACTION TO PLAY SOUND AND ANIMATION;
  67. //stage.character1.gotoAndStop("Action");
  68. character2.gotoAndStop("Action");
  69. }
  70. else if (event.keyCode == 75)
  71. {
  72. //THE ACTION TO PLAY SOUND AND ANIMATION;
  73. //stage.character1.gotoAndStop("Action");
  74. character1.gotoAndStop("Action");
  75. }
  76.  
  77.  
  78.  
  79. }
  80.  
  81. //-When a key is released, go to idle state
  82. function onKeyUp(event:KeyboardEvent):void
  83. {
  84. if (event.keyCode == 83)
  85. {
  86. //THE ACTION TO PLAY SOUND AND ANIMATION;
  87. //stage.character1.gotoAndStop("Action");
  88. character2.gotoAndStop("Idle");
  89. }
  90. else if (event.keyCode == 75)
  91. {
  92. //THE ACTION TO PLAY SOUND AND ANIMATION;
  93. //stage.character1.gotoAndStop("Action");
  94. character1.gotoAndStop("Idle");
  95. }
  96.  
  97.  
  98.  
  99. }
  100.  
  101. public function setXML():void {
  102. var myLoader:URLLoader = new URLLoader();
  103.  
  104. myLoader.addEventListener(Event.COMPLETE, processXML);
  105. myLoader.load(new URLRequest("XML/Songs/song1.xml"));
  106. }
  107.  
  108.  
  109.  
  110.  
  111. //Loading the XML for the song
  112. public function processXML(e:Event):void {
  113. var myXML = new XML(e.target.data);
  114.  
  115. //Setting the tempo to the framerate---(FOR ANIMATION PURPOSES ONLY--Need to recalculate for more precise conversion (framerate-tempo) )
  116. stage.frameRate = myXML.bpm/6;
  117.  
  118.  
  119. }
  120.  
  121.  
  122.  
  123.  
  124. }
  125.  
  126. }
Add Comment
Please, Sign In to add comment