Solved

communicating with butons in frames inside movieclip

Posted on 2009-07-11
7
244 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now