-
1. Re: Switch case trouble... it looks fine but output says otherwise
Ned Murphy Jun 19, 2009 6:34 PM (in response to the_missing_link)It plays fine too (with a listener in the loop). What is the output saying?
Update: I should add that y increases as you move down the stage, so you probably want to switch +=/-= between the UP and DOWN keys
-
2. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 19, 2009 8:24 PM (in response to Ned Murphy)these are the errors I recieve... except I get 8 of them one for each command. I do have a stage event listener in place.
1119: Access of possibly undefined property x through a reference with static type Class.
1119: Access of possibly undefined property y through a reference with static type Class.
UPDATE: I made a newbie error and after a break from the computer I noticed it but I still got an error. I forgot to put the words event: in the listener. Here is my listener and the error that I get a lot.
stage.addEventListener(event:KeyboardEvent.KEY_DOWN, cool);
1084: Syntax error: expecting rightparen before colon.
-
3. Re: Switch case trouble... it looks fine but output says otherwise
Ned Murphy Jun 20, 2009 4:26 AM (in response to the_missing_link)For the event listener, the following is correct:
stage.addEventListener(KeyboardEvent.KEY_DOWN, cool);
For the other 8 errors, what is the shoot_mc? How is it created/added to the stage? You appear to have used "Class" to define its class.
-
4. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 20, 2009 2:13 PM (in response to Ned Murphy)Shoot_mc is a movie clip thats pulled from my library used as a cursor.
-
5. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 24, 2009 10:12 PM (in response to the_missing_link)I posted this a couple post up in a edit but I think no one saw it. I'm no longer recieving the shoot_mc errors I forgot to put the words event: in the listener. Here is my listener and the error that I get a lot.
1084: Syntax error: expecting rightparen before colon.
-
6. Re: Switch case trouble... it looks fine but output says otherwise
Raymond Basque Jun 25, 2009 6:28 AM (in response to the_missing_link)Change
stage.addEventListener(event:KeyboardEvent.KEY_DOWN, cool);
to
stage.addEventListener(KeyboardEvent.KEY_DOWN, cool);
-
7. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 25, 2009 11:25 AM (in response to Raymond Basque)I did that and got another error. I decided to post the entire switch function and listener since that might help.
stage.addEventListener(KeyboardEvent.KEY_DOWN, cool); function cool(event:KeyboardEvent.KEY_DOWN):void { switch(event.keyCode) { case Keyboard.LEFT : shoot_mc.x -= 5 break; case Keyboard.RIGHT : shoot_mc.x += 5 break; case Keyboard.UP : shoot_mc.y += 5 break; case Keyboard.DOWN : shoot_mc.y -= 5 break; } } -
8. Re: Switch case trouble... it looks fine but output says otherwise
Raymond Basque Jun 25, 2009 11:26 AM (in response to the_missing_link)Change
function cool(event:KeyboardEvent.KEY_DOWN):void
to
function cool(event:KeyboardEvent):void
-
9. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 25, 2009 2:28 PM (in response to Raymond Basque)Thanks raymond for the help. I'm not sure why but I get the same errors that
I posted after doing what you said.
-
10. Re: Switch case trouble... it looks fine but output says otherwise
Ned Murphy Jun 25, 2009 2:43 PM (in response to the_missing_link)The problem may not have to do with the switching and keyboard stuff, but just in case, here's a sample file with the keyboard controlling the position of a shoot_mc:
-
11. Re: Switch case trouble... it looks fine but output says otherwise
the_missing_link Jun 25, 2009 5:11 PM (in response to Ned Murphy)thank you soo much Ned! I looked at your code and it was identical to mine,
so i looked at your library and my library and noticed a difference. You
exported as symbol1 when I exported as shoot_mc. The export was creating a
conflict. Thank you for your help!! Now a lot of my projects will work
thanks to this discovery.
-
12. Re: Switch case trouble... it looks fine but output says otherwise
Ned Murphy Jun 25, 2009 6:04 PM (in response to the_missing_link)You're welcome




