Solved

communicating with butons in frames inside movieclip

Posted on 2009-07-11
7
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

624 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