Refresh Listbox

What would be the easiest way to refresh a list box to its original state after some items have been erased.


Hmm, just another theory but…

Try creating the state as an AS function or prototype. Then call it on load to populate the box. Then have a reset button that calls the function again and resets the state of the listbox.

Worth a shot I suppose.

What is an AS function or prototype?
Better yet, how about a tutorial.

I’ll take a peek.:sleep:

There is a tutoral on prototypes in the AS tricks section.

Just go to and click on Actionscript. I think it is the first link in the Actionscripts section.

Can you post a .fla so I can see what I can do?

the fla is 240k and I guess that’s to big to upload and I can not upload swf.:frowning: What to do? but start reading.

Well good luck. I am off to bed now. 3:30 in the AM here.


function populate(){

then on a button…


Are you posting questions on these topics under different names?

Yeah, I noticed questions about the same exact thing but from all different names. I got confused…haha.

If you don’t mind if I change the subject for a second…

Hey Montoya, how come whenever I write a function exactly like the above and call it, it never works. I end up rewriting it as a prototype and all works fine and dandy. I don’t get it… any ideas?

good question… why don’t you write one that is not working and let me see it. Perhaps we can solve it together.

Ok, it is probably some really stupid mistake on my part though.

Let us try this basic way…

I add this code onto my movie clip.

onClipEvent (enterFrame) {

And the non-working function (this is a basic one for easier explanation)

function slide() {
	this._x += 1;

The above does not work, but when I change it to the below, it works perfectly…

MovieClip.prototype.slide = function() {
	this._x += 1;

I did nothing but change it from a function to a prototype. I didn’t even change the code on the movie clip.

Any ideas? Can you not += in a function maybe?

well…this is how I would do it… don’t know if it is the best method, but it works for me

for mc


the function itself:

function slide(mc){

try it out…


Works great! Thanks Montoya, I told you it would probably be some stupid mistake.

No problem, brotha!

Ready for another home-made explanation, Lost? :stuck_out_tongue:

No, this is really simple this time: it’s just that this.slide is the way you call a prototype, not a function. Functions don’t apply to an object, so Flash doesn’t know who this is.

The function takes the clip as a parameter, so it knows who it is talking to.

pom :asian:


All this time I thought there was just something wrong with my Flash program (I actually tried reinstalling it because I just couldn’t get it to work…I know I am lame).

With the method Montoya showed me it made perfect sense to define the mc in the function you are calling (function slide(mc)).

I can’t believe I didn’t think of that earlier.


Well said, Pom… Lost, Im sorry if I didnt explain that puppy further…

Nah, I got the basic jist from what you showed me. Ilyas just went further down and compared it to prototypes.

Now I can stop using prototypes for EVERYTHING…haha.

*Originally posted by ilyaslamasse *
Functions don’t apply to an object, so Flash doesn’t know who this is.
Well, that’s not exactly the reason why it’s not working, actually. The true reason [SIZE=1]I think[/SIZE] is that Flash is looking for a function declared in this, whereas the function was declared in the _root.

My bad.

pom :cowboy: