Skip to main content
Inspiring
March 2, 2009
Answered

reset Button

  • March 2, 2009
  • 10 replies
  • 1121 views
Hello I have a page with several input boxes and several instances of movie clips on the stage which have been added with addChild, what i want to do is make a reset buttun that clears all the input boxe and removes the movieClips so that the page looks as it did when it was first loaded but the help files are usless with a specific request like this.
This topic has been closed for replies.
Correct answer sharpasDOH
sorrted my self! I didn't like deleting movieClips thar were not on the page so a load of if statement sorted it out in the end :)

10 replies

sharpasDOHAuthorCorrect answer
Inspiring
March 15, 2009
sorrted my self! I didn't like deleting movieClips thar were not on the page so a load of if statement sorted it out in the end :)
Inspiring
March 5, 2009
tried that but get this error. Tried it with a colon and small e but still the same result
1120: Access of undefined property event.
reset_mc.addEventListener(Event.MouseEvent.CLICK, resetStage);
Inspiring
March 5, 2009
this is my code for the reset button but when i get to this page the reset button has a vibrant green outline around it?

reset_mc.addEventListener(MouseEvent.CLICK, resetStage);
Inspiring
March 4, 2009
yes i tried it without that first, well I have tried several ways to get this to work but its the same but I am not getting any faults reported either the only thing I get is this output

ArgumentError: Error #1063: Argument count mismatch on MathsDemo_fla::MainTimeline/resetStage(). Expected 0, got 1.
Ned Murphy
Legend
March 5, 2009
If you're using a button for the reset, the reset function needs to have an evt:MouseEvent specified as an argument
Inspiring
March 4, 2009
var tick_mc:MovieClip=new MovieClip ;
var cross_mc:MovieClip=new MovieClip ;
var tickArray:Array =new Array();
var crossArray:Array =new Array();

for (var i:uint=0; i<tickArray.length; i++) {
this.addChild(tick_mc );
this.addChild(cross_mc
);
}

function out02(event:Event):void {
if (out02_txt.text=="4") {
tick_mc.x=159;
tick_mc.y=85;
this.addChild(tick_mc);
tickArray.push(tick_mc);
time02_txt.removeEventListener(FocusEvent.FOCUS_OUT, out2);
} else {
cross_mc.x=159;
cross_mc.y=95;
this.addChild(cross_mc);
crossArray.push(cross_mc);
out02_txt.removeEventListener(FocusEvent.FOCUS_OUT, out2);
}
}

can't get any mcs on the page nothing showing i'm sure it's wahat I have put at the beggining of this message but i just cannot figure it out so any help is gratefully received
Ned Murphy
Legend
March 4, 2009
That for loop at the beginning has nothing to feed it at that point. The arrays are empty, having just been declared. They don't get filled with anything until you're in the function.
Ned Murphy
Legend
March 4, 2009
Thanks, but I'm a better student than a teacher.
Inspiring
March 4, 2009
Cheers Ned you are a better teacher than all of Adobe :)
Inspiring
March 3, 2009
Thanks againI think the problem is i'm trying to put 10 of the same _mc on the page as i have the reset button that clears the page but the _mcs don't stay in place when the FOCUS-OUT clicks in so if you could be a bit more specific or have I got use 10 differnt _mcs

var tick_mc:Tick = new Tick;
var cross_mc:Cross = new Cross;


function out2(event:Event):void{
if (out02_txt.text == "4"){
tick_mc.x = 159;
tick_mc.y = 85;
this.addChild(tick_mc);
out02_txt.removeEventListener(FocusEvent.FOCUS_OUT, out2);
}
else{
cross_mc.x = 159;
cross_mc.y = 95;
this.addChild(cross_mc);
out0_txt.removeEventListener(FocusEvent.FOCUS_OUT, out2);
}
}

I have 10 of these repeating the cross or tick appear when you focus out but go away on the next focus_out
Ned Murphy
Legend
March 4, 2009
Here's the general idea for the ticks ( may not be the exact solution... but you won't learn by having someone hand you solutions):

tickArray:Array =new Array();

function out2(event:Event):void{
if (out02_txt.text == "4"){
tick_mc.x = 159;
tick_mc.y = 85;
this.addChild(tick_mc);
tickArray.push(tick_mc);
out02_txt.removeEventListener(FocusEvent.FOCUS_OUT, out2);
}
etc...

function resetStage(){
for(var n:uint=0; n<tickArray.length; n++){
this.removeChild(tickArray);
}
tickArray = new Array();
}
Ned Murphy
Legend
March 2, 2009
That was a fairly easy answer. The tools:

1) two arrays

2) 2 for() loops

3) textfield.text = ""

4) removeChild()
Ned Murphy
Legend
March 2, 2009
Usually you have to think about how you can use the tools you have to do what you need done. Store references to these objects in arrays and loop thru the arrays, resetting textfields and removing children.
Inspiring
March 2, 2009
thank you I thought ot wouldn't be the easy answer but then again it is rewarding working these things out for yourself even if it does take me a fortnight to get my head round this :)