Hi,

I am getting an issue using States with databinding.
First, here a sample code :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical">
        <mx:transitions>
                <mx:Transition>
                        <mx:Sequence>
                                <mx:Resize target="{appli}" />
                                <mx:Resize target="{rule}" />
                        </mx:Sequence>
                </mx:Transition>
        </mx:transitions>
        <mx:states>
                <mx:State name="state1">
                        <mx:AddChild relativeTo="{appli}">
                                <mx:Button label="state2" 
                                        click="currentState='state2'" />
                        </mx:AddChild>
                        <mx:SetProperty target="{rule}" name="width" 
                                value="{appli.width / 2}" />
                </mx:State>
                <mx:State name="state2" basedOn="state1">
                        <mx:AddChild relativeTo="{appli}">
                                <mx:Button label="base" 
                                        click="currentState=''" />
                        </mx:AddChild>
                        <mx:SetProperty target="{appli}" name="width" 
                                        value="300" />
                        <mx:SetProperty target="{rule}" name="width" 
                                        value="{appli.width / 2}" />
                </mx:State>
        </mx:states>

<mx:VBox id="appli" width="150" borderColor="#FF0000"
borderStyle="solid" horizontalScrollPolicy="off">
        <mx:HRule id="rule" width="{appli.width}" />
        <mx:Button label="state1" click="currentState='state1'" />      
</mx:VBox>
</mx:Application>

Here are some unexpected behaviors :
- When clicking on "State2" button, the HRule width take appli.width
value then resize to appli.width / 2 (as expected). Why does it behave
like it ? "state2" is based on "state1", so HRule width should always
keep its value to "appli.width / 2".
- If I remove the SetProperty rule.width = {appli.width / 2} from
"state2" definition (it should not be necessary if "state2" is based on
"state1"), rule.width = appli.width instead of appli.width / 2 ???
- If I switch the Resize effects order like this :
                                <mx:Resize target="{rule}" />
                                <mx:Resize target="{appli}" />
Same thing, rule.width = appli.width instead of appli.width / 2 (with or
without the SetProperty rule.width in "state2")

I am suspecting that binding in SetProperty MXML tag is applied only
once when switching between states and then the "main" binding (outside
states declaration) override the state settings. In my example, if I
change appli.width after switching to "state1" or "state2", the "main"
binding is applied instead of the SetProperty binding.

Is it a known behavior ? How can I make things work as I was expecting
(override binding in states) ?

Thanks,

-- 
David Rousselie

*********************************
This message and any attachments (the "message") are confidential and intended 
solely for the addressees. Any unauthorised
use or dissemination is prohibited.
Messages are susceptible to alteration. France Telecom Group shall not be 
liable for the message if altered, changed or
falsified.
If you are not the intended addressee of this message, please cancel it 
immediately and inform the sender.
********************************


--
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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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