The solution was actually simple but took a great deal of digging.

I created a protected function as follows:

        
protected function onLabelCreationComplete():void
{                               
        if ( imageStatus == 'Available' ){
                artPrice.setStyle("color", "0xC39F70");
                artPrice.text = imagePrice;
        }
        else if ( imageStatus == 'Sold' ) {
                artPrice.setStyle("color", "0xED1F04");
                artPrice.text = imageStatus;
        }
        else {
                artPrice.setStyle("color", "0xC39F70");
                artPrice.text = imageStatus;
        }
}

Then I called the function from the Label control:

<s:Label id="artPrice" width="120" textAlign="left"
         fontFamily="Times New Roman" fontSize="18" 
         creationComplete="onLabelCreationComplete()"/>

The setStyle operator resolved the issue completely.

I used your states idea but implemented id using conditional statements.

Thanks for the reply this was helpful.

John


--- In flexcoders@yahoogroups.com, Haykel BEN JEMIA <haykelbj@...> wrote:
>
> I think the best way is to use states. Define the different states for your
> component, e.g.
> 
> <s:states>
>     <s:State name="available" />
>     <s:State name="sold" />
>     <s:State name="other" />
> </s:states>
> 
> You have now to track changes to win.status and set the current state
> accordingly, e.g. by listening to the property change event on win:
> 
> protected function win_propertyChangeHandler(event:PropertyChangeEvent):void
> {
> switch (event.property)
> {
> case "status":
> imageStatus = event.newValue;
> switch (event.newValue)
> {
> case "Available":
> currentState = "available";
> break;
> case "Sold":
> currentState = "sold";
> break;
> default:
> currentState = "other";
> break;
> }
> break;
> }
> }
> 
> and finally set the properties of the artPrice text based on the current
> state:
> 
> <s:RichText id="artPrice" width="120" color="#000000"
> color.sold="#C39F70" fontFamily="Times New Roman" fontSize="18"
> text="{imageStatus}" text.available="{imagePrice}" />
> 
> I hope this helps.
> 
> Haykel Ben Jemia
> 
> Allmas
> Web & Mobile Development
> http://www.allmas-tn.com
> 
> 
> 
> 
> On 30 January 2012 14:55, hermeszfineart <hermeszfineart@...> wrote:
> 
> > **
> >
> >
> > Part of the functionality in the gallery app ia am working on for my wife
> > is a popup window that displays information about the specific painting or
> > drawing.
> >
> > I am trying to figure out how to do the following based on the value
> > returned from the DB for the imageStatus field:
> > 1) Change the text displayed for the Price to the {imageStatus)if that
> > value is anything other than "Available".
> > 2) Change the color of the above text to RED if the {imageStatus) == Sold.
> >
> >
> >
> > <fx:Script>
> > <![CDATA[
> >
> > ... //cut for brevity
> >
> > [*Bindable*] *public* *var* imageTitle:String = *"{win.title}"*;
> >
> > [*Bindable*] *public* *var* imageStatus:String = *"{win.status}"*;
> >
> > [*Bindable*] *public* *var* imagePrice:String = *"{win.price}"*;
> >
> > [
> > *Bindable*] *public* *var* displayPrice:String ;
> >
> >
> >
> > ... // cut for brevity
> >
> > ]]>
> > </fx:Script>
> >
> > <s:Group>
> >
> > <s:layout>
> >
> > <s:VerticalLayout/>
> >
> > </s:layout>
> >
> > <s:RichText id="style" x="13" y="14" width="120" color="#C39F70"
> > fontFamily="Times New Roman" fontSize="18" text="{imageStyle}"/>
> >
> > <s:RichText width="120" color="#C39F70" fontFamily="Times New Roman"
> > fontSize="18" text="{imageMedium}"/>
> >
> > <s:RichText id="dimensions" width="112" color="#C39F70" fontFamily="Times
> > New Roman" fontSize="18" text="{imageHeight} x {imageWidth}"/>
> >
> > <s:RichText id="artPrice" width="120" color="#C39F70" fontFamily="Times
> > New Roman" fontSize="18" text="{imagePrice}" /> <!-- Currently displaying
> > the art's price -->
> >
> > </s:Group>
> >
> > I have tried several things with public functions, getters/setters, but
> > have gotten no where.
> >
> > Could someone kindly point me in the right direction?
> >
> > Thanks,
> >
> > John
> >  
> >
>


Reply via email to