A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [MX04] annoying trick in the action scrip >:(

  1. #1
    Member
    Join Date
    Jan 2007
    Posts
    55

    [MX04] annoying trick in the action scrip >:(

    im making a game where you have to guide a little ball around a series of mazes where you start off at one end and reach the item at the other end which i got off a tutorial somewhere.
    The problem is that when i get the item the first time it sends me back to the beginning of that level and then the second time sends me to where i want to go .....
    if (_root.coin.hitTest(this.herout)) {
    _root.coin = _root.gotoAndPlay(27);
    herout being the outside of my ball, coin being the object im getting.
    thats the action script i used to make it jump to the next level ive tryed everything!!!
    If you can help me get it to go there first time it would be much apreciated!
    Thanks in advance!

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    _root.coin = _root.gotoAndPlay(27);

    I don't understand what you are trying to do here

    if you want the main timeline to go to frame 27 when the hitTest
    condition is met, you need to loop the code and escape the
    loop on success -
    Code:
    this.onEnterFrame = function(){ // loop
    if (_root.coin.hitTest(this.herout)) { 
    _root.gotoAndPlay(27);
    this.onEnterFrame = null; // escape loop
    }
    }

  3. #3
    Member
    Join Date
    Jan 2007
    Posts
    55
    that didnt work =(
    im sorry it made more sense in my head! lol
    ok so it has a frame saying level one (on frame 26 because i made a few levels and then decided to add this in) and when the button on that level is pressed it goes to frame 3 (where my level one is). You can then play that level (moving the ball around with arrow keys) to get the object at the end which i called coin. that action script i believe tells it when the ball and the coin meet, go to frame 27 of the main movie, which is where the level 2 frame is. But when i play the first level it gets to the coin and restarts that level again (so i have to play that level again) and then once i get the coin a second time, it proceedes to level 2 like it should. i really dont want people to have to complete the level twice lol thats why i need it to stop if you can help!
    Also thanks for the fast reply!

  4. #4
    Member
    Join Date
    Jan 2007
    Posts
    55
    ok after lots of studying i solved the problem!
    it turns out the level was running over 2 frames and so it played the level twice! i just made it play one frame!
    Thanks for trying to help though modified dog!

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