|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Actionscript/Javascript Hide Movie Clip with Buttons
Hi all, and thanks for reading.
I have an embedded Flash movie which I'm manipulating with JavaScript. I basically want to hide certain "layers" which have essentially become groups of symbols in an embedded movie clip. The goal is to hide everything, which worked well using the Alpha property when the symbols in the movie clip were just graphics, but, now that I'm converting them to buttons to add interactivity, it's become problematic: the buttons, although invisible, are still active. Is there some way that I can just outright hide or turn off the movie clip or make each button in that movie clip inactive (without using a for loop) so that these buttons will disappear? Putting an invisible rectangle over it is not an option, as there are many different "layers" and possible combinations that would make it impractical. Thanks in advance. |
|
#2
|
||||
|
||||
|
All symbol objects have an attribute called _visible. You can set that to false to hide something. It's less CPU-intensive than _alpha. I think it also disables the symbol.
Some objects also have an enabled attribute. Disabling a movie clip doesn't disable the objects inside it - you have to disable each object individually. Why don't you want to use a for loop? Here is a recursive function that can disable objects. It was started by me and finished by 'blockage' at www.actionscript.org Code:
function disable(scope:Object, stack:Array):Void
{
// create a stack to avoid circular references
if (!stack) var stack:Array = [];
trace ("SCOPE: "+scope);
var j:Number;
var i:String;
var circular:Boolean;
for (i in scope)
{
if (typeof (scope[i]) == "movieclip")
{
// search the stack to make sure we not looking at a circular reference to an anscestor movieclip
circular = false;
j = stack.length;
while (j--) {
if (scope[i] === stack[j]) {
circular = true;
break;
}
}
// avoid any anscestors
if (!circular) {
trace("scope[name] = "+scope[i]);
trace("I have a movie clip child named "+i);
trace("Disabling: "+scope[i]);
scope[i].enabled = false;
// add this clip to the stack
stack.push(scope[i]);
// recurse down the branch
disable(scope[i], stack);
// done this branch so pop the stack
stack.pop();
}
}
else if (typeof(scope[i]) == "object")
{
if (scope[i].enabled)
{
scope[i].enabled = false;
}
}
}
}
disable(this);
// if called from main timeline, the entire movie will be disabled!
__________________
. Save The Developers! :: How To Ask Questions The Smart Way :: Cheat Sheets :: PHP :: MySQL :: Flash :: 13 Moon Facebook App. My Delicious"All matter is merely energy condensed to a slow vibration. We are all one consciousness experiencing itself - subjectively. There is no such thing as death, life is only a dream. We are the imaginations of ourselves." - Bill Hicks "Truth is hidden in the subtle nature of the heart of everything, although it is invisible. One cannot see it from inside and neither from the surface. One can only live and experience it." - Heart Sutra Last edited by b3n : October 12th, 2006 at 10:29 AM. |
|
#3
|
||||
|
||||
|
Thanks for responding.
I didn't use visibility because I didn't see where you could set that property for the movie clips besides on the actual layer, which I could never figure out how to access in JavaScript. Is there a way to do this, or do I just need an ActionScript to turn off the visibility of the unwanted movie clips when the movie loads? Thanks again. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Actionscript/Javascript Hide Movie Clip with Buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|