Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
ramesh_bh
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

How to change the screen background color ?

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

 

Please use plain text.
Developer
taylortbb
Posts: 137
Registered: ‎10-26-2010
My Device: Bold 9900 + PlayBook
My Carrier: Rogers

Re: How to change the screen background color ?

The background colour is set with HTML notation. You use #FFFFFF or #BBBBBB.

--------
Taylor Byrnes
Please use plain text.
New Developer
ramesh_bh
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Re: How to change the screen background color ?

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 ?

 

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: How to change the screen background color ?

[ Edited ]

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!

 

 

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
New Developer
ramesh_bh
Posts: 47
Registered: ‎11-25-2010
My Device: Not Specified

Re: How to change the screen background color ?

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 ?

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: How to change the screen background color ?

[ Edited ]

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!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
New Contributor
PsykoJ
Posts: 8
Registered: ‎11-18-2010
My Device: Not Specified

Re: How to change the screen background color ?

[ Edited ]

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.

Please use plain text.