|
|
|
[
Permlink
| « Hide
]
Joan Lafferty - [01/09/08 12:32 PM ]
reproduced in build 127. Sending to IRB.
Ok, I have the framework fix. Unfortunately, the workaround isn't that great. SystemManager/Application have a complex way of starting up, and unfortunately, this was copied into WindowedSystemManger/Window but wasn't done 100% correctly.
In normal circumstances (non-SystemManager/Application), when a child is added we call addingChild(child), $addChild(child), and childAdded(child). $addChild is the Flash addChild method. The other two methods are bookkeeping and do some extra stuff (childAdded is the method that ends up calling createChildren()) For SystemManager/Application, SystemManager is the top-level class, and we want to add Application as a child to that class. Normally, we would do: addingChild(child), $addChild(child), and childAdded(child); however, this is a special case, and we don't do it that straight-forward (perhaps for performance reasons, though I'm not 100% sure that's still the case today). Instead, we do: addingChild(child), childAdded(child), and then later after all the children have been created, we add it to the Flash display list with $addChild(child). WindowedSystemManager tried to copy this functionality over; however, it's not quite right. What actually happens is: 1. addingChild(child) 2. childAdded(child) 3 addChild(child) -- should be $addChild(child) Step #3 in turn calls addingChild(child), $addChild(child), and childAdded(child), which is why createChildren() gets called twice. Ok, so that's the problem. The workaround is to: 1. Extend WindowedSystemManager and add $addChild(child) as a method that just calls super.child(child). This is needed so we can call this method later on. 2. When you extend Window, the place where WindowedSystemManager is created is in Window.commitProperties(), so what you need to do is override this method (without calling super.commitProperties, which means you'll have to look at super.commitProperties() and copy all that stuff too and everything it's dependent on -- not just in Window.commitProperties() but all the way up the class hierarchy chain since we cannot call super.super.commitProperties()). However, change 2 things. Change where the WIndowedSystemManager is created to the class you created in step #1. Also change sm.addChild(this) to sm.$addChild(this), so we don't get the extra calls to addingChild(child) and addChild(child). I wish it was easier, but unfortunately it's not. The other option for the workaround is to monkeypatch Window and copy all the code, changing commitProperties() as needed. This way you don't have to worry about copying all of the super.commitProperties() stuff and all it's dependent on. Again, not really a great workaround.
The workaround I can think of sucks (I've asked Gordon to take a look to see if he can think of anything else). However, the fix inside the framework code isn't that bad. Talked to Gordon. We can't think of a simple, realistic workaround. We both think this is a fundamental problem because it affects component livecycle and should be fixed in the framework.
PFR - cyclone has been provided, tested and approved.
Verified in build 249. createChildren only gets called once.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||