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
EraserX
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified
Accepted Solution

scale9Grid and images

I am trying to scale9grid an image.  I am using the following code.

 

			[Embed(source="assets/images/frame.png",
				scaleGridTop="5", scaleGridBottom="10",
				scaleGridLeft="5", scaleGridRight="10")]
			var paneFrame:Class;
			
			var frame:Image;
			/*  Add the border */
			frame = new Image();
			frame.setImage(new paneFrame);
			frame.height = 300;
			frame.width = 300;
			addChild(frame);

 

 

When I do this, I get an empty screen.  The image in question measures 15x50 pixels.

 

To note when I just remove the scaling parameters from the embed code, the image displays (all pixelated of course)

 

 

		[Embed(source="assets/images/frame.png")]
			var paneFrame:Class;
			
			var frame:Image;
			/*  Add the border */
			frame = new Image();
			frame.setImage(new paneFrame);
			frame.height = 300;
			frame.width = 300;
			addChild(frame);

 

Has anyone used scale9grid on a image successfully?

 

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

Re: scale9Grid and images

hey EraserX,

 

try using the following code:

 

 

			[Embed(source="assets/images/frame.png",
				scaleGridTop="5", scaleGridBottom="10",
				scaleGridLeft="5", scaleGridRight="10")]
			var paneFrame:Class;

			var myContainer:Sprite = new Sprite();
			var frame:Sprite = new paneFrame();
			myContainer.addChild(frame);
			frame.width = 300;
			frame.height = 300;
			
			var myBitmapData:BitmapData = new BitmapData(300,300);
			myBitmapData.draw(myContainer);
			addChild(new Bitmap(myBitmapData))

 

i've looked around an apparently you have to add your image to a sprite first and then draw that sprite out as the source. something to do with non-transformable sources. and i used the Bitmap class instead of the image. im not a fan of the QNX image class yet but im warming up to it :smileyhappy:

 

 

here is the link to a good deal of info related to scale9grid:

 

http://www.dreaminginflash.com/2007/12/03/9-slice-and-bitmap/

 

hope that helps. 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
EraserX
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Re: scale9Grid and images

Thanks JRab!  I don't have experience working with bitmaps, so your example is definitely going to help!  Also there aren't any other posts (that I could find) on this forum on scale9grids with bitmaps/images so I"m sure lots of other people will find it helpful too.

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

Re: scale9Grid and images

hah no problem at all! yeah i agree scale9grid info is scarce compared to other things around here. but one reason for that is prolly that scale9grid is a grey area from what i've read about it so far in AS3. it basically doesnt do what logically makes sense. people feel it should do one thing but it really does another. but as with all things intangible there are workarounds :smileyhappy:

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