how to mediate a view manually ?

foodyi's Avatar


08 Jan, 2014 01:28 PM

I have several modules in my flex project, i load them to different panels which could be dragged and dropped in one parent container.
when i want to bring a panel to front, there need to call setElementIndex(panel,numElements - 1 ) function , it will trigger RemoveFromStage and AddToStage Event, which cause mediator call destroy function, and i need reinitialize the mediator.

  1. Support Staff 1 Posted by Ondina D.F. on 11 Jan, 2014 12:30 PM

    Ondina D.F.'s Avatar


    Sorry, I haven't noticed your post until today, because you've marked it as private. Is there any reason you want to keep this discussion private, or have you marked it as such by accident?

    Re-parenting means the view is removed from stage and then added again. So, its mediator is removed and then created again, and, of course, initialize() is called again.
    That shouldn't be an issue for you, unless your mediator is doing more than just adding event listeners in its initialize() method.

    If you want to mediate a view manually, you can do this:

    But, I don't see why that is necessary, because as I said, the re-parented view will have its mediator created automatically.


  2. 2 Posted by foodyi on 17 Jan, 2014 01:15 AM

    foodyi's Avatar

      I had convert this discussion to public, when i pushed this discussion ,i didn't aware i made a private discussion, so sorry.
      I think i found the problem, I new a rsl config file for module when module add to stage, when the depth of module was changed, there will trigger add_to_stage event, then my program reinitialize rsl context for the module and the mediator is also initialized. now i listen creationComplete event to initialize rsl context of module , and it works well.
         sorry for my poor english. another question, when i debug the project , everything works well. but when i use release version of the project, rsl framework always throw a null pointer error.

  3. Support Staff 3 Posted by Ondina D.F. on 17 Jan, 2014 09:56 AM

    Ondina D.F.'s Avatar


    when i debug the project , everything works well. but when i use release version of the project, rsl framework always throw a null pointer error.

    • Try setting the "Framework linkage" to Merged into code, instead of Runtime shared library (RSL) for your modules - under Project- properties - Flex Build Path - Framework linkage

    • If you did not compile your module in the main application, then maybe you should also try to choose "Do not optimize (module can be loaded by multiple applications)" for your module, under Project - Properties - Flex Modules - Edit Module

    I'm using FlashBuilder! Settings may differ in other IDEs


    Let me know how it goes.


  4. 4 Posted by foodyi on 18 Jan, 2014 03:15 PM

    foodyi's Avatar

    hi Ondina
    after i added below compiler arguments :

    the release version of my flex project works well, thanks a lot. btw, without these arguments, debug version of my project also works.
  5. Support Staff 5 Posted by Ondina D.F. on 20 Jan, 2014 12:20 PM

    Ondina D.F.'s Avatar

    You're welcome:)
    Glad to hear that it works.

  6. Ondina D.F. closed this discussion on 20 Jan, 2014 12:20 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