| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
#1 |
|
Pipty rupees only!
Join Date: Jul 2007
Location: Novosibirsk, Russia
Posts: 1,713
|
Hi guys. Sory if this one belongs to Flex thread, but I decided to post it here.
I meet the problem of extending flex components very often. And as often I put non-children element (skins, decorations, some controls) onto my component. But in most situations I want all those decorations to be under usual children of a component. I can create decorations (let's always call'em so in the thread) inside createChildren() method. This one will make all the decoration to be under children obviously. But classes (style properties), that my decorations are instances of, can change during runtime. In this case I track the change and update graphics inside updateDisplayList() method. I removeChild() my decoration, reinstantiate it, and addChild() again. So eventualy new decoration is upon children. This is bad. I was inventing sevaral "smart" methods of overcoming this, but I'd like to know what techniques you guys use in this case. Any discussion would be appriciated ![]()
__________________
fly high |
|
|
|
|
|
#2 |
|
Site Contributor
Join Date: Jun 2008
Location: Brooklyn
Posts: 311
|
can you post some example code? I'd be curious to know what you worked out with this as well.
|
|
|
|
|
|
|
|
|
#3 |
|
Pipty rupees only!
Join Date: Jul 2007
Location: Novosibirsk, Russia
Posts: 1,713
|
I don't actually have the code near myself at the time. But I can try to describe my last technique I'v noticed for myself to use.
Let's say I have a component, that would have additional decorations. All of them should be upon usual children of my component. 1. inside overriden createChildren() method I add a sort of layer, which is kind of container for decorations ActionScript Code:
2. To knwo exactly, that no child will bubble up and become upon our decorations,lets make some sorta trick ActionScript Code:
3. And finaly inside updateDisplayList() method if some skins updated - i simply reattach them to my decoration style in a desired order. The whole decoration will remain upon children. This code is just a main idea and has much bugs for sure. Since it came from my head right now. But when implementing some exact component - the code will be built according to idea but more accurately. Hope I'm understandable.
__________________
fly high |
|
|
|
|
|
#4 |
|
Site Contributor
Join Date: Jun 2008
Location: Brooklyn
Posts: 311
|
I sort of understand I think. You have a DisplayObject that contains style information you want to apply to all children of your component. You keep it at a specific depth so you can access it later and reapply it to the children if the style changes. Does that sound about right? (Sorry for all the questions. My knowledge of flex is still somewhat limited). If I understand this, why is that you need to have the decorations object at a specific depth? Is that how it bubbles up and sets the styles of other objects automatically? Couldn't you just call setStyle() on them?
|
|
|
|
|
|
#5 | |
|
Pipty rupees only!
Join Date: Jul 2007
Location: Novosibirsk, Russia
Posts: 1,713
|
You understand me right generaly.
Quote:
Also, as for just setting style, you cannot always set a style just because it's possible they don't exist at all. That's what all these things about - to support custom and sofisticated skins styles you have to make some sort of tricks to kepp decorations order correct for you... Wooff... I hope I'm undesrstandable. Sory for my english, it's not my native ![]()
__________________
fly high |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flex/ ActionScript Tile Component | j4kes | Flex 2 & 3 | 6 | 08-26-2008 11:01 AM |
| Access Flex Objects from Flash created component | Selecters75 | Flex 2 & 3 | 1 | 04-28-2008 09:13 AM |
| Passing parameters on initialization of custom flex component? | Daedalus | Flex 2 & 3 | 4 | 02-19-2008 11:01 PM |
| removeMovieClip does not work when a child component is present | Amn | Components | 2 | 08-15-2005 04:18 PM |
| Control child movie from parent movie? | TheJazzMan | ActionScript 2.0 | 6 | 04-29-2005 05:44 PM |