A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] dynamically loaded MovieClip won't bubble Events

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    2

    resolved [RESOLVED] dynamically loaded MovieClip won't bubble Events

    Hi there!

    I ran into a really strange problem today.

    I'm dynamically loading an swf with several MovieClips and an "exported for ActionScript" MovieClip holding several Sub-Movieclips.

    Code:
    mcl = new Loader();
    mcl.contentLoaderInfo.addEventListener( Event.COMPLETE, caveloadcomplete);
    
    ...
    
    function caveloadcomplete(event : Event) : void {
      var mc:MovieClip = MovieClip( mcl.content );
      MovieClip(mainstage["bgh"]).addChild(mc);
      var appDomain:ApplicationDomain =
    	mcl.content.loaderInfo.applicationDomain;
      var maclass:Class = Class(   appDomain.getDefinition("movearea") );
      cavemas = new maclass();
      mainstage.moveareaholder.addChild( cavemas );
    }
    So far, so easy, works like a charm (please mind I only post the relevant codeparts for readability).

    Now for the strange Part: if I try to do the following:
    Code:
    cavemas.addEventListener( MouseEvent.CLICK, moveclick );
    exactly *nothing* happens. No click events. If I try it this way:
    Code:
    cavemas["n2"].addEventListener( MouseEvent.CLICK, moveclick );
    It produces every single Click Event correctly (n2 is one of cavemas Sub-Movieclips). So it really looks like the MouseEvent doesn't bubble.

    If I just copy the whole "cavemas" clip to the loading clip, it also works as intended, so I suppose it has got something to do with the dynamic loading and adding of the clip.

    If I couldn't explain this clear enough, I found a guy having exactly the same problem, but in another Forum: http://www.actionscript.org/forums/s....php3?t=180594

    Any help would be highly appreciated, thank you in advance for your time!

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,358
    Could be a security domain issue. Events aren't allowed to bubble through different security domains. Try enforcing the same security domain for the loaded content.

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    I don't import swfs a lot these days but I believe each swf has it's own "root" which would catch all bubbling...you might try a manual bubbler at the top-level of the loaded swf. (Someone please correct me if I'm remembering this wrong)

  4. #4
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    Location
    Naperville,IL
    Posts
    489
    have you tried:
    cavemas["n2"].parent.addEventListener( MouseEvent.CLICK, moveclick )?

  5. #5
    Junior Member
    Join Date
    May 2007
    Posts
    2
    senocular, I tried your pointer, and it was exactly that: I tried to do this in the Debugger (local file domain), but loaded the files from a (again local) webserver (network domain, even though its 127.0.0.1). When switching to loading via File system, it worked like a charm!

    Thank you all for your help!
    Last edited by craftyfirefox; 08-22-2008 at 03:21 AM.

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