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
mstawick
Posts: 48
Registered: ‎06-24-2010
My Device: Storm 2
Accepted Solution

Create custom component that scales

Hi all,

 

maybe I can't think of proper question, but I can't find anything on this.

 

I have created a custom component by extending UIComponent. Inside I have Bitmap, TextField, Shape. For now width is fixed.

 

Now, I would like my component to always take 100% width of Container that I put it in, and based on width calculate height. I'd like everything to stay same size (ie. no Bitmap scaling), except that width of TextField and Shape should be adjusted - depending on parent Container width.

 

Should I add some listeners to parent, or override my component methods? I'm totally lost here. 

 

Thanks!

michal

Developer
Brandon_Appetizer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook

Re: Create custom component that scales

I'm not sure what the best way to go about this would be. Certainly, you could listen for an ADDED_TO_STAGE event and size the objects accordingly, but this way would not be able to automatically resize if the parent changed sizes.

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#event...

 

I suppose you could do a quick check on the ENTER_FRAME event to determine if the parent changed sizes and resize accordingly.

 

 

Anyone else have an opinion?

----------------------------------------
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
Developer
mstawick
Posts: 48
Registered: ‎06-24-2010
My Device: Storm 2

Re: Create custom component that scales

Thanks for suggestion.

 

My structure is like this: ScrollPane ( Container ( N*MyComponent) )

 

For now whenever size of ScrollPane / Container changes, I itereate over it's children and if it's my component I call MyComponent.onResize() method. But this doesn't feel correct.

 

 

Developer
CoCopia
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)

Re: Create custom component that scales

Setup a custom event in the scroll pane, and the Container and bubble the event through to your components.

 

i.e. the scrollpane triggers your custom event to the container custom event which triggers the event to your custom components.

Keep the Forum productive and useful for all. Click Kudos button if I've helped you. Select Solved to help everyone.

PlayBook qualifying app - Pandoras' Lights
Blog - CoCopia.co.uk Catch me on Twitter cocopia_apps
Developer
mstawick
Posts: 48
Registered: ‎06-24-2010
My Device: Storm 2

Re: Create custom component that scales

Thanks. Just to be sure, when you write "Setup a custom event in the scroll pane, and the Container" you mean that I have to extend them and add dispatchEvent(...) where necessary, right?

Developer
CoCopia
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)

Re: Create custom component that scales

yes, this way then only the components you wish to resize do, and you dont need to itterate overthem.

Keep the Forum productive and useful for all. Click Kudos button if I've helped you. Select Solved to help everyone.

PlayBook qualifying app - Pandoras' Lights
Blog - CoCopia.co.uk Catch me on Twitter cocopia_apps