Topic: opaqueBackground
Hello! I'm completely new to flash and have been trying to build some sample code for my chumby using FlashDevelop. I got a hang of the basics and was trying something when I faced this issue.
I want to change the background color of my widget based on some event. I realised that using the opaqueBackground works but only behind the textfields that are created, not the complete screen. The widget is configured for 320x240, background(#FFFF00, yellow), 2fps. Here is the sample code:
class Main
{
private static var _i:Number;
public static function main() : Void
{
_i = 0;
_root.createTextField("t", _root.getNextHighestDepth(), 0, 20, 320, 100);
var tf:TextFormat = new TextFormat();
tf.size = 32;
tf.align = "center";
_root.t.text = "Hello, world!";
_root.t.setTextFormat(tf);
_root.onEnterFrame = function () {
Main.myOnEnterFrame();
}
}
public static function myOnEnterFrame():Void
{
_i++;
if (_i > 20) _root.opaqueBackground = 0x00FFFF;//change to light blue color
}
}
I expect the complete screen to change to light blue color after 10s(20 frames) because I am changing the background of _root. Instead only the area behind the t textField changes to light blue and the remaining screen remains yellow. I'll try to post screenshots if possible. A few questions:
1. Is this the right way to create textFields? In my actual project I need 3 textFields which I plan to create using _root.createTextField(<name>, _root.getNextHighestDepth(),...
2. Is this the right way to change background color? As I understand this is a more efficient way than beginFill/endFill which I have not yet tried.
Hope some experts can help me.