I made an example with all two sets of buttons.
You can download it and run from Flash and you will see the trace results in output window depending on button who was clicked.
This is a discussion on Button event serious problem : Bug? within the advanced Actionscript 3.0 forums, part of the Flash English category; HELLO guys...I have another problem that I can't solve; I've been trying for two days now. I have two set ...
HELLO guys...I have another problem that I can't solve; I've been trying for two days now.
I have two set of buttons, both sets are on the stage, and both sets are in arrays. However, only one set of buttons receive mouse events. The other set doesn't receive no type of events...this is bs.
but here's the code :
var nextMovie
var buttons_array:Array=[money,assets,luxury,condos];
//---------- loop through the buttons array to set up properties and events
for (var i:int=0; i<buttons_array.length; i++)
{
buttons_array[i].mouseChildren=false;
buttons_array[i].buttonMode=true;
buttons_array[i].id=i;
buttons_array[i].addEventListener(MouseEvent.ROLL_OVER, onRollover,false,0,true);
buttons_array[i].addEventListener(MouseEvent.ROLL_OUT, onRollout,false,0,true);
buttons_array[i].addEventListener(MouseEvent.CLICK, buttonClicked,false,0,true);
}
//---------- the rollover,rollout and buttonclick functions
function onRollover(event:MouseEvent):void
{
event.target.gotoAndPlay("open");
}
function onRollout(event:MouseEvent):void
{
event.target.gotoAndPlay("close");
}
function buttonClicked(event:MouseEvent):void
{
buttonSelected(event.target.id);
if(event.target.name !=nextMovie)
{
nextMovie=event.target.name;
housing.gotoAndPlay("motivate");
//TweenLite.to(percent_mc, 1, {y:287, alpha:1, ease:Circ.easeInOut});
}
}
function buttonSelected(id:int):void
{
for (var i:int=0; i<buttons_array.length; i++)
{
if (i==id)
{
buttons_array[i].gotoAndStop("dock");
buttons_array[i].buttonMode=false;
buttons_array[i].removeEventListener(MouseEvent.ROLL_OVER, onRollover);
buttons_array[i].removeEventListener(MouseEvent.ROLL_OUT, onRollout);
buttons_array[i].removeEventListener(MouseEvent.CLICK, buttonClicked);
} else
if(buttons_array[i].currentLabel !="home")
{
buttons_array[i].gotoAndPlay("close");
buttons_array[i].buttonMode=true;
buttons_array[i].addEventListener(MouseEvent.ROLL_OVER, onRollover,false,0,true);
buttons_array[i].addEventListener(MouseEvent.ROLL_OUT, onRollout,false,0,true);
buttons_array[i].addEventListener(MouseEvent.CLICK, buttonClicked,false,0,true);
}
}
}
//############################### NEXT SET OF BUTTONS
// this is the set that doesn't work at all...
var firstButtons:Array=[ceo,cfo,boss,worker];
for(var j:int=0;j< firstButtons.length;j++)
{
firstButtons[j].addEventListener(MouseEvent.ROLL_OVER,onOver,fals e,0,true);
firstButtons[j].addEventListener(MouseEvent.ROLL_OUT,onOut,false, 0,true);
firstButtons[j].buttonMode=true;
firstButtons[j].addEventListener(MouseEvent.CLICK,imageClicked,fa lse);
//firstButtons[j].mouseChildren=false;
}
function onOver(event:MouseEvent):void
{
TweenLite.to(event.target, 1, {tint:0xffff00});
}
function onOut(event:MouseEvent):void
{
TweenLite.to(event.target, 1, {tint:0xffffff});
}
function imageClicked(event:MouseEvent):void
{
//lastLoaded="graphic";
//gotoAndStop("begin");
trace("the button was clicked");
trace(event.target.name);
}
what's strange is, when i seperate the code and put the code and buttons in seperate .flas, both codes work perfect. But when I put them in the same .fla, only one set of button receive events...this is so bad adobe...why guys?
I can't put themcall the buttons in the same because I need different functions for other stuff down the line....but right now, at this stage, tall buttons should work in one .fla and not just in different .flas...but they don't...I was looking at my as 3 books but didn't found a solution yet...this is advanced to me, so give me some helps guys...PLEASE!!!
any help would be wonderful...
x lisa x
I made an example with all two sets of buttons.
You can download it and run from Flash and you will see the trace results in output window depending on button who was clicked.
Thanks for the reply and .flas. It was very helpful.
x lisa x
I am glad to be useful.
Bookmarks