dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Playing movie clips when button is pressed

  1. #1
    Junior Member
    Join Date
    Jan 2007
    Posts
    26

    Playing movie clips when button is pressed

    I'm trying to create a simple flash game which shows an on-screen character jumping. I have created a movie clip of the character with the animation of the character crouching, then jumping, then landing. I would like to make it so that when a button, like SPACE bar is pressed, the character jumps and rises as long as the button is held. When the button is released, the character should come back down. I already have script in place for the jumping, but i would like the character to have the proper animation while doing so. I was thinking i would reference specific clips in the symbol timeline to correspond to when the button is pressed, held then let go. It should crouch and jump on the initial press, hold the jumping animation as long as he is jumping, and change again to landing animation when SPACE is released. For those of you kind enough to have actually read through this entire entry, i would appreciate any suggestions you have for me to try, i'm willing to learn anything right now...

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    heres one way to continuosly carry out an action while a button is pressed

    Code:
    myMovie.onPress = function(){
       
        this.onEnterFrame = function(){
           //trace("The button is still held down");
        }
    }
    
    myMovie.onRelease = function(){
        trace("button no longer down");
        delete this.onEnterFrame;
    }
    
    myMovie.onReleaseOutside = myMovie.onRelease;
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Junior Member
    Join Date
    Jan 2007
    Posts
    26
    thanks guy...

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