flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Lantier (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-33740) Change UIComponent function removedFromStageHandler from private to protected to allow override
Date Fri, 20 Sep 2013 14:51:52 GMT

    [ https://issues.apache.org/jira/browse/FLEX-33740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13773041#comment-13773041
] 

David Lantier commented on FLEX-33740:
--------------------------------------

Hello Justin, I'm coming back with news.

First, I've implemented an override as proposed first (named "removedFromStageOverride") and
implemented in 2 classes, one written in MXML, an "s:Vgroup" composed by a lot of components
(named ModelView, about 80 children added dynamically), another written in AS3 class that
extends NavigatorContent. For the test, each "NavigatorContent" has a ModelView as child and
a TabNavigator for parent.

Then, I've programmed 100 addChild of NavigatorContent, which created also 100 ModelView,
followed by 100 removeChild (that remove also the 100 ModelView as they quit the stage), then
I've repeated this cycle a lot to take times and memory. 

After that, I've done the same tests, but based on events, not on override. 

And, you are right … performances are the same between override and listening events (about
28 seconds for one cycle with override, 29 seconds with events, not significant for me). Also,
I've discovered that it was not a good idea to override removedFromStage, because we do not
take advantage of the event flow manager (we can be called twice by ovveride, when we receive
only one event).

For all these reasons, I think that my request … is a bad request ;-) We all should rely
on event flow to manage UIComponent livecycle (added/removed from stage). I was convinced
that override could be simpler and faster than event listening, but it is not.

Thanks a lot for attention and your answers!

Here, for example, the helper class I use in composition to manage live cycle events, with
an interface (IwhpGuiLivecycle) for callbacks. 

private function waitCreationComplete( wdo:DisplayObject ):void {
CONFIG::debugging { 
if( ! ( wdo is IWhpGuiLivecycle ) ) 
throw new Error( wdo + " is not IWhpGuiLivecycle" ); 
}
wdo.addEventListener( FlexEvent.CREATION_COMPLETE, wdo_creationCompleteHandler );
}
		
// ===== handle events
		
private function wdo_creationCompleteHandler( event:FlexEvent=null ):void {
var ect:Object = event.currentTarget;
ect.removeEventListener( FlexEvent.CREATION_COMPLETE, wdo_creationCompleteHandler );
ect.addEventListener( FlexEvent.REMOVE, wdo_removedHandler );
ect.addEventListener( Event.REMOVED_FROM_STAGE, wdo_removedFromStageHandler );
IWhpGuiLivecycle( ect ).thisStageOn( true );
}
		
private function wdo_addedToStageHandler( event:Event=null ):void {
var ect:Object = event.currentTarget;
ect.removeEventListener( Event.ADDED_TO_STAGE, wdo_addedToStageHandler );
ect.addEventListener( Event.REMOVED_FROM_STAGE, wdo_removedFromStageHandler );
ect.addEventListener( FlexEvent.REMOVE, wdo_removedHandler );
IWhpGuiLivecycle( ect ).thisStageOn( false );
}
		
private function wdo_removedHandler( event:Event=null ):void { 
var ect:Object = event.currentTarget;
ect.removeEventListener( FlexEvent.REMOVE, wdo_removedHandler );
_isRemoved = true;
}
		
private function wdo_removedFromStageHandler( event:Event=null ):void { 
var ect:Object = event.currentTarget;
ect.removeEventListener( Event.REMOVED_FROM_STAGE, wdo_removedFromStageHandler );
ect.addEventListener( Event.ADDED_TO_STAGE, wdo_addedToStageHandler );
IWhpGuiLivecycle( ect ).thisStageOff( _isRemoved );
_isRemoved = false;
}

                
> Change UIComponent function removedFromStageHandler from private to protected to allow
override
> -----------------------------------------------------------------------------------------------
>
>                 Key: FLEX-33740
>                 URL: https://issues.apache.org/jira/browse/FLEX-33740
>             Project: Apache Flex
>          Issue Type: Improvement
>          Components: .Unspecified - Framework
>    Affects Versions: Apache Flex 4.10.0
>         Environment: Gui framework
>            Reporter: David Lantier
>            Assignee: Justin Mclean
>              Labels: features, performance
>             Fix For: Apache Flex 4.11.0
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> It would be more safe and faster if it was possible to override the function UIComponent::removedFromStageHandler
(and also, remove) instead to have to add and remove events listeners for those who extends
UI classes. 
> Have to check if new proposed method name "removedFromStage" not used by any component,
or choose another.
> Example:
> private function removedFromStageHandler(event:Event):void
>     {
>         _systemManagerDirty = true;
> 	removedFromStage();     // proposition: add this call
>     }
> // proposition: new function protected, dedicated to override
> /** Override this allow to be called when this is removing from stage. Avoids to have
to listen REMOVED_FROM_STAGE event. */
> protected function removedFromStage():void {}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message