PDA

View Full Version : Dynamic enabled MovieClip


rien100moi
03-15-2005, 05:00 PM
I have a function :

function setVisible(obj):Void {
if (getProperty(obj, _visible) == false) {
for (i=0; i<table.length; i++) {
tutu = "carte_mc."+table[i].clip;
setProperty(tutu, _visible, false);
carte_mc[table[i].clip].enabled = false; // this line doesn't work
}
setProperty(obj, _visible, true);
}
}
I'd like when a movieclip is visible, it is enabled, when it's unvisible, it's disabled.
I'd like with this function to disabled all MC when I click on one.
All MC's are in "carte_mc[table[i].clip]" but i don'k know what's the problem.

I also try to do : setProperty(obj, enabled, false) but this property is unavailable with setProperty.

If you have another solution...
Thanks in advance.

Barn
03-15-2005, 06:55 PM
What's the content of the array and what's the content of clip?

You do not need to disable a button that has had its _visible property set to false; doing so automagically disables the button.

Also, if the following assumes you are sending an actual object reference to the function, not a string.

function setVisible(obj):Void {
if (!obj._visible) {
for (i=0; i<table.length; i++) {
// could be any one of these three depending on
// the datatype of the array element and "clip".
carte_mc.table[i].clip._visible = false;
carte_mc[table[i]].clip._visible = false;
carte_mc[table[i].clip]._visible = false;
}
obj._visible = true;
}

rien100moi
03-15-2005, 07:51 PM
I think my problem is because I don't put onPress function on my clips but I make a hitTest.
I have to find a solution to disable this.

Barn
03-15-2005, 11:03 PM
Ah, yes, that would certainly make a difference.

You could add a conditional to your hitTest that, besides the hitTest expression also checks to see if this._visible (which will be either true or false, so no comparison operator is required).