• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with a whiteboard!

New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

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!

TOPICS
ActionScript

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 20, 2012 Jun 20, 2012

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.addEventListen

...

Votes

Translate

Translate
Enthusiast ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

Thank you for the reply.  maskWhiteboard is which  other movie clip?  I'm a little confused

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 20, 2012 Jun 20, 2012

Copy link to clipboard

Copied

mask.jpg

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2012 Jun 20, 2012

Copy link to clipboard

Copied

Thank you again.  However, when I do this, it won't draw anywhere.  I put a new movie clip on the stage with an instance name of whiteboardMask.  Then, I put the code, changing it to whiteboardMask instead of maskWhiteboard.  Now, when I test it, it will not draw anywhere.

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;

var drawable:MovieClip = new MovieClip;

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];

Any help would be appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 20, 2012 Jun 20, 2012

Copy link to clipboard

Copied

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];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2012 Jun 20, 2012

Copy link to clipboard

Copied

thank you, I'm an idiot.

It works perfectly now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 20, 2012 Jun 20, 2012

Copy link to clipboard

Copied

you're welcome

It's just a detail that went unnoticed

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

Thank you again.  Is there an easy way to erase the entire whiteboard?  to get rid of all the "lines" on the whiteboard?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

lines = new MovieClip();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

Thank you. WOW again I completely miss the obvious.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

LATEST

do not worry sometimes happens

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines