[flexcoders] Re: Setting the backgroundcolor of a canvas with a function - Newbie alert

2007-01-18 Thread Cato Paus
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 0x00;
} else {
return 0xFF;
}
}

]]
/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 flexcoders@yahoogroups.com, 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.
 leftpage pageno=22 swift=0//left
 leftpage 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 0x00;
   } else {
   return 0xFF;
   }
 }
 
 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 flexcoders@yahoogroups.com, 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 0x, 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





[flexcoders] Re: Setting the backgroundcolor of a canvas with a function - Newbie alert

2007-01-17 Thread oneproofdk
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.
leftpage pageno=22 swift=0//left
leftpage 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 0x00;
} else {
return 0xFF;
}
}

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 flexcoders@yahoogroups.com, Cato Paus [EMAIL PROTECTED] 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 0x, 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




[flexcoders] Re: Setting the backgroundcolor of a canvas with a function - Newbie alert

2007-01-16 Thread Cato Paus
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 0x, 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



--- In flexcoders@yahoogroups.com, oneproofdk [EMAIL PROTECTED] wrote:

 In my first Flex2 app, I'm trying to set the background color of a
 canvas inside a repeater, to a specific color depending on a value 
in
 the datasource.
 
 In my mx:Script I made this function:
 private function getColor(swift:String):String {
if (swift=='1') {
   return '#00'
}else{
   return '#FF'
   }
 }
 
 
 mx:Canvas
 backgroundColor=getColor({myRepeater.currentItem.left.page.swift})
 width=50%
 
 This generates an error in FB when I save :
 1067 - Implicit coercion of a value of type String to an unrelated
 type uint.
 
 I'm pretty sure that I got this all wrong, isn't it possible to use
 the return value directly in the repeater, should I use a var to 
hold
 it - what to do ??
 
 Any help telling me why (and why not) is greatly appreciated.
 
 Thanks,
 Mark