+ Reply to Thread
Results 1 to 4 of 4

Button event serious problem : Bug?

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 ...

  1. #1
    Junior Member Settled In xPINKMERCEDESx is on a distinguished road
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Button event serious problem : Bug?

    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

  2. #2
    Junior Member Settled In corinahaloiu is on a distinguished road
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Re: Button event serious problem : Bug?

    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.
    Attached Files

  3. #3
    Junior Member Settled In xPINKMERCEDESx is on a distinguished road
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Re: Button event serious problem : Bug?

    Thanks for the reply and .flas. It was very helpful.

    x lisa x

  4. #4
    Junior Member Settled In corinahaloiu is on a distinguished road
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Re: Button event serious problem : Bug?

    I am glad to be useful.

+ Reply to Thread

Similar Threads

  1. Problem with Event.MOUSE_LEAVE
    By Jayer in forum advanced Actionscript 3.0
    Replies: 2
    Last Post: 15-12-09, 05:45
  2. Problem with MC button
    By ramin_85 in forum advanced Actionscript 3.0
    Replies: 1
    Last Post: 04-05-09, 05:32
  3. button problem
    By laurens2020 in forum Actionscript 3.0 newbies
    Replies: 1
    Last Post: 26-04-09, 22:26
  4. Problem with Button
    By xsimaker in forum HELP free utilities
    Replies: 9
    Last Post: 06-10-08, 06:00
  5. Listbox event problem
    By alan247 in forum Flash English
    Replies: 2
    Last Post: 29-05-08, 10:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts