The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Going to next frame with Keypress question

  1. #1

    Going to next frame with Keypress question

    I've already searched using the search button to find the answer but I couldn't find it.

    I'm really new to flash, but I want to know how to do this:


    There is this portal, in which takes you to the next screen IF you press down a key, say SHIFT.

    However, I only got


    Code:
    onClipEvent(enterFrame){
    if(this.hitTest(_root.hero)){
        gotoAndPlay(3)
    }
    Which would immediately send 'hero' to frame three as I touch it.


    What I want however, as explained, was that my 'hero' would only go to frame three IF SHIFT was pressed. So I tried-

    Code:
    onClipEvent(enterFrame){
    if(this.hitTest(_root.hero)){
    if(Key.isDown(Key.SHIFT)){
    gotoAndPlay(3)
       }
    }
    Since I typed this on here without Flash's help, it may look a bit funny, but the code I inputted was the same, with proper formatting, no errors.

    However, it didn't do a thing for me- for some reason, I wasn't even able to go to frame three with or without the keypress of SHIFT.



    So, as a wrap up: I am trying to find a way on how to make 'hero' go to frame three when/if there is a hitTest with 'portal', but only when I am pressing a certain key, like SHIFT. The script above went into the 'portal' actions. I am not sure if I put similar script into 'hero' and hitTest'ed it with 'portal', and if I would get better results?




    Thanks for reading this, and another big thanks if you help me as well!


    Last edited by blanked; April 26th, 2008 at 10:28 PM. Reason: script wrong

  2. #2
    the shift key is not being recognised because you are calling it from within a sub...err....sub level, what you need to do, is add a listener for keypresses. There are many beautiful tutorials on this very site about listeners, so i am not gonna go into much details about em, still, if you use a listener and use "and" in the if statement, it will work perfectly.
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  3. #3
    Quote Originally Posted by bluemagica View Post
    the shift key is not being recognised because you are calling it from within a sub...err....sub level, what you need to do, is add a listener for keypresses. There are many beautiful tutorials on this very site about listeners, so i am not gonna go into much details about em, still, if you use a listener and use "and" in the if statement, it will work perfectly.

    Thank you for the input. I knew it had something to do with Key listeners... looking up on them as we speak. Thanks once again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012