Actionscript 3.0: Addition of Document Class causes errors -


i'm trying learn actionscript 3.0 game i'm making in flash cs6, , i'm having issues document class. initially, had working menu scripting keyboard events , sound. realized needed store variables in way access them frame, created document class empty class , set game reference it, , menu scripting generating compiler error. error i'm getting "1046: type not found or not compile-time constant: keyboardevent," doesn't make sense me since worked fine beforehand. have idea problem might be? thanks!

document class:

package   {       import flash.display.movieclip;       public class main extends movieclip       {        }   } 

menu script:

import flash.utils.getdefinitionbyname; import flash.ui.keyboard;  stop();//used stay on current frame  var selection:int = 0;//will used determine button has "on" animation activated var canmove:boolean = true;  var menusong:sound = new menusong(); menusong.play (0 , 9999);//plays , loops(9999 times) menu theme  var menumove:sound = new menumove(); var menuselect:sound = new menuselect();  stage.addeventlistener(keyboardevent.key_down, move);//calls move function when key pressed  function move(event:keyboardevent):void{//the line causing error     if(canmove){         if(event.keycode == 40){             selection = (selection + 1)%3;//occurs when down key pressed             menumove.play();         }         else if(event.keycode == 38){             selection = (selection + 2)%3;//occurs when key pressed             menumove.play();         }         else if(event.keycode == 32){             canmove = false;             soundmixer.stopall();             menuselect.play();             fadeout.gotoandplay(1);         }          switch(selection){             case 0:                 this.singleplayer.gotoandplay("on");                 this.multiplayer.gotoandstop("off");                 this.credits.gotoandstop("off");                 break;             case 1:                 this.singleplayer.gotoandstop("off");                 this.multiplayer.gotoandplay("on");                 this.credits.gotoandstop("off");                 break;             case 2:                 this.singleplayer.gotoandstop("off");                 this.multiplayer.gotoandstop("off");                 this.credits.gotoandplay("on");                 break;           }//all tells selected button (based on selection variable)         //to play "on" animation, , other buttons play "off" animation.     } } 

you need import flash.events.keyboardevent use in code (menu script).

why dont use script called "menu script" document class ? if goal of swf designed in menu script code, should document class.

in way or another, if use stage.addeventlistener(keyboardevent.key_down, move); in code, must import flash.utils.keyboardevent. same thing sound ( import flash.media.sound) & soundmixer (import flash.media.soundmixer).


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -