View Full Version : Change State of a component

05-29-2007, 04:37 AM
I am using TileList component and have created a component that will load in the Tile List using itemRenderer. I have two state for my component and I want those two state to work from my main file, which is not working. When I am using click="currentState='secondLevel'" in the component file it is working fine.

But the same code is not working when I am using it (suppose in a button) in the main file.

05-29-2007, 02:27 PM
I might not be ver clear. Let me explain it briefly.

Let's say in my main appliction, I have a component X and in the main file, I have a button Y. I want to change the state of X when I click the button Y
can this be done?


05-29-2007, 05:05 PM
This doesn't work?

<mx:YourCustomCoponent id="comp"/>
<mx:Button click="comp.currentState='secondLevel'"/>

05-30-2007, 05:56 AM
Thanks Dr_Zeus!

It is working fine :)

05-30-2007, 11:36 AM
I more question. How can I use this when I am using HorizontalList.

I am not getting any scope to provide its ID anywhere like you have used:

<mx:YourCustomCoponent id="comp"/>
<mx:Button click="comp.currentState='secondLevel'"/>

For HorizontalList I am using:

<mx:HorizontalList id="myList"
itemRenderer="myComponent.Thumbnail" />

05-30-2007, 04:43 PM
Can you elaborate? I don't understand what you want to do with the HorizontalList.

05-31-2007, 04:10 AM
The final thing that I want to do is drag n drop.

Suppose there are two HorizontalList in my canvas. Thre first Horizontal List is populated with Image, price and description using XML file.

I simply want to Drag the items from first Horizontal List and drop it to the second one. Till now everything is working fine.

The next thing I want is to do is change the state of the Item so that I could see only Image and price and no description in the second Horizontal List. Basically add to cart sort of thing.

I don't know whether I am using a right procees while using State?