Flex 2
Player r15 (debug version installed by builder)

A repeater is bound to an ArrayCollection. The ArrayCollection is
dynamically updated. Objects are added and removed at runtime. This
works satisfactory. Now I want the removal of an object to trigger an
effect which is much nicer than just removing an item from the screen
with the blink of an eye. So I use the removedEffect in my custom
component.
The code looks something like this.

My custom component (just the bits that are relevant):
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="initApp()"
        currentState="{assistant.availability}" 
        horizontalScrollPolicy="off" verticalScrollPolicy="off"
        creationCompleteEffect="{appear}"  removedEffect="{disappear}">
        <mx:Parallel id="appear" >
                <mx:Fade alphaFrom="0" duration="1000"/>
        </mx:Parallel>

        <mx:Parallel id="disappear" >
                <mx:Fade alphaTo="0" duration="1000" />         
        </mx:Parallel>
</mx:Canvas>

ow the main application with the repeater (again just the relevant bits):

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
        pageTitle="SNS Bank"
        layout="absolute" 
        horizontalAlign="center" verticalAlign="middle" 
        width="800" height="600" 
        creationComplete="initApp()" xmlns:local="*">

        <mx:Script>
                <![CDATA[
                        [Bindable]
                        private var assistants:ArrayCollection = new 
ArrayCollection();
        </mx:Script>

                <mx:Tile height="245" top="29" borderStyle="none"
dropShadowEnabled="false" 
                        width="350" horizontalCenter="0" 
backgroundColor="#FAA54C"
backgroundAlpha="0.05">
                        <mx:Repeater id="rp1" dataProvider="{assistants}"
recycleChildren="true" removed="{disappear}">
                                <local:AssistantRepresentationPanel 
id="assistantPanel"
assistant="{rp1.currentItem}"/>
                        </mx:Repeater>
                </mx:Tile>
</mx:Canvas>


When the removedEffect is defined on the custom component repeated
within the Repeater and an element is removed from the ArrayCollection
the Repeater is bound to, the error with stack trace occurs:

TypeError: Error #1009: Cannot access a property or method of a null
object reference.
        at
mx.effects::EffectManager$/http://www.adobe.com/2006/flex/mx/internal::eventHandler()[C:\dev\GMC\sdk\frameworks\mx\effects\EffectManager.as:547]
        at flash.display::DisplayObjectContainer/removeChild()
        at
mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$removeChild()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:4616]
        at
mx.core::Container/removeChild()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:2324]
        at
mx.core::Repeater/mx.core:Repeater::recycle()[C:\dev\GMC\sdk\frameworks\mx\core\Repeater.as:1049]
        at
mx.core::Repeater/mx.core:Repeater::execute()[C:\dev\GMC\sdk\frameworks\mx\core\Repeater.as:1097]
        at
mx.core::Repeater/mx.core:Repeater::collectionChangedHandler()[C:\dev\GMC\sdk\frameworks\mx\core\Repeater.as:1118]
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.collections::ListCollectionView/dispatchEvent()[C:\dev\GMC\sdk\frameworks\mx\collections\ListCollectionView.as:833]
        at
mx.collections::ListCollectionView/mx.collections:ListCollectionView::removeItemsFromView()[C:\dev\GMC\sdk\frameworks\mx\collections\ListCollectionView.as:1367]
        at
mx.collections::ListCollectionView/mx.collections:ListCollectionView::listChangeHandler()[C:\dev\GMC\sdk\frameworks\mx\collections\ListCollectionView.as:1022]
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.collections::ArrayList/mx.collections:ArrayList::internalDispatchEvent()[C:\dev\GMC\sdk\frameworks\mx\collections\ArrayList.as:518]
        at
mx.collections::ArrayList/removeItemAt()[C:\dev\GMC\sdk\frameworks\mx\collections\ArrayList.as:371]
        at
mx.collections::ListCollectionView/removeItemAt()[C:\dev\GMC\sdk\frameworks\mx\collections\ListCollectionView.as:596]
        at
ProspectCenter/ProspectCenter::removeAssistant()[C:\fds2\jrun4\servers\dev\sns\ProspectCenter.mxml:187]
        at
ProspectCenter/assistantStatusChangeHandler()[C:\fds2\jrun4\servers\dev\sns\ProspectCenter.mxml:144]
        at
ProspectCenter/__assistantStatusConsumer_message()[C:\fds2\jrun4\servers\dev\sns\ProspectCenter.mxml:35]
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.messaging::Consumer/mx.messaging:Consumer::messageHandler()[C:\dev\enterprise_gmc\frameworks\mx\messaging\Consumer.as:943]
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.messaging::ChannelSet/mx.messaging:ChannelSet::messageHandler()[C:\dev\enterprise_gmc\frameworks\mx\messaging\ChannelSet.as:849]
        at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.messaging.channels::NetConnectionChannel/receive()[C:\dev\enterprise_gmc\frameworks\mx\messaging\channels\NetConnectionChannel.as:232]

When stepping through the code in the debugger the error does not
occur. Meaning that the breakpoint is set at the point where an
element is removed from the ArrayCollection the Repeater is bound to.
Can anyone verify this behaviour?

Brgds,
Eduard





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to