Skip navigation
jerm8352
Currently Being Moderated

Help with a whiteboard!

Jun 19, 2012 4:02 PM

Tags: #problem #actionscript3 #whiteboard #swapchildren

Hello, I am making a whiteboard math app.  The program has a whiteboard in the middle and the top and bottom of the program have a bar that will have various buttons and text fields for displaying the question, entering an answer, help, and the person's score.  I have pretty much everything working how I want it except that the "pen" for the whiteboard writes all over the top and bottom bars, buttons, text fields, etc.  How do I stop this?  The top and botttom bars are movie clips named "top" and "bottom" if that helps.

 

Here is the code:

 

import flash.display.MovieClip;

import flash.events.MouseEvent;

 

var lines:MovieClip;

var isMoving:Boolean = false;

var linesColor:Number = 0x000000;

var linesSize:uint = 1;

var equations:Array = new Array;

var equationsAnswers:Array = new Array;

var score:uint = 0;

var questionsAsked:uint = 0;

var answer:String = new String;

 

 

equations = ["x + 7 = 13", "x - 8 = 23"];

equationsAnswers = ["6", "31"];

 

lines = new MovieClip();

 

stage.addEventListener(MouseEvent.MOUSE_DOWN, startLines);

stage.addEventListener(MouseEvent.MOUSE_MOVE, drawLines);

stage.addEventListener(MouseEvent.MOUSE_UP, stopLines);

checkbtn.addEventListener(MouseEvent.CLICK, newquestion);

stage.addChild(lines);

 

 

function startLines(e:MouseEvent) : void {

    isMoving = true;

    lines.graphics.lineStyle(linesSize, linesColor, 1.0);

    lines.graphics.moveTo(mouseX, mouseY);

}

 

function drawLines(e:MouseEvent):void {

    if (isMoving){

        lines.graphics.lineTo(mouseX, mouseY);

    }

   

}

 

function stopLines(e:MouseEvent):void {

    isMoving = false;

}

 

function newquestion(e:MouseEvent):void {

    answer = inputAnswer.text;

    if (answer == equationsAnswers[questionsAsked]){

        score ++;

    }

    questionsAsked++;

    scoreshow.text = score + ":" + questionsAsked;

    question.text = equations[questionsAsked];

    inputAnswer.text = "";

}

question.text = equations[questionsAsked];

 

 

 

 

Any help would be very appreciated!

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 4:09 PM   in reply to jerm8352

    Ypu can create a MovieClip to get inside the "lines" an the use a mask to show only the "drawable" area

     

     

     

    var drawable:MovieClip=new MovieClip();

    drawable.addChild(lines);

     

    drawable.mask=maskWhiteboard

     

    (maskWhiteboard is other Movie Clip)

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 7:50 AM   in reply to jerm8352

    mask.jpg

     

    maskWhiteboard is a movieclip that you create with the size and shape of the area where you can draw, excluding your buttons

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 11:21 AM   in reply to jerm8352

    stage.addChild(drawable);

     

    you need add to the stage the Movieclip named drawable

     

     

     

     

     

    var score:uint=0;

    var questionsAsked:uint=0;

    var answer:String=new String();

    var drawable:MovieClip=new MovieClip();

    stage.addChild(drawable);

     

    equations=["x + 7 = 13","x - 8 = 23"];

    equationsAnswers=["6","31"];

     

    lines = new MovieClip();

     

     

    stage.addEventListener(MouseEvent.MOUSE_DOWN, startLines);

    stage.addEventListener(MouseEvent.MOUSE_MOVE, drawLines);

    stage.addEventListener(MouseEvent.MOUSE_UP, stopLines);

    checkbtn.addEventListener(MouseEvent.CLICK, newquestion);

    stage.addChild(lines);

    drawable.addChild(lines);

    drawable.mask=whiteboardMask;

     

     

    function startLines(e:MouseEvent):void {

        isMoving=true;

        lines.graphics.lineStyle(linesSize, linesColor, 1.0);

        lines.graphics.moveTo(mouseX, mouseY);

    }

     

     

    function drawLines(e:MouseEvent):void {

        if (isMoving) {

            lines.graphics.lineTo(mouseX, mouseY);

        }

    }

     

     

    function stopLines(e:MouseEvent):void {

        isMoving=false;

    }

     

     

    function newquestion(e:MouseEvent):void {

        answer=inputAnswer.text;

        if (answer == equationsAnswers[questionsAsked]) {

            score++;

        }

     

        questionsAsked++;

        scoreshow.text=score+":"+questionsAsked;

        question.text=equations[questionsAsked];

        inputAnswer.text="";

    }

     

    question.text=equations[questionsAsked];

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 1:20 PM   in reply to jerm8352
    you're welcome

     

     

    It's just a detail that went unnoticed

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 27, 2012 3:17 PM   in reply to jerm8352

    lines = new MovieClip();

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 27, 2012 3:52 PM   in reply to jerm8352

    do not worry sometimes happens

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points