Solved

communicating with butons in frames inside movieclip

Posted on 2009-07-11
7
247 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

791 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