PDA

View Full Version : load movie x, set event for x.dataGrid


sneakyimp
04-12-2006, 07:49 AM
i have movie that contains a placeholder movie (product1) for another SWF to be dynamically loaded into using loadMovie(). problem is, there's a dataGrid in the movie i'm loading that i need to assign an onChange event to. i tried this, but i realize my onLoad() function is wiped the minute the other movie gets loaded.

products1.onLoad = function() {
// assign the onclick events and stuff for the datagrid

gridListener = new Object();
gridListener.change = function(evt){
var gs:Object = productDataGrid.selectedItem;
trace('products 1 going to load companions for ' + gs.id);
// loadCompanions(gs.id);
}
productDataGrid.addEventListener("change", gridListener);
}
products1.loadMovie("product_list2.swf");


i was considering defining the code to assign the event handler in my main movie and configuring the code in the movie to be loaded to look for it in its parent once it gets loaded, but the path and scope considerations are making my head spin.

Is there any reliable, elegant way to assign an event handler to a component in a movie that you are trying to load? given that the component won't exist when you are first loading the movie, you can't access it directly.