dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: How2 respond to - Hit ANY key?

  1. #1
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45

    How2 respond to - Hit ANY key?

    How do I respond to *ANY* key press?

    I want to go from scene 1 to scene 2 after -any- key is pressed.

    I looked at the Asteroids & Crusader "Start" buttons and was puzzled. For example the Asteroid game "start" button has an action associated with it (Asteroids w/flash icon) but there is no scene, element, or function named "Asteroids"; so were does it go when the start button is pressed?

    Thanks jZ
    Jan Zumwalt - http://www.flash.neatinfo.com

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    About Asteroids "start" button... Game starts by playing first scene and stops.. start button simply continues to play from there ( so it goes to "play game" scene... ) Start button action play "Asteroids" refers to the movie name which is "Asteroids"

    "any key" is bit harder... using actionscripting you could add key "down" handler and do anything with it (it gets all keyboard "down" events),.. no problem if you use scripting as "backbone" of you game but simply plugging it in sample game like Asteroids might mess things up..
    Last edited by Finjogi; 01-16-2008 at 03:09 AM.

  3. #3
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45
    Thanks!

    1) After reading your explanation, I noticed that the "Play" action says play OR *RESUME*. Now I understand.

    2) For the "hit any key", something like this maybe? (how do I specify a "scene name"?

    myListener = new Object();
    myListener.onKeyDown = function () {
    trace ("You pressed a key.");
    }
    Key.addListener(myListener);
    Last edited by jwzumwalt; 01-17-2008 at 12:31 AM.
    Jan Zumwalt - http://www.flash.neatinfo.com

  4. #4
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    2) yes something like that, however if you use keyboard element and then add you own key listener what will happen... anyway here is actionscript3 example of keyboard events: http://edutechwiki.unige.ch/en/AS3_e...yboard_control

    -- cut down version --
    root.stage.addEventListener(KeyboardEvent.KEY_DOWN , keyPressedDown);

    private function keyPressedDown(event:KeyboardEvent):void {
    trace ("You pressed a key.");
    }
    ---

    Scene name is simple what you see it in 3dfa, like "Scene 1" and going to that position should be like this: gotoAndPlay ("Scene 1"); or you could create frame label at wanted position and gotoAndPlay ("framelabel");

    However, it seems that framelabels are not registering at the moment and renaming Scenes bugs at least in my computer so I'll go and report bug or two to 3dfa

    edit: renaming works when using edit scenes button ( "edit scenes -> rename" )
    Last edited by Finjogi; 01-17-2008 at 02:33 AM.

  5. #5
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45

    This is what I tried - didn't work :-(

    See attachment
    Attached Files Attached Files
    Jan Zumwalt - http://www.flash.neatinfo.com

  6. #6
    Senior Member
    Join Date
    Dec 2006
    Posts
    274
    Unfortunately at the moment 3dfa preview does not handle all action scripting so some scripting only works when exported to flash... in this case flash9 (action script 3 syntax was used.. )

    From what I have understood, in near future 3dfa will offer full flash "preview" and debugging and internal preview will be closer to full flash too..

    I modified your example little bit to provide some sort of "debugging" in flas as tracing is not directly supported in flash "screen".
    Attached Files Attached Files

  7. #7
    Member
    Join Date
    Oct 2006
    Location
    Seattle, WA
    Posts
    45
    Thanks for the help!!
    jz
    Jan Zumwalt - http://www.flash.neatinfo.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center