A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: ActionScripting Error HELP!!!

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    ActionScripting Error HELP!!!

    A problem from a RPG game I'm designing -

    Ok so if I have a MC called guy and a MC called shop, I can use Keyboard to navigate guy and this is what I am trying to do #

    If guy is hit-testing shop, I want a dynamic Txtbox to say: - Press Space to Acess Shop - Better get your wallet first! -
    And If I press SPACE while guy is hit-testing shop, I want to gotoAndStop to another location.

    This is the AS i dreamed up:


    Code:
    onClipEvent (load) { if (this.hitTest(_root.guy)) { description = "Shop Keeper, Its best if you have some money on you though"; if (Key.isDown(Key.SPACE)) { _parent.gotoAndStop("eleswhere",1); } } }
    So could anyone tell me what's wrong and how do i fix it?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    Ok, firstly you need to have it on an

    onClipEvent(enterFrame)

    handler, the load handler only runs once when the movie runs.
    Secondly, you need to use

    Key.isDown(KEY.SPACE) //-- Capital 'KEY'


    Hope that helps, i dont think there is anything else wrong with it..

    Alex

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Er it is on the onClipEvent handler.
    the code thing didnt work out proper.
    .. I'll try it maybe your right.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    Senior Member
    Join Date
    Jun 2004
    Posts
    193
    no, its on the onClipEvent !!**LOAD**!! // NOT the same as enterFrame.

    Load will activate the script once, enterFrame will activate the code every frame.


    so you should have

    onClipEvent(enterFrame){...}

    not

    onClipEvent(load){...}


    Alex

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