views:

23

answers:

1

Hi, I have a Canvas (lets call it the Drop Box) which users can drag and drop external files onto. Next to this I have a ViewStack, of which one of the layers is a Canvas with a TileList. I have successfully managed to code it so that the items dropped onto the Drop Box appear in the TileList. I simply capture the darg drop event (lets call this event A) and dispatch a new one that the TileList is listening for (lets call this event B).

However, this only works if the ViewStack selectedIndex is set to that of the Canvas with the TileList. If the Canvas with the TileList isn't selected then the event listener which is added to the TileList at CreationComplete level (event B), won't be called until after the drag drop event has dispatched (event B). This means that something is firing before something even has a chance to listen for it!

I've tried looping until the Canvas with the TileList is completely drawn, but this causes the app to hang.

I've also tried passing the event to the Canvas and storing it locally, but when I attempt to access the clipboad of the event I get an error (dead clipboard).

Effectively I want to only dispatch the event to the Canvas after it's had a chance to load, and add the event listener to the TileList.

Any ideas? :)

+1  A: 

Maybe setting creationPolicy="all" for View Stack will help? All it's children will be created at startup.

Maxim Kachurovskiy
Brilliant, works a treat thanks. If I have multiple containers in the stack will it decrease performance?
Craig Myles
Also - what does the attribute "creationIndex" do? I can't find any documentation for this online.
Craig Myles
`creationIndex` is used only with `creationPolicy="queued"` - http://www.adobe.com/livedocs/flex/2/langref/mx/core/Container.html#creationIndexPerformance will decrease for sure. But if they are "slim", you will not notice that.
Maxim Kachurovskiy
Excellent, thanks for the information.
Craig Myles