PDA

View Full Version : Does setBGColor work?


cmcginnis
08-12-2004, 02:05 PM
Tried to do this in one of the editor windows within the tutorial section of your site. After it loads the color appears correctly (red). After executing the method, the color is turned to black instead of blue.

Any ideas?

Here is the sample code:

<canvas width="500" height="150" >
<view name="square" bgcolor="#ff0000" width="30" height="30" clickable="true" onclick="this.changeColor()">
<method name="changeColor">
this.setBGColor("#0000ff");
</method>
</view>
</canvas>

antun
08-12-2004, 02:07 PM
I think you need to use the JavaScript hex number syntax:
this.setBGColor(0x0000ff);


... setting a color to a string "#0000ff" will probably make it go black, since in JavaScript, a string will convert to 0 unless it begins with a numeric character.

-Antun

cmcginnis
08-12-2004, 02:14 PM
I tried the follow to no avail...


<canvas width="500" height="150" >
<view name="square" bgcolor="0xff0000" width="30" height="30" clickable="true" onclick="this.changeColor()">
<method name="changeColor">
this.setBGColor("0x0000ff");
</method>
</view>
</canvas>

antun
08-12-2004, 02:16 PM
Are there any warnings with the debugger? I think you need to drop the the quotes. In JavaScript, 0xff0000 means "in hex ff0000".

-Antun