A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Event Listeners Disappearing?

  1. #1
    New
    Join Date
    Feb 2010
    Location
    St. Louis
    Posts
    6

    Exclamation Event Listeners Disappearing?

    I am using Adobe Flash Professional CS4 with all the latest updates. The FLA is an Actionscript 3.0 file.

    I am creating a basic flash site with several pages that change when the user clicks links on a left side navigation bar. on the pages are sub tabs that change out different content(text) based on what the user clicks on the current page. when they click a button it triggers an event listener, the event listener runs its function which changes the definition of an already defined (String) variable, and the page goes on to a frame checks what that variable is and then leads the movie to the correct frame that the corresponding content is on.

    here's the issue: it works perfectly the first few times, and then the event listeners stop working, first one of them, then all three once i click one of the two available.

    i started this site before i even knew what a class was(regretably), and all the code is on the timeline in different frames.

    {{{{{{code from the first frame of the content section:}}}}}}

    //stops the movie and assigns event listeners to the buttons if another internal page is not selected by the user
    if(page != "default")
    {
    gotoAndPlay("connectContentClose")
    }
    else if(connectTab == "connect")
    {
    play()
    }
    else if(connectTab == "ideazine")
    {
    play()
    }
    else if(connectTab == "consultation")
    {
    play()
    }
    else{
    {
    stop();

    Connect_Title_btn.addEventListener(MouseEvent.CLIC K, connectSubConnect);
    function connectSubConnect(evtObj:MouseEvent):void
    {
    connectTab = "connect";
    trace("clicked connectSubConnect");
    play();
    Connect_Title_btn.removeEventListener(MouseEvent.C LICK, connectSubConnect);
    }

    Ideazine_Title_btn.addEventListener(MouseEvent.CLI CK, connectSubIdeazine);
    function connectSubIdeazine(evtObj:MouseEvent):void
    {
    connectTab = "ideazine";
    trace("clicked connectSubIdeazine");
    play();
    Ideazine_Title_btn.removeEventListener(MouseEvent. CLICK, connectSubIdeazine);
    }

    Consultation_Title_btn.addEventListener(MouseEvent .CLICK, connectSubConsultation);
    function connectSubConsultation(evtObj:MouseEvent):void
    {
    connectTab = "consultation";
    trace("clicked connectSubConsultation");
    play();
    Consultation_Title_btn.removeEventListener(MouseEv ent.CLICK, connectSubConsultation);
    }
    }
    }


    {{{{{{code from the frame after that}}}}}}

    if(connectTab == "connect")
    {
    play();
    }
    else if(connectTab == "ideazine")
    {
    gotoAndPlay("ideazineTabStart");
    }
    else if(connectTab == "consultation")
    {
    gotoAndPlay("consultationTabStart");
    }

    {{{{{code from the frame where the content is showing}}}}}}

    if (connectTab != "connect")
    {
    play();
    }
    else
    {
    gotoAndPlay("connectTabOpen");
    }


    after this are the "ideazine" tab section and "consultation" tab section; the code is the same except replace "connect" with either "ideazine" or "consultation"

    If this doesnt give anyone a clear idea, i can host the problem part of the file somewhere so you can see exactly whats going on with it, but im almost sure its a simple problem which is elementary and im just a newb who needs to learn a lot more.

    thanks

  2. #2
    New
    Join Date
    Feb 2010
    Location
    St. Louis
    Posts
    6

    site

    ...
    Last edited by PaperStreetPub.; 02-26-2010 at 10:32 PM.

  3. #3
    New
    Join Date
    Feb 2010
    Location
    St. Louis
    Posts
    6
    I figured it out. Here's the solution if event listeners are disappearing.
    When you create an instance of an object and give it a name it is a single item on the timeline. I was making the buttons animate by deleting the buttons and replacing them with a movieclip that was the exact copy of the button(so that the user couldnt click on it while it was animating. i guess few would even try so that concern seems a little thoughtless in retrospect), and then once the animation was done i deleted the movieclip and put the button back on the stage. when i put the button back on the stage, even though it was an instance of the same button mentioned earlier and it had the same instance name, the fact that it was not on the stage for a few frames disabled the event listener because there was nothing to listen to. when i put the button back on the stage, the event listener wasnt there anymore. Creating new event listeners for every time an instance shows up gets messy fast, so instead of changing it to a movieclip i kept the button there and animated it just the same.
    Last edited by PaperStreetPub.; 02-28-2010 at 05:03 PM.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center