Note that there are some explanatory texts on larger screens.

plurals
  1. POActionscript drawing w/clear button
    primarykey
    data
    text
    <p>I'm following example Lesson 4 out of Actionscript classroom in a book, but modifying it by adding a CLEAR button to the stage. </p> <p>Whenever I test all of the functions work, but, I am able to draw over the top of my button. Ideally when the user is drawing, the colors should be going underneath the button.</p> <p>In the timeline I have layers for the Background, Button, and Actions. I've added the coding below to help address the issue quicker. Thanks!</p> <pre><code>package { import flash.display.MovieClip; public class Ellipse extends MovieClip { // constructor public function Ellipse(w:Number=40,h:Number=40,color:Number=0xff0000) { graphics.beginFill(color); graphics.drawEllipse(0, 0, w, h); graphics.endFill(); } } // end class Ellipse } // end package import flash.events.MouseEvent; var color:Number; stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing); stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing); function startDrawing(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_MOVE, makeShapes); color = Math.random() * 0xFFFFFF; } function stopDrawing(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, makeShapes); } function makeShapes(e:MouseEvent):void { var ellipse:Ellipse = new Ellipse(10, 10, color); stage.addChild(ellipse); ellipse.x = mouseX; ellipse.y = mouseY; } btnClear.addEventListener(MouseEvent.CLICK, clearBoard); function clearBoard(e:MouseEvent) { for (var i:int = stage.numChildren-1; i &gt;= 1; i--) { stage.removeChildAt (i); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload