A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: why double click?

  1. #1
    Junior Member
    Join Date
    Jul 2004
    Location
    PA
    Posts
    20

    why double click?

    okay so i finished my first program.. i had a start button n everything.. but to start the movie.. for some reason u have to click the button twice.. n i didn't kno why.. so i need some help.. its just one scene.. n i made one layer just for a stop in the beginning.. n then i made a button layer. .where i placed the button on the stage n had this in the script..
    code:
    on (release) {
    MyButton.onPress = function() {
    gotoAndPlay(2);
    };
    }


    What should i change?

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Welcome to FlashKit!

    It's like this:
    when you have on() or onClipEvent() this code is attached to a movie clip and/or button.
    This is the way is was done in flash 5.

    When you have some_mc.onSomething , for example, MyButton.onPress, you have a method, and this is the preferred way in MX or higher.

    So, you have duplicated code!
    The problem is that your on (release) does nothing but define a method, the onRelease, so, only when you click the second time, the onRelease is triggered.

    You should have:
    code:

    on (release) {
    gotoAndPlay(2);
    }


    or, like I said, the preferred way:

    code:

    MyButton.onPress = function() {
    gotoAndPlay(2);
    };


    attached to the timeline where the button is.

  3. #3
    Junior Member
    Join Date
    Jul 2004
    Location
    PA
    Posts
    20
    thnx a lot it worked great!

  4. #4
    Junior Member
    Join Date
    Jul 2004
    Location
    PA
    Posts
    20
    well actually only the on(release) one worked the MyButton.onPress didnt work..

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    did you attach
    code:

    MyButton.onPress = function() {
    gotoAndPlay(2);
    };


    to the timeline the button is in?

    For example, if the button is on the stage, you attach the code to the main timeline.

    Make sure the instance name of the button is MyButton.

    And the gotoAndPlay(2) refers to the timeline you want to control.
    If no movie clip is specifyed, it is the timeline the code is attched to (in the example, the main timeline).

    But you can specify a different timeline:
    code:

    some_mc.gotoAndPlay(2);

    Attached Files Attached Files

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