11-29-2010 11:00 PM
Hi,
I want to change the background color of the screen, i have used the following code but it doesn't worked out, can anyone help me please
package
{
[SWF( frameRate="30", backgroundColor="0xFFFFFF", width="800", height="600" )]
public class MyDocumentClass extends Sprite
{
public function MyDocumentClass()
{
super();
}
}
}
Even i tried the following
graphics.beginFill(0xBBBBBB, 1);
graphics.drawRect(0, 0, 800, 600);
graphics.endFill();
But melt down, please help
11-29-2010 11:13 PM
The background colour is set with HTML notation. You use #FFFFFF or #BBBBBB.
11-30-2010 12:49 AM
Thanks for the reply, but
[SWF( frameRate="30", backgroundColor="#FFF000", width="800", height="600" )]
didn't worked for me, i want to change the screen color of my PlayBook application.
Please hlep ?
11-30-2010 12:57 AM - edited 11-30-2010 01:30 AM
Hey ramesh,
Try changing the width value to 1024. The width of the playbook screen is actually 1024.
Edit: i tried copy and pasting your exact line:
[SWF( frameRate="30", backgroundColor="#FFF000", width="800", height="600" )]
and it worked fine even before changing the width to 1024 and got a yellow background. maybe you arent inserting that bit of code into the rite place. what is the exact code you are writing for your app?
Edit #2: i just noticed you were missing the Sprite class import in your initial code. copy and paste the following code:
package
{
import flash.display.Sprite;
// The following metadata specifies the size and properties of the canvas that
// this application should occupy on the BlackBerry PlayBook screen.
[SWF(width="1024", height="600", backgroundColor="#FFF000", frameRate="30")]
public class MyDocumentClass extends Sprite
{
public function MyDocumentClass()
{
}
}
}
that should give you a grey yellow background. hope that helps!
11-30-2010 01:39 AM
Here where i am placing the code
[SWF( frameRate="30", backgroundColor="#FFF000", width="800", height="600" )]
public class Page1 extends Sprite
{
var btn:Button = new Button();
var lab:Label = new Label();
page2 = new Page2();
lab.text = "Click";
btn.addChild(lab);
btn.setPosition(10,50);
btn.addEventListener(MouseEvent.CLICK,dothis);
addChild(btn);
stage.nativeWindow.visible = true;
}
}
any help ?
11-30-2010 01:45 AM - edited 11-30-2010 03:11 PM
here is what i pasted in the other thread that seems to pertain to this thread too.
again assuming all your classes are set up this should run:
package
{
//Remember to import all of the classes that you
//are using
import flash.display.Sprite;
import flash.events.MouseEvent;
import qnx.ui.buttons.LabelButton;
// The following metadata specifies the size and properties of the canvas that
// this application should occupy on the BlackBerry PlayBook screen.
[SWF(width="1024", height="600", backgroundColor="#FFF000", frameRate="30")]
public class Page1 extends Sprite
{
private var page2:Page2;
public function Page1()
{
//initiate new object here to use later
page2 = new Page2();
var labButton:LabelButton = new LabelButton();
labButton.label = "Click";
labButton.setPosition(10,50);
labButton.addEventListener(MouseEvent.CLICK,dothis );
addChild(labButton);
//addChild(log); //dont know where you declared this so commented out
stage.nativeWindow.visible = true;
}
//change the event to MouseEvent since that is what you
//are listening for
public function dothis(event:MouseEvent):void {
addChild(page2);
//addChild(log); //dont know where you declared this so commented out
}
}
}
remember to import all your class definitions inlcuding Sprites, Events, etc. also remember whatever event you are listening for you have that same event in your listener. good luck!
11-30-2010 01:07 PM - edited 11-30-2010 01:34 PM
I actually had the same problem before when I first started coding.
I don't think its in the code. What happened was i couldn't get my head around why it wasn't changing so i just copied and pasted the HelloWorld example over and it still didn't work.
I just restarted a new flex application and restarted a new file. Sure enough that did the trick.
It might be a bug, or the application wasn't set up properly. But try starting a new file.
Let me know how it goes.