Link to home
Start Free TrialLog in
Avatar of cristobal_ny
cristobal_ny

asked on

communicating with butons in frames inside movieclip

In the _root on the first frame of the timeline I have a script that has two instructions.

there's a button and a movieclip (holder) with a button on the second frame.

when the button is pressed the timeline in the movieclip moves to the second frame. So now with that second button on screen there's a problem that the script is not affecting it (the _root should go to frame 5)

I prefer to have most of my code in the first frame and the only workaround to this problem I'm facing would be to add code inside the nested clips. What's the proper technique?
_root.boton1.onPress = function() {
	_root.holder.gotoAndStop(2);
};
 
_root.holder.boton.onPress = function() {
	_root.gotoAndStop(5);
};

Open in new window

Avatar of TanLiHao
TanLiHao
Flag of Singapore image

I do not understand what you mean but if you can post the whole .fla I would help you fix your problem.
Avatar of cristobal_ny
cristobal_ny

ASKER

thank you for your interest in helping me out
here's the attached sample
experts.jpg
all the scripts in ur single frame would be executed continously..

so when the _root.holder.boton.onPress executes, it will search for the boton symbol.
what you can probably do is.. put in functions on the root.. and on the nested clip, call them..
that way you can have it in one place
first of all you don't need to reference _root because you're already on the root.

then secondly make sure that your clips are on their own layer and that they span the entire timeline where they need to be active.

see example uploaded.
sample.fla.txt
ASKER CERTIFIED SOLUTION
Avatar of TanLiHao
TanLiHao
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you TanLiHao!
your solution is just what I needed.

Just two more questions. In the sample that you uploaded it does not have the :Void that you wrote in the code window. The sample does work very well so I'm just wondering why you included it in the code window.
The :Void means that there are no returning in the functions, as best practice, it's recommended to add :Void everytime the function does not return anything.

I think I may have have forgot to add Void in the sample so I added it in the code window.