Why would a Mediator not receive an event from a View?

jansensan's Avatar


24 Feb, 2012 05:04 PM

Hello, I have been working with RobotLegs for a while now, and for the first time I encounter something I cannot understand. In a view, I dispatch an event to which the Mediator listens, however that event seems to only be able to happen once. It's a show / hide menu action depending on what happens in the video player.

The VideoBoard.videoExpandCollapseEventHandler() function gets called properly, then I want to dispatch to the mediator so that the appropriate model can be updated. Every trace within that function work, but in the mediator, it can happen only once, and never after. Is there something that removes the listener from the mediator without me requesting it?

Below is an excerpt of my code. Any help is appreciated!

// VideoBoardMediator.as (the mediator)

override public function onRegister():void
    // map events
    eventMap.mapListener    (   eventDispatcher, 
    eventMap.mapListener    (   view, 
    eventMap.mapListener    (   view, 

    // init view
    view.scale = configModel.scale;
    view.resize(configModel.width, configModel.height);

    // add videos
    var i:uint;
    var numLoops:uint = videoBoardModel.numVideoVOs;
    var vo:VideoVO;
    for(i = 0; i < numLoops; i++)
        vo = videoBoardModel.videoVOs[i];
        view.addVideo(vo.id, vo.imageURL, vo.vimeoId, vimeoAppService.API_KEY);

private function stateModelUpdatedHandler(event:StateModelEvent):void
    if(stateModel.currentState == State.VIDEOS)

private function dispatchExpandVideo(event:VideoPlayerEvent):void
    trace("\n", this, "---  dispatchExpandVideo  ---");

private function dispatchCollapseVideo(event:VideoPlayerEvent):void
    trace("\n", this, "---  dispatchCollapseVideo  ---");

// VideoBoard.as (the view)

private function videoExpandCollapseEventHandler(event:VideoPlayerEvent):void
    trace("\n", this, "---  videoExpandCollapseEventHandler  ---");

    var video:MultiTouchVideoPlayer = event.target as MultiTouchVideoPlayer;
    var duration:Number;
    var onCompleteFunction:Function;

    var params:Object = {};
    params.scaleX = 1;
    params.scaleY = 1;
    params.onCompleteParams = [video];
        case VideoPlayerEvent.EXPAND_TO_FULLSCREEN:
            _collapsedVideoX = video.x;
            _collapsedVideoY = video.y;
            _collapsedVideoRotation = video.rotation;

            duration = 0.45;
            params.x = _width * 0.5;
            params.y = _height * 0.5;
            params.width = _width;
            params.height = _height;
            params.rotation = 0;
            params.onComplete = videoExpandComplete;
            trace("dispatch expand");
            dispatchEvent(new VideoPlayerEvent(VideoPlayerEvent.EXPAND_TO_FULLSCREEN));

        case VideoPlayerEvent.COLLAPSE_FROM_FULLSCREEN:
            duration = 0.33;
            params.x = _collapsedVideoX;
            params.y = _collapsedVideoY;
            params.rotation = _collapsedVideoRotation;
            params.onComplete = videoCollapseComplete;
            trace("dispatch collapse");
            dispatchEvent(new VideoPlayerEvent(VideoPlayerEvent.COLLAPSE_FROM_FULLSCREEN));
    TweenMax.to(video, duration, params);

Showing page 2 out of 2. View the first page

  1. 31 Posted by jansensan on 24 Feb, 2012 11:49 PM

    jansensan's Avatar

    Holy crap that was it!!!!!

    I suspect that the amount of created stuff with both Tuio (the multitouch library) and and loading the Vimeo stuff might have caused my listeners to get collected.

    Wow, you complete my week so well! Thanks so much! I would so pay you a drink if I were in the same town!

  2. Support Staff 32 Posted by Ondina D.F. on 24 Feb, 2012 11:51 PM

    Ondina D.F.'s Avatar

    I tried to add just the VideoBoard to the stage to see what’s going on in there, but I can’t make it work right now.
    I guess I’m already tired, so I should go to bed.
    I’m sure Shaun will find the culprit :)

  3. 33 Posted by jansensan on 24 Feb, 2012 11:53 PM

    jansensan's Avatar

    Yea he did, thanks both of you for spending so much time with me on this! :) I owe you!

  4. Support Staff 34 Posted by Ondina D.F. on 24 Feb, 2012 11:55 PM

    Ondina D.F.'s Avatar

    Wow! Shaun said that in his first post actually;)
    Glad you fixed it!!
    And you're welcome:)

  5. Support Staff 35 Posted by Shaun Smith on 24 Feb, 2012 11:57 PM

    Shaun Smith's Avatar

    Glad to be of assistance. Bear in mind however that the solution (forcing strong references) is really just a hacky fix - there is a problem somewhere, and when you have the time you should try to get to the bottom of it (break points everywhere!).

    I'll delete your attachment. Also, I think we can leave this thread as Private as we didn't actually resolve the issue, so I don't think it will be helpful to anyone in the same boat.

    Glad you're back on track. Have a good weekend :)

  6. Support Staff 36 Posted by Ondina D.F. on 26 Feb, 2012 02:14 PM

    Ondina D.F.'s Avatar

    Looking at your code with fresh eyes.


    private function initContext():void
        var c:SlideshowSS12Context = new SlideshowSS12Context(this, true);

    Not only your VideoBoardMediator, but all your other rl classes don’t work any more after a while, because your context gets gc-ed.

    private var context:SlideshowSS12Context;

    private function initContext():void

    context= new SlideshowSS12Context(this, true);


    Problem: Things Work For A While And Then Mysteriously Stop

    Solution: Hang on to your context!!!!

    Try this and let us know how it works :)


  7. 37 Posted by jansensan on 27 Feb, 2012 03:35 PM

    jansensan's Avatar

    Yes, yes you were right! :) I removed the strong references that Shaun suggested and that indeed prevents the context from being collected, nice thinking! I should have thought of that, I just never faced such an issue :) Thanks again for spending so much time to help me!

  8. Support Staff 38 Posted by Ondina D.F. on 27 Feb, 2012 04:34 PM

    Ondina D.F.'s Avatar

    Oh, no problem. Glad you can continue developing your nice app:)

  9. Ondina D.F. closed this discussion on 27 Feb, 2012 04:34 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac