tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/74-fp-9016Robotlegs: Discussion 2018-10-18T16:35:10Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-07T13:23:08Z2010-04-07T13:23:08ZFP 9.0.16<div><p>Hi Lewis,</p>
<p>As far as I'm aware, Robotlegs and SwiftSuspenders should work
fine for all versions of Flash Player 9 and 10.</p>
<p>You mention that you are compiling against the source instead of
the SWCs - have you made sure to include the necessary compiler
options for SwiftSuspenders? See: <a href=
"http://github.com/tschneidereit/SwiftSuspenders">http://github.com/tschneidereit/SwiftSuspenders</a>
(under Installation).</p>
<p>Also, a little more info as to what's not working would be
helpful. Is the app running at all? Is it just the traces that are
not coming through? What do you mean by "I don't think there is a
debug player version of this build"?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-12T18:16:00Z2010-04-12T18:16:02ZFP 9.0.16<div><p>Hi Shaun,</p>
<p>Thanks for your reply,</p>
<p>I was wrong about the debug player which I now have
installed.</p>
<p>I had all the right compiler arguments but it still wasn't
working. I have now reverted back to using the SWC's.</p>
<p>I'm using Flex Builder 3 to publish to FP9.0.16 and I get the
following message prior to anything appearing on the screen:</p>
<p><code>TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener() at
mx.core::Container/addEventListener()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:2052]
at
org.robotlegs.base::MediatorMap/org.robotlegs.base:MediatorMap::addListeners()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/MediatorMap.as:233]
at org.robotlegs.base::ViewMapBase/set
contextView()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/ViewMapBase.as:86]
at
org.robotlegs.base::ViewMapBase$iinit()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/ViewMapBase.as:63]
at
org.robotlegs.base::MediatorMap$iinit()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/base/MediatorMap.as:75]
at org.robotlegs.mvcs::Context/get
org.robotlegs.mvcs:Context::mediatorMap()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:152]
at
org.robotlegs.mvcs::Context/org.robotlegs.mvcs:Context::mapInjections()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:197]
at
org.robotlegs.mvcs::Context$iinit()[/Users/shaun/Documents/Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/robotlegs/mvcs/Context.as:76]
at
com.daredigital.barclaycard.bcdbra142::AppContext$iinit()[C:\Users\lewis\Documents\Flex
Builder
3\Lewis\src\com\daredigital\barclaycard\bcdbra142\AppContext.as:11]
at Lewis/Lewis::onCreationComplete()[C:\Users\lewis\Documents\Flex
Builder 3\Lewis\src\Lewis.mxml:23] at
Lewis/___Lewis_Application1_creationComplete()[C:\Users\lewis\Documents\Flex
Builder 3\Lewis\src\Lewis.mxml:7] at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent() at
mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9051]
at mx.core::UIComponent/set
initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:698]
at Function/http://adobe.com/AS3/2006/builtin::apply() at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460]
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403]</code></p>
<p>If I publish to FP10 then all is fine and I don't get this
error</p>
<p>I guess there is some kind of initiation sequence falure within
the flash player itself.</p>
<p>Does this help? If you need anything else then I can send some
code over...</p>
<p>I'm in the process of cutting the app out of the framework but
would be much happier to find a solution to this.</p>
<p>Thanks Muchly<br>
Lewis</p></div>subtronictag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-12T18:28:02Z2010-04-12T18:28:02ZFP 9.0.16<div><p>Could you attach a sample of how you are initializing the
context (in the root of your app)?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-12T18:28:36Z2010-04-12T18:28:36ZFP 9.0.16<div><p>Hi Lewis,</p>
<p>I'm afraid that's a real problem you have there: FP 9.0.16 was
the<br>
first AS3 player to be released and it unfortunately didn't
support<br>
the Event.ADDED_TO_STAGE event that Robotlegs uses for the<br>
auto-mediation feature.<br>
There's really only one thing you can do to still make Robotlegs
(or<br>
any other framework with a similar auto-mediation feature) work
for<br>
your client: Let all views that you want to support auto-mediation
for<br>
dispatch a custom event as soon as they hit the stage (or whenever
you<br>
want auto-mediation to be applied) and another custom event
once<br>
they're removed from stage. Then, change the MediatorMap
(specifically<br>
lines 233, 234 and 245, 246) to listen to those custom events.</p>
<p>BTW, it's really weird that your client still has this
specific<br>
version of the player deployed. That's a really early version of
the<br>
player that was replaced very quickly. Meaning your client was
the<br>
prototypical early adopter back then, but changed to being
really<br>
conservative shortly after installing this player version.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-12T18:36:18Z2010-04-12T18:36:18ZFP 9.0.16<div><p>Oh dear, thanks for clearing that up Till.</p>
<p>Lewis, if you decide to go for the ADDED_TO_STAGE workaround,
you could try this utility:</p>
<p><a href=
"http://github.com/eidiot/robotlegs-utilities-LazyMediator">http://github.com/eidiot/robotlegs-utilities-LazyMediator</a></p>
<p>Might save a bit of time.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-13T14:03:52Z2010-04-13T14:04:18ZFP 9.0.16<div><p>Tell me about the weirdness.<br>
They're a high street bank and its a nightmare to get them to
update any of their systems, I guess it was just coincidence that
they updated to that player and now we have to deal with the
consequences.</p>
<p>Anyway...</p>
<p>... it works!!!</p>
<p>I did a search for all instances of "ADDED_TO_STAGE" (they
appear in 'MediatorMap' 'ViewMap' and also 'Context') and replaced
with "ADDED". As long as I remember to remove each mediated view
directly then all is good.</p>
<p>Thank you both for your inventiveness.</p>
<p>Next time your in London - I'll buy you both a drink!! :)</p>
<p>Lewis</p></div>subtronictag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-13T14:20:31Z2010-04-13T14:24:05ZFP 9.0.16<div><p>PS. For anyone else that reads this and has the misfortune of
having to target FP9.0.16. You need to change the
"REMOVED_FROM_STAGE" to "REMOVED" too as this doesn't dispatch
either.</p>
<p>Cheers<br>
Lewis</p></div>subtronictag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-13T14:39:23Z2010-04-13T14:39:23ZFP 9.0.16<div><p>Hi Lewis,</p>
<p>I'm glad it's working! Keep in mind, though, that you have to be
very<br>
careful when using ADDED: It's dispatched when a view is added to
its<br>
parent, even if that parent itself is not part of the display
list,<br>
yet. If you're not very careful with the order in which you
invoke<br>
your addChild methods, this can lead to views not being mediated
and<br>
to very frustrating debugging sessions.</p>
<p>And thanks for the beer offer! I hope I'll be in Brighton for
FOTB in<br>
the fall - maybe we can work out something Robotlegs-related for
that.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-13T15:37:40Z2010-04-13T15:37:40ZFP 9.0.16<div><p>Hey Lewis,</p>
<p>This is good news, but as Till mentioned, ADDED can cause some
funky, hard to diagnose, behavior. If you plan to stick with this
work-around, I think it's quite important that you document it
loudly - so that anyone who has to do maintenance, or add features,
down the line is aware of it (even if that person is you).</p>
<p>To be honest, I still think that the LazyMediator util might be
a better solution. It's pretty easy/quick to implement and actually
results in better performance for the app. Also, you can use it in
your app without editing the RL framework source; editing framework
code will be problematic when it comes time to upgrade to a newer
version of RL - you'll need to remember to modify those same
files.</p>
<p>Anyhow, just my 2 cents :)</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T15:49:39Z2010-04-14T15:49:39ZFP 9.0.16<div><p>Hey Guys,</p>
<p>You are right I do get some anomalies by doing it this way but
if I use the LazyMediator I get the same error as with using the
MediatorMap but in ViewMap this time even if I comment out all the
code in my MainContext startup block. Also it still has a problem
with "REMOVED_FROM_STAGE" as this doesn't fire either.</p>
<p>Any ideas?</p>
<p>Lewis</p></div>subtronictag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T16:42:07Z2010-04-14T16:42:07ZFP 9.0.16<div><p>Damn, I totally forgot that the LazyMediator util relies on
ADDED_TO_STAGE internally (for some reason I thought it
didn't):</p>
<p><a href=
"http://github.com/eidiot/robotlegs-utilities-LazyMediator/blob/master/src/org/robotlegs/utilities/lazy/LazyMediatorActivator.as#L28">
http://github.com/eidiot/robotlegs-utilities-LazyMediator/blob/mast...</a></p>
<p>What I find crazy is that the code compiles in the first place!
If the ADDED_TO_STAGE constant is not defined for your target the
compiler should throw a compile-time error instead of waiting until
runtime to tell you that ADDED_TO_STAGE is null.</p>
<p>In all honesty, I'm starting to think that you'll need to
mediate your components manually. How many mediators do you have in
your app? Worst case scenario: you'll have to edit out all
references to ADDED_TO_STAGE, turn off auto-mediation (by setting
enabled to false on the MediatorMap), and call
<code>mediatorMap.createMediator(view)</code> for your view
components manually.</p>
<p>I'm really sorry about all this - I was unaware that there was a
version of the Flash Player that didn't support ADDED_TO_STAGE.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T16:58:44Z2010-04-14T16:58:44ZFP 9.0.16<div><p>What I'd do is this:<br>
Let all views you want to mediate extend a base class.<br>
In this base class, use an ENTER_FRAME listener to check if the<br>
"stage" property is defined. Once that's the case, dispatch a
custom event (or, better yet: simply<br>
dispatch "addedToStage", then you don't need to change Robotlegs
at<br>
all).<br>
Then switch to another ENTER_FRAME listener to check for
"stage"<br>
becoming null, upon which you dispatch a custom event or<br>
"removedFromStage". At this point your view isn't on the stage
anymore, so the event won't<br>
be caught by the MediatorMap. Because of that, your Mediator will
have<br>
to listen for it and manually remove itself from the MediatorMap
by<br>
invoking "mediatorMap.unmapView(view)".</p>
<p>I know it all sounds a little complicated, but as long as you
can let<br>
your views extend a base class, it shouldn't be too bad.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T17:07:06Z2010-04-14T17:07:06ZFP 9.0.16<div><p>That sounds like a good approach. There is still the issue of
Event.ADDED_TO_STAGE evaluating to null though (as the original
error message indicates):</p>
<p><code>TypeError: Error #2007: Parameter type must be non-null.
at flash.events::EventDispatcher/addEventListener()</code></p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T17:14:42Z2010-04-14T17:14:42ZFP 9.0.16<div><p>That's why I'd use the actual string: "addedToStage".</p>
<p>I guess what happens with Event.ADDED_TO_STAGE is that the
compiler<br>
adds a lookup of the property "ADDED_TO_STAGE" on the object
"Event".<br>
Since Event is a class and classes are dynamic, the Flash
Player<br>
simply returns undefined instead of throwing an exception, as,
in<br>
fact, Event.ADDED_TO_STAGE is undefined in FP 9.0.16.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T17:22:41Z2010-04-14T17:22:41ZFP 9.0.16<div><p>Yeh, but what I meant was that the RL source is going to fail at
every point where Event.ADDED_TO_STAGE is used. Dispatching the
string "addedToStage" is fine, it's where the framework listeners
are wired up that errors will be thrown.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T17:34:56Z2010-04-14T17:34:56ZFP 9.0.16<div><p>Aah, of course. Dammit, hadn't thought of that. Ok, so Lewis:
You'll<br>
definitely have to change your Robotlegs code. I guess changing
every<br>
instance of "Event.ADDED_TO_STAGE"/ "REMOVED_FROM_STAGE" to<br>
"addedToStage"/ "removedFromStage" and then following the steps
outlined above should do the trick.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-04-14T19:23:25Z2010-04-14T19:23:25ZFP 9.0.16<div><p>Just a thought, what we had to do to get WAMU to upgrade, was
show them the penetration rate of the new player <a href=
"http://www.adobe.com/products/player_census/flashplayer/version_penetration.html">
http://www.adobe.com/products/player_census/flashplayer/version_pen...</a>
and make them aware of the security issues with that particular
player version, header injection, etc</p>
<p>Maybe if you made them aware of that they would upgrade?</p>
<p>Anyways good luck ether way.</p></div>Jason Diastag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-05-06T17:21:51Z2010-05-06T17:21:59ZFP 9.0.16<div><p>Hi Guys,</p>
<p>Back on this project again managed to sort this out thanks to
all your help.</p>
<p>I changed all <code>Event.ADDED_TO_STAGE</code> instances to
<code>"addedToStage"</code> and all
<code>"Event.REMOVED_FROM_STAGE"</code> instances to
<code>"removedFromStage"</code>.</p>
<p>I also did as Till mentioned and added a class to my
AbstractView:</p>
<pre>
<code>package org.robotlegs.utilities.patch
{
import flash.display.DisplayObject;
import flash.events.Event;
/**
* @author lewis.evans@daredigital.com
*/
public class StageEventListener
{
private var view:DisplayObject;
private var alreadyAdded:Boolean = false;
public function StageEventListener(target:DisplayObject)
{
view = target;
view.addEventListener(Event.ENTER_FRAME, checkStage);
}
private function checkStage(e:Event):void {
if(view.stage && !alreadyAdded) {
alreadyAdded = true;
view.dispatchEvent(new Event("addedToStage"));
} else if (!view.stage && alreadyAdded) {
alreadyAdded = false;
view.dispatchEvent(new Event("removedFromStage"));
}
}
}
}</code>
</pre>
<p>Then in my mediator listened for the removed event but unmapView
didn't work so I used
<code>mediatorMap.removeMediator(this);</code></p>
<p>All works fine for me but can you imagine any problems with
this?</p>
<p>Thanks</p>
<p>Lewis</p></div>lewisevanstag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-05-06T17:31:45Z2010-05-06T17:31:45ZFP 9.0.16<div><p>I think that's as good as it can get for automated view
mediation in FP 9.0.16</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-05-06T17:34:05Z2010-05-06T17:34:05ZFP 9.0.16<div><p>Surely those events need to bubble?</p>
<p><code>view.dispatchEvent(new Event("addedToStage",
true));</code></p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/13946932010-05-07T14:53:48Z2010-05-07T14:53:48ZFP 9.0.16<div><p>Er, mine aren't.</p>
<p>Doesn't the framework actually listen to the view
<strong>directly</strong> for ADDED_TO_STAGE events when you
<code>addListeners()</code> in MediatorMap?</p>
<p>This approach does work its just a little messy. Is there not a
way I could add something to the MediatorMap to listen for the
"removedFromStage" event sent from the view automatically as
opposed to adding <code>view.addEventListener("removedFromStage",
unmapView);</code> to each in my mediators?</p>
<p>In fact shouldn't <code>addListeners()</code> automatically add
both directly to the view anyway. Would making the events bubble
sort this out?</p></div>subtronic