Hi here is a working Code :)
as you see the input to the public function is as you did; String.
but we return a uint, as you see the whole public function is in {}
this is for binding the public function to the backgound.
Cato
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script >
<![CDATA[
public function getColor(swift:String):uint {
if (swift=='1') {
return 0xFFFF00;
} else {
return 0xFFFFFF;
}
}
]]>
</mx:Script>
<mx:Canvas backgroundColor="{getColor('1')}" width="50%"
height="212" x="10" y="10"/>
<mx:NumericStepper id="nStepper" x="10" y="230"
backgroundColor="{getColor(nStepper.value.toString())}"/>
</mx:Application>
--- In [email protected], "oneproofdk" <[EMAIL PROTECTED]> wrote:
>
> Hi Cato!
>
> Thanks for your reply, but I still can't make it work.
>
> The value {myRepeater.currentItem.left.page.swift} is a string (or
is
> it?) it contains a number, either 0 or 1.
> <left><page pageno="22" swift="0"/></left>
> <left><page pageno="22" swift="1"/></left>
>
> I've tryed to do it like you suggest, getColor(swift:uint):uint, but
> with no changes.
>
> public function getColor(swift:uint):uint {
> if (swift==1) {
> return 0xFFFF00;
> } else {
> return 0xFFFFFF;
> }
> }
>
> <mx:Canvas
> backgroundColor="getColor(uint
({myRepeater.currentItem.left.page.swift})"
> width="50%">
>
> The error I get is on the <mx:Canvas> line, "1067: Implicit coercion
> of a value of type String to an unrelated type uint."
>
> Anyone out there that can help me on this issue ?
>
> Thanks in advance.
> Mark
>
> --- In [email protected], "Cato Paus" <cato1@> wrote:
> >
> > Hi use uint for colors like getColor(swift:uint):uint
> >
> >
> > The uint class is primarily useful for pixel color values (ARGB
and
> > RGBA) and other situations where the int data type does not work
> > well. For example, the number 0xFFFFFFFF, which represents the
color
> > value white with an alpha value of 255, can't be represented
using
> > the int data type because it is not within the valid range of the
int
> > values.
> >
> > Cato
>