Problem with gotoAndPLay();

The function is not working properly. Weird problem.

Page 1 of 1

10 Replies - 3598 Views - Last Post: 04 August 2009 - 10:32 PM

#1 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Problem with gotoAndPLay();

Posted 31 July 2009 - 03:54 AM

Hello eveyone, I am trying to play different motion tweens on the same time line using action script 3.0. I have different motion tweens that are designed to play once a condition is met. In order to play those tweens from action script i used the function: gotoAndPlay(frameNumber); where frameNumber is the frame number i want to play from and then continue until the tween ends. the code looks lsome something like this:

_root.HomePage_mc.onEnterFrame = function() {
if (mouse_over_HomePage_mc) {
_root.HomePage_mc.nextFrame();
_root.Solutions_mc.gotoAndPlay(15); // this is where i want it to start for that movie clip
}



The problem is that it is reaching the needed frame (frame 15) but instead of continuing to play it stops. This seems very weird to me, I searched all over the web trying to find an answer for this and i couldnt find. I tried making a working around that such as this:
for(i = 15; i <= 30; i++ ){
_root.Solutions_mc.gotoAndPlay(i);
}



But it didnt work in a right way, as it just seems to jump to the last frame in the animation and does not show the desired tween.

I hope that someone could give me answer to this problem, or has an explanation for why it is being like this. Also any suggestions, ideas, workarounds and comments are welcome. Thanks in advance for your help. Have a good day. :)

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with gotoAndPLay();

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1200
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

Re: Problem with gotoAndPLay();

Posted 31 July 2009 - 10:44 AM

Flash is one of those things that tries to optimize what you are doing. You have a loop that updates a movieclip (which must update the graphics/ video memory), so Flash takes the time to wait for you to stop making call after call to it then updates the graphics.

So this:
for(i = 15; i <= 30; i++ ){
_root.Solutions_mc.gotoAndPlay(i);
}


If really saying:
_root.Solutions_mc.gotoAndPlay(30);


I believe what you want to say is something like so:
_root.Solutions_mc.gotoAndPlay(15);


Assuming you don't have a stop() call on each frame that should act how you want it to (playing at the swf's framerate).

You could also do it another way (if you absolutely want to use the loop). Use the setInterval function so it doesn't just continue all the way through:
var i = 15;
var timer = setInterval(doLoop, 1000);
function doLoop(){
	if(i > 30){
		clearInterval(timer);
		return;
	}
	_root.Solutions_mc.gotoAndPlay(i);
	i++;
}


This is reponsible for going through and looping the function every second, which then does the same thing the for loop does, just in a more drawn-out way.

Hope that helps.
Was This Post Helpful? 1
  • +
  • -

#3 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Problem with gotoAndPLay();

Posted 01 August 2009 - 01:04 AM

Actually I already tried using _root.Solutions_mc.gotoAndPlay(15);
and the problem remained the same, the animation seems to directly jumps to frame 30 without showing any animation on the way.

I tried the loop you suggested, although I fully believe that this way should work yet still it just appears to be jumping to frame 30.

Quote

Assuming you don't have a stop() call on each frame that should act how you want it to (playing at the swf's framerate).


I think this is the source of the problem, could you please tell me how I can know if there is a stop() call on each frame? Is that call generated automatically? How can I remove it in this case?

I believe that _root.Solutions_mc.gotoAndPlay(15); Is the right way to do this but simply something is stopping it from working in the right way. Thanks very much for your help :)
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1200
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

Re: Problem with gotoAndPLay();

Posted 01 August 2009 - 09:49 AM

Okay, go into Solution_mc (to edit it) and look at the timeline, if a frame has actionscript on it you will see a little "a" on the keyframe position. Click on each of those frames with your actions panel open (so you can see and modify what they are) and make sure there isn't any gotoAnd* calls in there, otherwise it may just be jumping. On the lasst frame you will probably want to have a stop() call so it doesn't repeat all the time.

Depending on how this works out I may ask you to post the fla so I can check in more depth.
Was This Post Helpful? 0
  • +
  • -

#5 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,605
  • Joined: 20-January 09

Re: Problem with gotoAndPLay();

Posted 01 August 2009 - 08:23 PM

Quote

Depending on how this works out I may ask you to post the fla so I can check in more depth.


Helping out with flash is kinda hard online huh?

Anyways, I have to ask the obvious questions - are you sure there isn't a 'STOP' on frame 15?

Also, have you considered actually placing all the data into it, possible trying something different to see if there is a bug in the way the movie is playing.

For instance I have had issues where I would put in:


gotoAndPlay(16);




And it wouldn't work correctly, but when I enter in all the data:


gotoAndPlay(16 , "Fun Scene");




It would stupidly work. I am not saying that this is the case here, but you could be making a glitch somewhere. I suggest posting the fla if you can.

--

Greg
Was This Post Helpful? 0
  • +
  • -

#6 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1200
  • View blog
  • Posts: 7,309
  • Joined: 07-September 06

Re: Problem with gotoAndPLay();

Posted 01 August 2009 - 08:38 PM

Quote

Helping out with flash is kinda hard online huh?

Yes, it is easier when you can look at the whole thing at once and not just part of it :)
Was This Post Helpful? 0
  • +
  • -

#7 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Problem with gotoAndPLay();

Posted 01 August 2009 - 11:14 PM

Quote

Yes, it is easier when you can look at the whole thing at once and not just part of it smile.gif


Alright then here is the file attached you can check it out. What I am working on is a simple flash menu where the components in it shrink and expand depending on mouse over,

for example if the mouse is over Home, then all the other menu items will shrink and the Home item will grow, growing the item works fine when I use .nextFrame();

but the problem is that if I have more than one tween on the same time line for a menu item i.e. one tween for shrinking, another for expanding the .nextFrame(); and prevFrame(); will play all the tweens and that's not what I want therefor I want to use gotoAndPlay(); In my flash file I am right now just testing how this works so I have only one gotoAndPlay(); for shrinking the menu item below the Home menu item on mouse over.

I would like to thank you guys for the time and effort you are spending to solve my problem, thank you very much :)

Attached File(s)


This post has been edited by ayman_mastermind: 01 August 2009 - 11:17 PM

Was This Post Helpful? 0
  • +
  • -

#8 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Problem with gotoAndPLay();

Posted 03 August 2009 - 11:58 PM

bump....
come on guys someone help me, I need to solve this silly problem, I am not yet an expert in flash... thanks :)
Was This Post Helpful? 0
  • +
  • -

#9 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Problem with gotoAndPLay();

Posted 04 August 2009 - 03:09 AM

Nevermind, I worked out a solution for this problem, now gotoAndPlay() works the way i wanted, the problem was from _root.HomePage_mc.onEnterFrame = function() I removed it and used the on(rollOver) and on(rollOt) and put my statements directly under them. Thanks very much for your help BetaWar and gregwhitworth, have a good day, see you around :)
Was This Post Helpful? 0
  • +
  • -

#10 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,605
  • Joined: 20-January 09

Re: Problem with gotoAndPLay();

Posted 04 August 2009 - 10:06 PM

Wow I got credit for help even when I didn't do anything. Awesome!
Was This Post Helpful? 0
  • +
  • -

#11 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Problem with gotoAndPLay();

Posted 04 August 2009 - 10:32 PM

Quote

Wow I got credit for help even when I didn't do anything. Awesome!


No you did, at least you gave a tip to try out, maybe it will come in handy when facing some other problem ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1