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
Developer
Posts: 117
Registered: ‎12-03-2010
My Device: Not Specified
Accepted Solution

simulator Beta 2 auto scale bug ?

[ Edited ]

Hi,

 

My application layout correctly on Simulator version 1.

I just setup the new version of Simulator and the same application is no more layout correctly.

 

I found out that my LabelButton too close the right edge and the simulator version 2 seems automatically scale to shrink my layout to make the button no more too close to edge.

 

Not sure anybody has such problem ?

 

code like:

 

var b:LabelButton = new LabelButton();

b.x = 896;
b.y = 8;
b.width = 120;
b.height = 47;

 make my entire layout shrink.

However, try to setup  b.x = 850; no more shrink...

 

This happen only on the right edge, not the left edge .....  ??!!

 

 

 

Developer
Posts: 117
Registered: ‎12-03-2010
My Device: Not Specified

Re: simulator Beta 2 auto scale bug ?

[ Edited ]

Mmm.... if you just create a HellowWorld and add the label button as my previous message,

everything works fine. I should create a demo program to show the real issue.

 

All right, here is the simple HelloWorld to create the issue, please try the code and let me know if you have the same problem as I had.  Thanks.

 

 

	[SWF(width="1024", height="600", backgroundColor="#F4F4F4", frameRate="30")]
	public class HelloWorld extends Sprite
	{
		public function HelloWorld()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			var sprite:Sprite = new Sprite();
			var shape:Shape = new Shape();
			shape.graphics.beginFill(0xff0000);
			shape.graphics.drawRect(0, 0, 1024, 600);
			shape.graphics.endFill();
			sprite.addChild(shape);
						
			var b:LabelButton = new LabelButton();
			b.x = 896;
			b.y = 8;
			b.width = 120;
			b.height = 47;

sprite.addChild(b); sprite.x = 0; sprite.y = 0; sprite.width = 1024; sprite.height = 600; addChild(sprite); } }

 

The red background sprite should cover 1024x600 entire screen, but due to label button, it shrink.

Is this my code problem?  or Simulator problem ?

 

Thanks.

 

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: simulator Beta 2 auto scale bug ?

hey,

 

from what has happened to me in the past, applying a specific width and height to a sprite will cause a resize to all of its children. so take out the these lines:

 

 

sprite.width = 1024;
sprite.height = 600;

 

after that run your program. the width and height should be the same because of the shape object. hope that clears things up. 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
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: simulator Beta 2 auto scale bug ?

I don't claim to know what's going on with that, but if you comment out even just the "sprite.width = 1024" part it "fixes" it.

 

Of course, you don't actually need half of that code, if you're just trying to put a button on a red background. 

 

For one thing, Sprites have a Graphics property too, so there's no need to add a Shape to a Sprite just to get a Graphics pane to draw on.

 

And since your main class extends Sprite, you don't even need to add a second Sprite. Just draw on the graphics property of your main Sprite, and add the LabelButton directly to it.

 

That would get it down to just this code (after setting the stage properties):

 

graphics.beginFill(0xff0000);
graphics.drawRect(0, 0, 1024, 600);
graphics.endFill();

var b:LabelButton = new LabelButton();
b.x = 896;
b.y = 8;
b.width = 120;
b.height = 47;
addChild(b);

 I realize this was just an example, and agree it appears to demonstrate a bug or, at least, a mysterious behaviour that may be explainable by someone else (e.g. JRab who just posted), maybe someone with deep knowledge of the Flash display list stuff.

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 117
Registered: ‎12-03-2010
My Device: Not Specified

Re: simulator Beta 2 auto scale bug ?

Hi,

 

Thanks all for the reply. Yes, it is just a demo to show the problem. My real application is, of course, more complex than that.

 

I do know the extends Sprite class has it owns graphic and can draw on it.

But my class is so "mess" with many graphic drawing and add many children and then some strange behaviors happen again. That's why for all drawing stuff, I try to use Shape and make them all as child instead of directly drawing on itself. ( I know, this will grow display tree and  may hurt performance .... )

 

Just like this sprite.width tips, like you, I really have no idea what's going wrong.

Especially, set sprite.width = 1024; it just works fine on Simulator #1, but not #2 ?!

 

Anyway, I am lack the deep knowledge of Sprite drawing ( relayout, repaint ... etc ) mechanism, this seems like a bug for me now;  I will try get more Flash drawing knowledge later.  Got to finish my app first.

 

Thanks again!