PDA

View Full Version : buttons within movies


jake2008
10-20-2008, 12:06 PM
Hi,

I am creating a menu that involves some buttons to be housed within movie-clips and some within movie-clips and behind masks.

I have searched forums and tutorials looking for the appropriate coding but ave been unsuccessful so far.

Is it possible to control buttons within movie-clips (or movie-clips within movie-clips) through actionscript on the main stage?

And what would be code examples of this technique?

This has me puzzled for quite a while now and would be greatful of any help, thank you

raydowe
10-20-2008, 02:32 PM
In fact, the best practice is to write all your code (except for maybe stop actions) on the main timeline. By keeping all your code in one spot, it is a lot cleaner and easier for others to read.

The syntax for nested clips is as follows.

From the main timeline:

parentname_mc.childbutton_btn.alpha = 0.5;

where parentname_mc is the instance name of the parent clips (or the one who has other clips inside it) and childbutton_btn is the name of the nested clip (or the one who exists within the parent movieclip)

You can also write code on clips or classes, and call it as if it were on the main timeline. For example, you could write the same statement but put the code on the childbutton_btn if you said:

root.parentname_mc.childbutton_btn.alpha = 0.5;
//OR
stage.parentname_mc.childbutton_btn.alpha = 0.5;


Hope that helps :)

atomic
10-20-2008, 03:56 PM
Though beware that the targeted buttons need to be present on stage, if you are to target them in this manner, from the main timeline...

In other words, if the button is only present on frame 5 of the parent movie clip, and you're trying to assign it a handler from the main timeline, while the parent clip is stopped on frame 1, it simply won't work...

jake2008
10-20-2008, 11:51 PM
Thanks very much for your time guys,

That was brilliant, so easy now that I know how, ha ha. I feel a bit stupid.

:rolleyes: