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

Alpha value for background of a List

Is there any way to set the alpha value only for the background color of the list? I see the list has a global alpha but I didn't find any way to apply transparency only to the background color without affecting all the other elements...

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

Re: Alpha value for background of a List

hey tstark,

 

from the looks of it you cannot change the alpha of the children to be higher than their parent. meaning you can change the alphas to be different but you cannot make it so the child of an object is more "visible" than its parent. so the list's alpha overrides its childrens ability ot be any higher (cell renderer, custom objects within the list). i tried fiddling around with the blendMode property but with no luck either. if theres a work around im interested Smiley Happy

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: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Alpha value for background of a List

You may create semi-transparent list by implementing skin for cell renderer. You will have full power on behave and display of the list.

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Alpha value for background of a List

hey gluth,

 

i tried doing that but it still runs into the child vs parent issue. so the skin itself is the parent of the label or modified label object. so it basically goes :

 

ListObject.alpha > CellRenderer.alpha > label.alpha > any other objects within the cell render.alpha

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
New Developer
Posts: 22
Registered: ‎12-20-2010
My Device: Not Specified

Re: Alpha value for background of a List

JRab, gluth, thank you very much. What about simulating a transparent background using a semi-transparent png image (for example, square black image with black set at 50% transparency), then tile the image on the background of the cell in the draw() function of the CellRenderer? It's not quite the same thing, I know, but it could be a workaround...maybe?

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

Re: Alpha value for background of a List

hey tstark,

 

theoretically that should work. the only potential problem that i can see you running into is the hard coded background of the List and the cell renderer. so say if you do put in an image into the background, the background colors of the list and cell renderer will show up under it. but i think if you can find a way to disable or make the background invisible, it'll do the trick. so far we've covered up the background to make custom colors, havent tried hiding yet. let me know what you find! 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: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Alpha value for background of a List

Hmm, I didn't get any trouble with that technique.

 

ListSkin:

 

    public class ListSkin extends UISkin
    {
        private var selectedSkin:Sprite;
        private var upSkin:Sprite;
        private var upOddSkin:Sprite;
        private var downSkin:Sprite;

        public function ListSkin()
        {
            super();
        }

        override protected function initializeStates():void
        {
            upSkin = new Sprite();
            upSkin.graphics.beginFill(0xFF0000, 0.15);
            upSkin.graphics.drawRect(0, 0, 200, 200);
            upSkin.graphics.endFill();

            upOddSkin = new Sprite();
            upOddSkin.graphics.beginFill(0xFF0000, 0.35);
            upOddSkin.graphics.drawRect(0, 0, 200, 200);
            upOddSkin.graphics.endFill();


            downSkin = new Sprite();
            downSkin.graphics.beginFill(0xFF0000, 0.50);
            downSkin.graphics.drawRect(0, 0, 200, 200);
            downSkin.graphics.endFill();

            selectedSkin = new Sprite();
            selectedSkin.graphics.beginFill(0xFF0000, 0.75);
            selectedSkin.graphics.drawRect(0, 0, 200, 200);
            selectedSkin.graphics.endFill();

            this.setSkinState(SkinStates.UP_ODD, upOddSkin);
            this.setSkinState(SkinStates.UP, upSkin);
            this.setSkinState(SkinStates.DOWN, downSkin);
            this.setSkinState(SkinStates.SELECTED, selectedSkin);
            this.setSkinState(SkinStates.FOCUS, upSkin);
        }
    }

 

 

Excerpt from CellRenderer:

 

public class ListCellRenderer extends CellRenderer {


        override protected function init() : void
        {
            super.init();
            ///more code here, adding fields, images and etc.
            setSkin(ListSkin);

        }

}

And with that code I have transparent background in the list. It was weird, because I have to set skin not on the list, rather on cell renderer. I use above renderer as a skin on the list and it works more than perfect.

 

 

 

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Alpha value for background of a List

hey,

 

nice! thats a good find. and yeah cell renderer only accepts skin objects and list's only accept cell renderer objects. nevertheless great job!

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
New Developer
Posts: 22
Registered: ‎12-20-2010
My Device: Not Specified

Re: Alpha value for background of a List

@JRab, I never tried that sincerely...I was more concerned about the performance of that solution, having a png tiled on the background for each cell could be painful, maybe, on the real device...I cannot check on the emulator about that right now, unfortunately, you know...

 

@gluth...your solution sounds great! I will try it out and check if it works for me but it sounds very promising.

 

Thank you very, very much!

Highlighted
Developer
Posts: 116
Registered: ‎11-18-2010
My Device: BlackBerry PlayBook
My Carrier: null

Re: Alpha value for background of a List

Hi gluth. Really good solution You have provide. But what If I need to implement tweening transition between states? For example tween background from white to blue in case of selection of the item?