A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: any ideas about my addEventListener problem?

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Posts
    104

    any ideas about my addEventListener problem?

    Hi, I have what I think is a very unusual problem with the addEventListener. I have used it successfully on a few projects, so I am not that new to this function. When I run test movie it works perfectly (even buttonMode works), but when I run test movie on the parent movie it does NOT work. BTW, the addEventListener in question is a sub movie to the main movie. What is odd is that other eventListeners in this sub movie are working.

    below is the code that is in the sub movie timeline.. the movie "mytestbtn" is not even getting the buttonMode=true. The mytestbtn is in a layer of that movie. I tried mytestbtn.visible=false, and sure enough it was not visible. I really don't believe it is this code, I think there might be something else going wrong because as I said, simply testing this movie it works fine.. only when it is loaded into the main movie does it stop working.

    mytestbtn.buttonMode=true;
    mytestbtn.addEventListener(MouseEvent.CLICK, tryagainx);
    function tryagainx(evt:MouseEvent):void {
    gotoAndPlay(1);
    }



    mytestbtn.addEventListener(MouseEvent.ROLL_OVER, rolloverx);
    function rolloverx(evt:MouseEvent):void {
    trace("i got rolled over");
    mytestbtn.gotoAndStop(2);
    }

    mytestbtn.addEventListener(MouseEvent.ROLL_OUT, rolloutx);
    function rolloutx(evt:MouseEvent):void {
    mytestbtn.gotoAndStop(1);
    }

    Maybe my question would be better asked if there is something that can cause an eventlistener to stop working, besides the obvious, ie removal of the eventlistener.

    Thanks for any help with this one..

    Jim
    Jim Booth

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Posts
    104
    I thought I would add a little more information. I am convinced this issue is not about the addEventListener. Because even when I just try to add buttonMode to the button it does not respond.

    I guess i just feel there is something that prevents the actionScript from working. Also, no errors are displayed. It is as if it just disregards the code.
    Jim Booth

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    22
    If your adding a movie to a parent movie, then your code would have to look like this

    PHP Code:
    ParentMovie.TargetMovie.addEventListener(MouseEvent.CLICKfunctionHere
    of course this is assuming your calling from the root timeline. I need to know what timeline your writing your code in before I can help you any further? Also remember that if your adding MovieClips to other MovieClips you have to now call your target MovieClip through it's parent MovieClip.
    Last edited by enlight311; 05-27-2010 at 04:39 PM.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    104
    I probably wasn't clear. I have my root movie swf. it calls the sub movie swf into it, which happens to be a learning activity. At the end of the learning activity, you proceed in the sub movie to the score or results screen (within the sub movie). I physically placed a movie clip on the stage. And that is the object that I seem unable to put an addEventListener. When I test the sub movie it works perfectly, and the addEventListener works, as well as the "buttonMode" code. But when the sub movie is playing inside the root movie, it doesn't work. Although, everything else does.
    Jim Booth

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    22
    So basically there is a Child SWF being loaded into the parent SWF, and when you try to execute code in the child SWF (already loaded in the parent ), the event listeners you have added into the child will not work, is that right??

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Posts
    22
    Now (and maybe you answered this already?) when the Child(already loaded in the parent) is playing can use use any of the code in it? because you mentioned that when you play the child SWF by itself everything works, so I'm interested in finding out if ANY of it works at all once loaded in the parent? Also make sure that there is nothing like invisible buttons or masks that reside above where the Child SWF is being loaded into, I have ran into obstructions before.

  7. #7
    Senior Member
    Join Date
    Jun 2001
    Posts
    104
    yes, you are following pretty good.. the child swf works good outside of the parent.. and the child swf also partly works inside.. it imports xml and parses it out.. it builds a scrolling field with buttons and listeners using the addchild.. it tracks the score, and imports jpgs, does some randomization of an array.. then when the activity is completed it navigates to a frame which has the movieclip on it. I have tried the addEventListener both in the movieclip and on the timeline.. but no luck.
    Jim Booth

  8. #8
    Junior Member
    Join Date
    Dec 2007
    Posts
    22
    Quote" it navigates to a frame which has the movieclip on it. I have tried the addEventListener both in the movieclip and on the timeline.. but no luck."

    ok I got ya, So tell me this, Once the current frame is on the frame where this MovieClip resides what is the event listener listening for? And what what is the event listener function supposed to do once it's called by the event?

  9. #9
    Senior Member
    Join Date
    Jun 2001
    Posts
    104
    the code above is what i wanted to do.. and i put a trace in the frame to verify that the frame was getting navigated to.. and it was.. But basically, all i wanted the button to do is replay the swf, ie let the student take the course again.
    Jim Booth

  10. #10
    Senior Member
    Join Date
    Jun 2001
    Posts
    104
    Well, I fixed it, but not sure I can explain it clearly. On frame 45 there were two movie clips. One was just a background, the other was the movie clip that I wanted to add the event Listener to. I found that if i moved the movie clip to a frame before frame 45 the button would work, but when it got to 45 it would stop working. I deleted the background movie clip and everything started working. I put the movie clip back on the stage and it still kept working. There was not any code or listeners associated with the backdrop. It was just a graphic symbol movie clip. I have been working in flash since version 2 and I have never seen anything like this. I have had a corrupt object in the library, but nothing like this.. something that prevented a listener from activating. very weird. Thanks enlight for trying to figure out the issue. It helped just knowing someone was thinking about it. I spend 8 hours on this and I don't know how I could have figured it out any sooner.
    Jim Booth

Tags for this Thread

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