all groups > flash actionscript > february 2005 >
You're in the

flash actionscript

group:

Clearing or Reseting movieClip Contents


Clearing or Reseting movieClip Contents kbrandon
2/9/2005 11:59:23 PM
flash actionscript:
My objective is to create a fixed area on stage that is populated based on 10
buttons. These buttons are linked to functions which will place various text,
shapes, components in the defined area. I am trying to find an efficient way
to clear the dynamic items created by a previous function when a new one is
called. Initially I created an empty movie clip on stage. The idea was to
have a given function clear the movieClip before performing its tasks. However
the only clear related function for movieClip solely applies to drawing API
content. I have thought of some very kludgey methods such as creating a
duplicated movieClip over the original which can the be
removed(removeMovieClip) and recreated by each function. Lastly I could forgo
the movieClip Container and track what should be seen and then use visibility
property (Very Messy). It seems like this would be a popular requirement that
should have a good solution... I am open to suggestions other than using
MovieClip container, but this class generally has the most versatility. Any
help would be appreciated.

On a related side note can a non-duplicate movieClip be deleted?
Re: Clearing or Reseting movieClip Contents kglad
2/10/2005 4:22:59 PM
if you create an empty movieclip, you create objects and variables within this
movieclip, then when you remove this movieclip all the objects and variables
you created should be removed. what is that you create that you don't think is
being removed?
Re: Clearing or Reseting movieClip Contents kglad
2/10/2005 4:23:29 PM
Re: Clearing or Reseting movieClip Contents abeall
2/10/2005 4:25:01 PM
I don't have MX'04 (thus I do not have movieClip container class - or any extra
classes for that matter), but if I understand correctly I would just do this:
if every function needs to clear its predecessor, than just make every function
createEmptyMovieClip on the same depth. It will automatically clear(remove) the
old one. But maybe I missunderstood. > On a related side note can a
non-duplicate movieClip be deleted? Bring it to a positive depth, and thou
can killeth anything: MovieClip.prototype.kill = function(){
this.swapDepths(1048575); this.removeMovieClip; } Although my understanding is
there is some similar class/function built into MX'04 that does this.
Re: Clearing or Reseting movieClip Contents abeall
2/10/2005 4:26:18 PM
Re: Clearing or Reseting movieClip Contents kbrandon
2/10/2005 6:50:22 PM
My initial goal was to have 1 movieClip on Stage that is cleared and then
populated by each function. Thanks for the help on using emptyMovieClips to
solve my problem! Deleting was causing me a problem because it was a stage MC
with a negative depth. I do have a few questions that might increase everyones
general knowledge.

1) Is there a way to clear/reset the contents of a movieClip (Goal Statement
Above)?
2) Was it a fact that the MC was a stage element or the negative depth that
caused my deletion problem? Why? Is this a general rule for all elements?

Thanks Again for the help...
Re: Clearing or Reseting movieClip Contents abeall
2/10/2005 7:07:27 PM
1) There are some different ways, but none of them are like
_root.myMcPath.clearContents(). One example is to use a container clip just a
regular clip), that only contains movieclips, then to clear it you could make
your own little function MovieClip.prototype.killContents = function(){ for(var
mc in this){ if(typeof this[mc] == 'movieclip'){ this[mc].kill(); } } //use
alongside the kill() prototype i gaev you earlier 2) In a way both: all
authored MCs are on a negative depth, and only those on positive depths can be
removed.
http://www.google.com/search?q=understanding+flash+depths&sourceid=mozilla-s
earch&start=0&start=0&ie=utf-8&oe=utf-8 (the second article,
kirupa, is quite good, but the site was down just now).
Re: Clearing or Reseting movieClip Contents abeall
2/10/2005 7:09:23 PM
3) If my functions all create emtpyMovieClips() with the same name (ie.
'container_mc') will that delete the previously created MovieClip? No, they
will just mess up referencing, they need to be on the same depth (or rather,
putting something on an occupied depth will kill anything that was there).
Using the same name would be a good idea though, as it would get confusing if
the name changed, and wouldnt really be helpful.
AddThis Social Bookmark Button