Copy link to clipboard
Copied
Hello
Fairly new to javaScript/Animate so the code might be a bit sketchy but.... I think I need to clear the array somehow on the attached project, each time I move between sections.
Download .fla here
It is basically a load of circles that use vectors to move around the screen in a 'random' fashion. These objects are connected by lines which are drawn in a shape object.
It all works fine except when I go to another location and then return to the main screen, the number of lines doubles and they appear to be tracking ghost objects. Every time you leave and return another set of lines appears...
I am guessing this is because I keep creating(?)/adding to(?) the existing array of objects but can't find a way to clear or block this happening.
Creating the array and graphic for the lines in the 'global/script' section seemed to stop additional lines being created but then the speed of movement doubled each time you return to the home screen.
Another issue is that the lines continue to be drawn in the 'test' frame even though I am not calling any code here to do so..
Any pointers would be greatly appreciated. Cheers 🙂
Click on a circle to go to the 'test' frame and then click the 'home' button to return home and see the madness!
Hi,
I haven't dig too much into the logic of the code, but I noticed that
_this.addChild (linesObject);
is executed multiple times.
I moved these two lines
_this.addChild( linesObject );
_this.setChildIndex( linesObject, 0 );
immediately after the initialization of linesObject and I think, now it works as expected.
See the attachment.
Copy link to clipboard
Copied
Hi,
I haven't dig too much into the logic of the code, but I noticed that
_this.addChild (linesObject);
is executed multiple times.
I moved these two lines
_this.addChild( linesObject );
_this.setChildIndex( linesObject, 0 );
immediately after the initialization of linesObject and I think, now it works as expected.
See the attachment.
Copy link to clipboard
Copied
Thanks Vladin
Working perfectly. Didn't realise I should be clearing the linesObject as well.
Much appreciated 🙏