This content has been marked as final. Show 5 replies
every time your attachMovie statement runs, it creates a movieclip called "box". so if the drawChildToCenterBox function is called twice, you'll have two movieclips on the stage both called "box", making it very difficult to reference one of them individually.
you then put the reference to this movieclip into a variable called boxRef. if the drawChildToCenterBox function is called twice, the second call will replace the variable boxRef with the reference to the second movieclip, meaning all interval calls will only reference the second boxRef. You have a similar problem with intervalID, xPos, yPos and i.
Thanks for the reply!
There's only supposed to be one instance of this object "box". I do a removeClip() on it in another part of the code.
I could post the rest of the code, if it would help. xPos, yPos, and pretty much everything in this function is meant to be disposable. I return the boxRef for later use and keep track of that in other parts of the code.
sorry i'm confused then. earlier you said:
"...there are 2 of these movable clips and it only happens to the left one..."
are there two(or more) movieclips on the stage simultaneously that are both created with the drawChildToCenterBox function? if so then i don't understand how there's "only supposed to be one instance of this object "box"."
you say these variables are disposable, but you're referring to them in your interval handler...
I'm sorry that I didn't explain myself completely. There are several of these child nodes, but only one goes through this function at a time. This function turns the child node into the parent node. Once the function is used, the values in it are no longer needed. The next time it is run, the values are replaced. That is not a problem.
I'll post the whoel set of code so that it will make more sense for you.
Thanks for your willingness to help.
wow that's a lot of code to wade through - to be able to understand it fully it might be handy to see the fla.
but before we take that step, i'm not sure that you understand what i've been trying to say, so just in case let me try and say it again.
You say: "Once the function is used, the values in it are no longer needed. The next time it is run, the values are replaced. That is not a problem."
However, (admittedly without thoroughly reading your new code posting yet!) i suspect that it could be the problem. once the function has been called, the function that your setInterval call created is still accessing the values that this function created, and if it is called again before the interval is cleared, then these values will be changed. for example 'i' will be set back to 0 and both interval functions will be incrementing it...
is this your problem? if you think you understand what i'm getting at but this isn't your problem, let me know, post your fla and we'll see if we can't tackle it.