Hi List,
Sorry for the long winded post, but I'm completely baffled by an
exception that my app is throwing involving an allegedly undefined
view state. I have bound the current state of an item renderer
component to an expression that returns one of several possible state
names.
<mx:currentState>{calcCurrentState(Channel(data).syncing, open)}</
mx:currentState>
protected function calcCurrentState (syncing:Boolean,
open:Boolean):String {
return syncing ? 'syncing' : (open ? 'open' : 'closed');
}
Two of the states work without issues, but a third one causes
exceptions. Flex complains that the state is undefined; a claim which
seems to conflict with the evidence:
a. I have stopped the app in the debugger and observed the contents
of the states array (as it should be)
b. Although Flex claims the state is undefined, it then switches to it.
I have tried changing the name of the state, using a different state,
removing the overrides from the state, and several other tests, all
to no avail.
<mx:states>
<!-- These states work fine -->
<mx:State name="closed">
<mx:SetProperty target="{this}" name="height"
value="55"/>
</mx:State>
<mx:State name="open" />
<!-- Flex claims this state is undefined -->
<mx:State name="syncing" basedOn="closed">
<mx:RemoveChild target="{syncBtn}"/>
<mx:AddChild relativeTo="{syncTools}" position="1">
<mx:ProgressBar/>
</mx:AddChild>
</mx:State>
<!-- This test state produces same results -->
<mx:State name="myState"/>
</mx:states>
A stack trace follows, delineated for clarity. It appears that two
state changes are taking place. I'm not sure why that is or if it is
normal.
Thanks for any insights you can offer.
Cheers,
Lach
ArgumentError: Undefined state 'syncing'.
at mx.core::UIComponent/::getState()
at mx.core::UIComponent/::findCommonBaseState()
at mx.core::UIComponent/::commitCurrentState()
at mx.core::UIComponent/setCurrentState()
at mx.core::UIComponent/set currentState()
at MethodInfo-5897()
at Function/http://adobe.com/AS3/2006/builtin::call()
at mx.binding::Binding/::innerExecute()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
at mx.binding::Binding/execute()
at mx.binding::Binding/watcherFired()
at mx.binding::Watcher/notifyListeners()
at mx.binding::PropertyWatcher/eventHandler()
at flash.events::EventDispatcher/
flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/::commitCurrentState()
at mx.core::UIComponent/setCurrentState()
at mx.core::UIComponent/set currentState()
at MethodInfo-5887()
at Function/http://adobe.com/AS3/2006/builtin::call()
at mx.binding::Binding/::innerExecute()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
at mx.binding::Binding/execute()
at mx.binding::Binding/watcherFired()
at mx.binding::Watcher/notifyListeners()
at mx.binding::PropertyWatcher/eventHandler()
at flash.events::EventDispatcher/
flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.couch.emotive.model::Channel/dispatchEvent()
at com.couch.emotive.model::Channel/set syncing()
at com.couch.emotive.commands::SyncChannelCommand/result()
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/
internal::applyResult()
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/
internal::callTokenResponders()
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/
internal::dispatchRpcEvent()
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/
internal::resultHandler()
at mx.rpc::Responder/result()
at mx.rpc::AsyncRequest/acknowledge()
at ::NetConnectionMessageResponder/NetConnectionChannel.as
$31:NetConnectionMessageResponder::resultHandler()
at mx.messaging::MessageResponder/result()