Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.MovieClip;
- import flash.events.KeyboardEvent;
- import flash.ui.Keyboard;
- import flash.events.Event;
- import flash.text.*;
- import flash.net.URLRequest;
- import flash.net.URLLoader;
- public class Main extends MovieClip
- {
- var manageShit:NoteManager = new NoteManager();
- var ajouteNote:Note = new Note();
- public function Main ()
- {
- init();
- setXML();
- //Diabled while working on the menu/song selection
- //DISABLED XML IN IT'S OWN CLASS
- /*var xmlCall:XmlClass = new XmlClass();*/
- }
- function init():void
- {
- //Add event listeners
- stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
- stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
- /*addEventListener(Event.ENTER_FRAME, onEnterFrame)*/
- }
- public function callNote():void
- {
- parent.addChild(ajouteNote);
- //Changing the text field of the note
- }
- //-When a key is pressed, play the sound and animation
- function onKeyDown(event:KeyboardEvent):void
- {
- if (event.keyCode == 83)
- {
- //THE ACTION TO PLAY SOUND AND ANIMATION;
- //stage.character1.gotoAndStop("Action");
- character2.gotoAndStop("Action");
- }
- else if (event.keyCode == 75)
- {
- //THE ACTION TO PLAY SOUND AND ANIMATION;
- //stage.character1.gotoAndStop("Action");
- character1.gotoAndStop("Action");
- }
- }
- //-When a key is released, go to idle state
- function onKeyUp(event:KeyboardEvent):void
- {
- if (event.keyCode == 83)
- {
- //THE ACTION TO PLAY SOUND AND ANIMATION;
- //stage.character1.gotoAndStop("Action");
- character2.gotoAndStop("Idle");
- }
- else if (event.keyCode == 75)
- {
- //THE ACTION TO PLAY SOUND AND ANIMATION;
- //stage.character1.gotoAndStop("Action");
- character1.gotoAndStop("Idle");
- }
- }
- public function setXML():void {
- var myLoader:URLLoader = new URLLoader();
- myLoader.addEventListener(Event.COMPLETE, processXML);
- myLoader.load(new URLRequest("XML/Songs/song1.xml"));
- }
- //Loading the XML for the song
- public function processXML(e:Event):void {
- var myXML = new XML(e.target.data);
- //Setting the tempo to the framerate---(FOR ANIMATION PURPOSES ONLY--Need to recalculate for more precise conversion (framerate-tempo) )
- stage.frameRate = myXML.bpm/6;
- }
- }
- }
Add Comment
Please, Sign In to add comment