I get only a single level of cancellation with the pop method / Cancel button

Hello.  Why this code produces only a single level of cancellation?  I thought whenever the pop method is triggered on a table, the table shrinks and you can continue to pop as long as the table is not less than 0.

Here is my code:

import flash.display.MovieClip;

import flash.display.Shape;

import flash.events.MouseEvent;

import flash.events.Event;

// http://www.Kirupa.com/Forum/showthread.php?309502-AS3-spiral-effect ... it's one used previously in other files

// http://hub.tutsplus.com/tutorials/create-a-basic-drawing-application-in-Flash--active-1627 ... it's the one used here

var my_mc:MovieClip = new MC();

var container: MovieClip = new MovieClip();

stage.addEventListener (MouseEvent.MOUSE_DOWN, startDrawing);

stage.addEventListener (MouseEvent.MOUSE_UP, stopDrawing);

var shape: Shape = new Shape();

var myArr:Array = new Array();

var myArrRedo:Array = new Array();

var myArrObj:Array = new Array();

var undo_btn:MovieClip = new Btn_mc_undo();

var redo_btn:MovieClip = new Btn_mc_redo();

undo_btn.x = 10;

undo_btn.y = 350;

redo_btn.x = 110;

redo_btn.y = undo_btn.y;

addChild (undo_btn);

addChild (container);

stage.addChild (redo_btn);

var nums:int;

undo_btn.addEventListener (MouseEvent.MOUSE_DOWN, undoEvent);

redo_btn.addEventListener (MouseEvent.MOUSE_DOWN, redoEvent);

function undoEvent(e:MouseEvent):void {}

container.removeChild (myArrObj.pop ());

}

function redoEvent(e:MouseEvent):void {}

nothing yet

}

var num:int = 0;

function startDrawing(e:MouseEvent):void {}

Shape = new Shape();

container.addChild (shape);

Shape.Name = String (num);

myArr.push (shape.name);

myArrObj.push (shape);

shape.graphics.lineStyle (3, 0xcccccc);

shape.graphics.moveTo (mouseX, mouseY);

stage.addEventListener (MouseEvent.MOUSE_MOVE, whileDrawing);

NUM ++;

}

function stopDrawing(e:MouseEvent):void {}

stage.removeEventListener (MouseEvent.MOUSE_MOVE, whileDrawing);

}

function whileDrawing(e:MouseEvent):void {}

shape.graphics.lineTo (mouseX, mouseY);

}

a couple of these lines are surplus to troubleshooting (for example the num ++);

I offered him work.  Maybe you have something else in the file which you have not realized.

If you put a trace (e.target) according to your drawing, you'll see that it calls the function of drawing when you click the button (s).

Here is a link to an example file using your code with a few adjustments for lack of content...

http://www.nedwebs.com/Flash/AS3_Draw_Undo.fla

Another remedy would be to create a separate drawing area of the buttons and target this area instead of the scene for your drawing listeners.

It would also be a good idea to use a CLICK listener to the buttons and not a MOUSE_DOWN.

Tags: Adobe Animate

Similar Questions

Maybe you are looking for

  • PDF.js mangles police embedded Viewer

    I have a number of documents I want to integrate into the Web pages for easy access. It is a PDF file generated with pdftex locally under MikTeX. They use fonts Adobe Minion Pro. They make seamless in Adobe Reader, Sumatra, PDFXchange and chrome (wit

  • Error bad 5205 satellite on recovery machine

    My 5205 s703 came with a bad machine after an attempt to recover from a system failure. I remember using the DMI toshiba update to try to resolve the problem of ID. (he is the ID changing 5205 to 5200 5205). That's why the recovery disk does not work

  • Installed Firefox 3.6.10 now my mouse wheel does not scroll

    I just installed FF 3.6.10 update, and now my mouse wheel does not scroll. I checked my settings of the mouse, and everything is OK. Mouse wheel scrolls in applications non-Firefox, including offline and IE records online. The mouse wheel has worked

  • Mini bios password

    Can someone help me with the passowd of BIOS on a mini 1000.  I bought the computer on sale at auction of na and found that it was locked code is CNU9105JLW.  Thanks Craniack

  • HPE-400Z: the power switch not turn on the PC.