kingyiren / efflex

Automatically exported from code.google.com/p/efflex
0 stars 0 forks source link

Updated Slide to work with spark--possible bug in org/efflex/spark/viewStackEffects/supportClasses/ViewStackAnimateInstance.as #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am porting an application that uses the Slide effect over to SDK4.5.  My 
ViewStack has NavigatorContent instances as children.  This causes lots of 
problems in 
org/efflex/mx/viewStackEffects/effectClasses/ViewStackTweenEffectInstance.as.  
The nested class (ContainerResizeAndCreator) reaches into Container to examine 
whether the children are completed (mxChild.mx_internal::numChildrenCreated).   
B/c Spark skinnable containers do not inherit from Container, this throws 
errors.

I found the code to separate out that logic in 
org/efflex/spark/viewStackEffects/supportClasses/ViewStackAnimateInstance.as.  
However, there is a subtle error: when forcing the creation of deferred content 
in spark components:

                child = viewStack.getChildAt( index ) as UIComponent;
                if( child is SkinnableContainerBase )
                {
                    sparkChild = child as SkinnableContainer;
                    if( ( !sparkChild.deferredContentCreated && sparkChild.numChildren != 0 ) || !sparkChild.initialized )
                    {
                        _creatingContainers.push( sparkChild );
                        sparkChild.addEventListener( FlexEvent.CREATION_COMPLETE, onContainerCreationComplete, false, 0, true );
                        sparkChild.createDeferredContent();
                    }

a listener is setup for FlexEvent.CREATION_COMPLETE.  Turns out, this event 
will never fire.  Instead, SkinnableContainer will fire 
FlexEvent.CONTENT_CREATION_COMPLETE.

    public function createDeferredContent():void
    {
        if (!mxmlContentCreated)
        {
            mxmlContentCreated = true;

            if (_mxmlContentFactory)
            {
                var deferredContent:Object = _mxmlContentFactory.getInstance();
                mxmlContent = deferredContent as Array;
                _deferredContentCreated = true;
                dispatchEvent(new FlexEvent(FlexEvent.CONTENT_CREATION_COMPLETE));
            }
        }
    }

I've attached my version of ViewStackTweenEffectInstance, which listens for the 
correct event.  (I also reconfigured the creationComplete listener to not 
exclusively expect mx components.) I suspect that ViewStackAnimateInstance.as 
in the spark package will have to be updated as well to reflect the correct 
event being dispatched.  

Original issue reported on code.google.com by sc...@talsma.tv on 22 Apr 2011 at 4:52

Attachments:

GoogleCodeExporter commented 8 years ago
Hi, I have the same problem, can you attach the swc or zip file of your efflex? 
because I have a swc but not the .as

Original comment by 3kg...@gmail.com on 19 Apr 2012 at 5:33

GoogleCodeExporter commented 8 years ago
Here is the source w/my change integrated.

Original comment by sc...@talsma.tv on 19 Apr 2012 at 6:38

Attachments: