-
Controlling a movie clip from another movie clip
Hi, I've having problems refering to a movie clip from other nested movie clip.
I've got a list of links nested in a movie clip named "link_list_mc", and I've got a movie clip that simulates a radio equilizer nested in another movie clip named "central_control_mc".
Both mcs are directly on the stage. As you can see I can reproduce the music of my links but I cannot put to play the movie equilizer. My question is, how could I send an order (like in this case: stop() or play()) to a movie clip from another movie clip?.
Ive been using:
root.central_control_mc.equilizer.stop()
parent.central_control_mc.equilizer.stop().
but neither of them seem to work.
This is the code in the first frame of my nested movie clip "list_links_mc".
Code:
var mySecondChannel:SoundChannel = new SoundChannel();
//click_cl01_al01.addEvent..."click."..click_cl01_al01
function click_cl01_al01(evt:MouseEvent):void
{
//Music
SoundMixer.stopAll();
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("file_01.mp3");
snd.load(req);
mySecondChannel = snd.play(0, int.MAX_VALUE);
//this is the line that is having me problems
central_control_mc.equilizer_mc.play();
}
Thanks for any insight on this one.
-
You didn't say how your attempts didn't work. If we knew what error messages you were getting, it would be easier to figure out what is wrong. Given your attempts, the error you were probably getting was something about "possibly undefined" or "no such property" central_control_mc. That would be because neither root nor parent (being typed as DisplayObject and DisplayObjectContainer respectively) define such a property. If you cast to MovieClip or your document class, you could make that work. Assuming that those properties exist.
But don't do that. Instead of having your links clip control your equalizer clip directly, just have it dispatch an event. The document class instance (main timeline) will listen for that event, and that will tell the equalizer what to do. That way, your list doesn't care where the equalizer is, or even that it exists.
Code:
function click_cl01_al01(evt:MouseEvent):void{
//Music
SoundMixer.stopAll();
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("file_01.mp3");
snd.load(req);
mySecondChannel = snd.play(0, int.MAX_VALUE);
dispatchEvent(new Event("soundPlaying", true));
}
in the main timeline:
Code:
addEventListener("soundPlaying", soundPlayHandler);
function soundPlayHandler(e:Event):void{
central_control_mc.equilizer_mc.play(); //you know you misspelled equalizer, right?
}
Also, from your comment it looks like you have an instance and a function both named click_cl01_al01 in the same scope. You can't do that. Change one of them.
-
Yes 5TonsOfFlax it throws an “possibly undefined” error. But I don’t care about it anymore!!!! thanks to you. Of course an event dispatcher was the solution (I’m pretty newbie with AS3).
I’ve got equalizer well spelled by now (Sorry, English isn’t my mother language as you can see).
"click_cl01_al01" was "click_cl01_al01_btn" actually.
Man you've nailed it, thank u very much, it works like a charm. Have a great a day!!!.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|