Steve Abaffy wrote:
Quick update
>
> Function{
>
> Var Mort: MovieClip = new Mort();
>
> Try{
>
> removeChild(Mort);
>
> }catch(e:Error){
>
> // Do nothing;
>
> }
>
> addChild(Mort);
>
> }
>
> This function is called multiple times and each time it adds the child
> Mort,
> but I want to remove the one placed there previously, it works if I add the
> two lines right after each other as in the previous email but I really need
> it work more like this.
>
You have a scope issue. Mort is a local variable, and is no longer there
when you call it the second time. Try moving it up so it's declared in the
class definition, and instantiated in the function.
You have a couple of other problems, too. You have a variable Mort and a
class Mort. You should really make the variable lower case mort, like Jason
suggested.
Also, if that is your entire function, you have other problems. Every time
you call it, you're creating a new Mort (in the variable declaration--var
Mort:MovieClip = new Mort();). That guarantees you that you won't have the
previously created Mort--you just wiped it out on the first line of the
function.
Work with the debugger, Steve. Set some break points, and look at the state
of the variables, follow the logic flow. You'll find you can solve problems
like this more quickly if you understand what's happening in your code.
Cordially,
Kerry Thompson
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders