Ignore this part in the initial testComponent2:
creationComplete="{this.currentState = 'study';}"
It is irrelevant to the question.

-Davy

On Thu, Nov 6, 2008 at 2:16 PM, Davy Strube <[EMAIL PROTECTED]>wrote:

> I've got a weird error in Flex 3.0.0 I can't figure out:
> how to add states to a component.
>
> I looked up this problem in google, and found sites saying I need to change
> the namespace of the "states" object if the new components have their own
> new namespace, but what if I'm getting this error without making a new
> namespace for the components?
>
> Let's say I have two simple components (1 & 2) referenced in a simple
> Application (3):
> 1- testComponent1.mxml:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
>     width="100%" height="100%">
>     <mx:Label text="label 1"/>
>     <mx:Button id="button1" label="goto tc2" click="{this.
> parentApplication.currentState='testComponent2'}"/>
> </mx:HBox>
>
> 2- testComponent2.mxml:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
>     width="100%" height="100%"
>     creationComplete="{this.currentState = 'study';}" >
>     <mx:Label text="label 2"/>
>     <mx:Button id="button2" label="goto tc1" click="{this.
> parentApplication.currentState='testComponent1'}"/>
>  </mx:HBox>
>
> 3- testMain.mxml:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute" xmlns:local="*"
>      currentState="testComponent1">
>     <mx:states>
>         <mx:State name="testComponent1">
>             <mx:SetProperty target="{viewStack}" name="selectedIndex"
> value="0" />
>          </mx:State>
>         <mx:State name="testComponent2">
>             <mx:SetProperty target="{viewStack}" name="selectedIndex"
> value="1" />
>         </mx:State>
>     </mx:states>
>     <mx:ViewStack id="viewStack" width="100%" height="100%" >
>         <local:testComponent1 id="tc1" />
>         <local:testComponent2 id="tc2" />
>      </mx:ViewStack>
> </mx:Application>
>
> =================
> Compiles fine, works perfectly.
>
> If I click the button in tc1, I go to tc2; and vice versa.
>
> Now, for whatever reason, I want to add a state in tc2:
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
>     width="100%" height="100%"
>     creationComplete="{this.currentState = 'mystate1';}" >
>
>     <mx:Label text="label 2"/>
>     <mx:Button id="button2" label="goto tc1" click="{this.
> parentApplication.currentState='testComponent1'}"/>
>
>     <mx:states id="mystates">
>         <mx:State name="mystate1">
>         </mx:State>
>         <mx:State name="mystate2">
>         </mx:State>
>     </mx:states>
>
> </mx:HBox>
>
> ====================================
> Error: "*Could not resolve <mx:states> to a component implementation*"
>
> What the heck?
>
> If I change     <mx:states id="mystates"> to     <local:states
> id="mystates">
> the error becomes
> "*The prefix "local" for element "local:states" is not bound*"
>
> When I put this in the HBox tag:
> xmlns:local="*"
> then the error becomes:
> "*Type was not found or was not a compile-time constant: states.*"
>
> Am I missing something, or going about this the wrong way?
>
> Please help.
> Thanks!
> -Davy Strube
>



-- 
Davy Strube
Synapse Analytics
1000 Abernathy Rd, Ste. 1010
Atlanta, GA 30328

770-401-1542 (c)
678-389-4739 (o)



-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to