A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Flash CS5.5 AS2 Key question

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    7

    Flash CS5.5 AS2 Key question

    onClipEvent (enterFrame) {
    if (Key.isDown(65)) {
    this.gotoAndStop("attack1");

    The problem is, when i press letter "a" (key.isDown(65)"" it will animate "attack1" but it will not finish the animation unless i hold the button... i wanted it to just one push and it will automatically finish the frames without holding button "a",

    this is just for now thx

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    There's a script you are not providing, i think. The scripts that will happen when you release the button. I think you have a line in your script that will be made when you release the "a" button, it goes to first 1 (or the frame when the character is "stand"). So that's why when you release the button, instead of the animation of the attack continues, it stops, because the main movieclip gotoAndStop the first frame, or the frame with the "stand" state.

    If you don't have any other script, i don;t know what's the issue then, because i tried your script, and it works, when you press "a" button, the attack animation runs perfectly until its end here, because this script you posted, doesn't have any event for when you release the "a" button.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    Registered User
    Join Date
    Feb 2014
    Posts
    7
    yes it will go to the character stand or idle.. what should i replace the "this.gotoAndStop".

    btw. i tried isToggle instead of isDown so it will finish the frame but i dont know how to toggle it 'off' again.

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    My suggestion is.. make the attack1 animation as a movieclip, inside the main movieclip. Put an instance name to the attack1 animation's movieclip.
    Then in the main movieclip's script, make a function like this:
    onClipEvent (enterFrame) {
    if (Key.isDown(65))
    {
    this.AnimInstanceName.play();
    }
    }
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  5. #5
    Registered User
    Join Date
    Feb 2014
    Posts
    7
    hi angelhdz it doesnt seem to be wirking or im doing it wrong.. the attack1 is in movie clip so i did this..

    if (Key.isDown(65))
    {
    this.attack1.play();
    }

    do you have or could you give me a sample .fla file that i can open and study, that is related to my question? it would possibly help me alot thanks!

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