PDA

View Full Version : accessing object in child movie clips


treefield
02-06-2003, 06:54 PM
I am currently trying to access Flash UI component specifically a list box (instance name is ViewsListBox) that is in a movie clip (instance name is views_mc) that is loaded on to the main movie clip as follows...

//MAIN MOVIE
//create movie clip for views list
createEmptyMovieClip("views_mc",10);
with(views_mc){
_x = 160;
_y = 35;
}

views_mc.loadMovie("viewsListBox.swf");

views_mc:ViewsListBox.addItem(localData.data.portL istArray[1][index], localData.data.portListArray[0][index]);

This isn't working... no items are being added to the list box although portListArray has data. I have also tried...

_root.views_mc.ViewsListBox.addItem(localData.data .portListArray[1][index], localData.data.portListArray[0][index]);

and

_level0.views_mc.ViewsListBox.addItem(localData.da ta.portListArray[1][index], localData.data.portListArray[0][index]);

No such luck... a kind pointer in the right direction would be much appreciated.

Thanks :)

CyanBlue
02-06-2003, 07:23 PM
Howdy... :)

Do what I say... :D

1. Create a new movie.
2. Drag a ListBox component onto the stage.
3. Delete that instance of the ListBox component.
4. Open up the Library and make sure that there is a folder called 'Flash UI Components' with 'ListBox' inside of it.
5. Copy this code into the frame and do the test movie to see it working..._level0.createEmptyMovieClip("views_mc", 10);
with (_level0.views_mc)
{
_x = 160;
_y = 35;
}
_level0.views_mc.attachMovie("FListBoxSymbol", "ViewsListBox", 100);
_level0.views_mc.ViewsListBox.addItem("Label", "Data");6. Now, go back to your code and see where the problem lies... :)

Let me know if you have further question...

treefield
02-06-2003, 08:31 PM
I am still stuck... I tried your code in a test movie and it works great... how it does not work in mine... hmmm.... not so well but I think I left something out. I am thinking it has to do with other movies that I am loading. Can you do this?

//MAIN MOVIE
_level0.createEmptyMovieClip("views_mc", 10);
with (_level0.views_mc)
{
_x = 160;
_y = 35;
}
_level0.views_mc.attachMovie("FListBoxSymbol", "ViewsListBox", 100);
_level0.views_mc.ViewsListBox.addItem("Label1", "Data1");
_level0.views_mc.unloadMovie();

trace("movie unloaded");
_level0.views_mc.attachMovie("FListBoxSymbol", "ViewsListBox", 100);
_level0.views_mc.ViewsListBox.addItem("Label2", "Data2");

I am getting a blank screen... the movie clip holds a list box and will display error messages (in other external movie clips that are loaded) if the database or web server is down or errors (has my servlets).

Thanks again for all your help :)

CyanBlue
02-06-2003, 09:20 PM
Yes... You should get the blank screen because you unloaded the place holder movieclip which is done by this line...
_level0.views_mc.unloadMovie();
and you are trying to attach another movieclip to the movieclip that you just deleted which is not possible... By the time this line gets executed, _level0.views_mc is not on the stage anymore...
_level0.views_mc.attachMovie("FListBoxSymbol", "ViewsListBox", 100);

Know what I mean???

What are you trying to do??? I don't understand what you want to accomplish here...

treefield
02-07-2003, 04:13 PM
So, I see I may just have conceptually gone way off track... I have this GUI that displays a list box populated by a Java servlet that queries a SQLServer db. The time it takes for the main movie to draw then the list box to populate at initial load is a little less than desirable (about 5-10 sec). I am trying to put a preloader in place of list box that says the "data is loading". I have that in a seperate movie... loading.swf. I also have error messages (2 separate movies) that display if the request for the list box data errors due to web server or database problems.

I originally drew the list box component on the screen and made it not visible if errors came up. Since I wanted a preloader for the list box, I figured when the viewsData.onLoad got called, I would unload the preloader and load the list box which would then be populated or load the error clips if an error occurs.

I guess this is not really working for me unloading and loading them all into a single movie clip. Should I have defined 4 seperate movie clips at different levels? And shouldn't they be loaded and unloaded when needed to bring down the memory demand from the Flash Player?

Alas, again I thank you for your help. Very much appreciated :)

CyanBlue
02-07-2003, 04:24 PM
Well... Personally if I have less than 10 seconds delay on the web project, I wouldn't bother to put the preloader for that... :)

As you have said, why don't you open up a small message box(movieclip rather than external SWF file since it will take some time to load an external SWF file) for that 10 seconds period and have it done with it??? I don't know if this is what you are intending, but I think that should solve your problem... :)