Copy link to clipboard
Copied
The aim of this application is to generate angles so that students can state what type (e.g. acute etc)
I can generated an angle, but I can't remove this angle so a new angle can be added. They just build up on top of each other.
I have uploaded the code.
I'm just wondering if anyone can perhaps help with this problem.
I've tried removeChild, and I think I am heading in the right direction, but just don't have it right.
Here is how I added the child to the stage.
stage.addChild(shape);
... and here is a link to see what is happening when I create the new question (i.e. press GO again).
https://mymathsroom.com/angles/
Thanks
Copy link to clipboard
Copied
if you're not going to assign unique names to each angle, then add them all to the same parent so you can remove them all without needing a name. eg:
var angleP:MovieClip=new MovieClip();
stage.addChild(angleP);
call removeAnglesF when desired
function removeAngelesF():void{
for(var i:int=angleP.numChildren-1;i>=0;i--){
angleP.removeChildAt(i);
}
}
Copy link to clipboard
Copied
I think I am heading in the right direction with your answer. I havn't got it working yet.
One thing is that I did not create movieclips, but used this command ....
var shape = new createjs.Shape();
So I am not quite sure how to get the id of the instance on the stage (if it is considered an instance like a movieclip would be).
I'll keep at it though.
Thank you.
Copy link to clipboard
Copied
if you have an html5 project, use:
var angleP = new createjs.MovieClip();
stage.addChild(angleP);
function removeAnglesF() {
for (var i = angleP.numChildren - 1; i >= 0; i--) {
angleP.removeChildAt(i);
}
}