The first thing I tried, I thought would be obvious. I opened up the Skin.fla file I was referencing, found the instance names and figured something like myMovie.layout_mc.volumeMute_mc would work. So:
myMovie.layout_mc.volumeMute_mc.onRelease = function(){
trace("Clicked Mute!");
}
Nothing.
So more searching found that everything is actually in a movieClip called skin_mc. Who knows how someone found this, but oh well.
myMovie.skin_mc.layout_mc.volumeMute_mc.onRelease = function(){
trace("Clicked Mute!");
}
Still nothing.
So after a lot of research, testing things that didn't work, etc., I came across this website. Basically, this page lets us know how to access some captioning properties inside of a skin. So I adjusted some of the code to fit my need, and came up with this:
var listenerObject:Object = new Object();
listenerObject.skinLoaded = function (eventObject:Object):Void {
eventObject.target.skin_mc.volumeMute_mc.onRelease = function (){
trace("Clicked Mute!");
}
}
myMovie.addEventListener("skinLoaded",listenerObject);
Worked! (please see update)
One of these days I'll take a class or something so I actually know what all this means. ;)
So now if you want to use a mute button, or play button, or the seekbar to go to frame 4, or open another browser, or just annoy people, you can.
Update:
Yikes. This doesn't work as expected. Doing this, now the buttons don't work. Your new action triggers, but now the mute doesn't mute and play doesn't play. I found that all of them have "button_mc" inside of them, but going deeper and referencing that movieClip, now my little trick doesn't work. Back to the drawing board...
Update:
Okay, so I think I got this working. Seems like the problem was, my code was either blocking the other event from firing or there was a child/parent issue, so the actual buttons for mute and play were never receiving the event in order to do their jobs. So if you use onMouseDown, and make sure you use a hitHest so it knows you're over the movieClip you want to click, you can do it. onMouseDown isn't a button event, but you can use it as one without it being a true button event, limiting the conflicts.
var listenerObject:Object = new Object();
listenerObject.skinLoaded = function (eventObject:Object):Void {
eventObject.target.skin_mc.volumeMute_mc.onMouseDown = function (){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
clickedText.text = "Mute Clicked";
}
}
eventObject.target.skin_mc.playpause_mc.onMouseDown = function (){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
clickedText.text = "Pause-Play Clicked";
}
}
eventObject.target.skin_mc.back_mc.onMouseDown = function (){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
clickedText.text = "Rewind Clicked";
}
}
eventObject.target.skin_mc.forward_mc.onMouseDown = function (){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
clickedText.text = "Fast Forward Clicked";
}
}
}
myMovie.addEventListener("skinLoaded",listenerObject);
I'll keep working with it, but at this point, it looks like I can use my muteButton to control whatever I want.
No comments:
Post a Comment