You see that you're declaring clip (and buttons) twice (causing the
error), and as two different types (not causing the error but will cause
another shortly).
Because you want one variable to act as either a Main or Sub, you need
to either cast clip as an abstract version that both of those extend, or
make an interface both of them implement and cast clip as such, or cast
clip as * and forgo any strict typing altogether.
Relevant code only:
var buttons:Array;
var clip:* = e.target;
switch(e.target.buttonType)
{
case 0:
{
buttons = _menuButtons;
break;
}
case 1:
{
buttons = _subMenuButtons;
}
}
Pavel wrote:
Hi List,
I have written a script, here is piece of some method:
private function resetState( e:Event )
{
switch(e.target.buttonType)
{
case 0 :
var clip = e.target as MenuButtonMain;
var buttons:Array = _menuButtons;
break;
case 1 :
var clip = e.target as MenuButtonSub;
var buttons:Array = _subMenuButtons;
break;
}
for (var i:uint = 0; i< buttons.length; i++)
{
if( buttons[i] != clip )
{
buttons[i].enable();
} else buttons[i].disable();
}
The script works as want it to but I keep getting a 3596 - duplicate
variable definition warning, when I run the script. Should I be woried
about this warning message? What is wrong in my code?
Thanks
Pavel
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders