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
bdeneau
Posts: 34
Registered: ‎03-23-2011
My Device: Bold 9700
My Carrier: Rogers
Accepted Solution

Alternating row gradient issue

I'm trying to create a "skin" (it's not really) for a table that I'm displaying of records from a database.  I couldn't find a method of displaying the data that I liked so every row is just a bunch of labels.  The first thing I output is a Shape with a gradient fill to skin the row, and I only use it for alternating rows.

 

However, it only works on the first row, then every other row is a solid fill.  What is going wrong here?

 

Here the code snippet:

 

for (var x:int = 0; x < dp.length; x++) {
	if (x % 2 == 0) {
		var matrixRow:Matrix = new Matrix();
		matrixRow.createGradientBox(620, 30, 90/180*Math.PI);
		var grad:Shape = new Shape();
		grad.graphics.clear();
		grad.graphics.beginGradientFill(GradientType.LINEAR, [0xDDDDDD,0xDDDDDD], [0,1], [0,255], matrixRow);
		grad.graphics.drawRoundRect(0, x * 30, 620, 30, 5, 5);
		grad.graphics.endFill();
		container.addChild(grad);
	}

        //etc

 

 

 

 

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

Re: Alternating row gradient issue

hey,

 

try doing this instead:

 

 

for (var x:int = 0; x < dp.length; x++) {
	if (x % 2 == 0) {
		var matrixRow:Matrix = new Matrix();
		matrixRow.createGradientBox(620, 30, 90/180*Math.PI);
		var grad:Shape = new Shape();
		grad.graphics.clear();
		grad.graphics.beginGradientFill(GradientType.LINEAR, [0xDDDDDD,0xDDDDDD], [0,1], [0,255], matrixRow);
		grad.graphics.drawRoundRect(0, 0, 620, 30, 5, 5);
		grad.y = x * 30;
		grad.graphics.endFill();
		container.addChild(grad);
	}

        //etc

 

The graphics package doesnt work exactly how we'd think. its best if you set the position of the object separately. so in your case its working, its just not shifting the drawing for you. 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.
Developer
Brandon_Appetizer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Alternating row gradient issue

Jrab beat me to it. I'll need to stop doing actual work if I want to keep up =)
----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Please use plain text.
New Developer
bdeneau
Posts: 34
Registered: ‎03-23-2011
My Device: Bold 9700
My Carrier: Rogers

Re: Alternating row gradient issue

Thanks. I'm enjoying writing this app but I find the playbook has a bunch of interesting quirks.

Please use plain text.