Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

communicating with butons in frames inside movieclip

Posted on 2009-07-11
7
Medium Priority
?
252 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
Technology Partners: 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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 what frame rate is, how to control it and what effect it has on the video.

705 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