Solved

communicating with butons in frames inside movieclip

Posted on 2009-07-11
7
248 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:cristobal_ny
7 Comments
 
LVL 14

Expert Comment

by:TanLiHao
ID: 24833075
I do not understand what you mean but if you can post the whole .fla I would help you fix your problem.
0
 

Author Comment

by:cristobal_ny
ID: 24834400
thank you for your interest in helping me out
here's the attached sample
experts.jpg
0
 
LVL 7

Expert Comment

by:kishoregp
ID: 24837660
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Expert Comment

by:blue-genie
ID: 24837816
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
0
 
LVL 14

Accepted Solution

by:
TanLiHao earned 500 total points
ID: 24837950
I am not sure if blue-genie have offered you the solution you want but anyway here is what I interpreted.

Blue-genie's example requires you to have the button named in frame 1 too of holder.

However my example allows you to have boton in frame 2 ,which is in your original example. Therefore when you press the first button, it will cause the holder to go to frame 2.

Then on the holder's frame 2, boton can be pressed and the main timeline will go to frame 5.

I believe this is what you want to achieve.

All code in frame 1.

See the code below or attached file for the code.

If you are using the code snippet, replace the code in your script layer in frame 1 to the code shown.


I have moved the text box with target text  a bit more up so boton will not cover it when you go to frame 5.

boton1.onPress = function():Void {
	holder.gotoAndStop(2);
	holder.boton.onPress = function():Void {
		gotoAndStop(5);
	};
};

Open in new window

experts.fla.txt
0
 

Author Comment

by:cristobal_ny
ID: 24841368
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.
0
 
LVL 14

Expert Comment

by:TanLiHao
ID: 24847730
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.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question