Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6698507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:35:10+00:00 2026-05-26T06:35:10+00:00

I want to know how to prevent the user from drawing outside my school

  • 0

I want to know how to prevent the user from drawing outside my school board.

My board image sizes 709.15 X 499.5.
So I thought of something like this…

if(stage.stageWidth <= 709)

But if my board image is being called as a variable on stage boardActiva it should be easier.

Here’s the function that draws:

        private function dibujar(e:MouseEvent){         
        trace(e.localY);            
        tizaActiva.x = e.stageX;
        tizaActiva.y = e.stageY;
        if(dibujando){
        tabla.graphics.lineTo(e.stageX,e.stageY);
        }

And this is the full code:

package  {  
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.*;
import flash.trace.Trace;
import flash.ui.Mouse;
import flash.display.Shape;
import fl.controls.ColorPicker;
import fl.motion.Color;
import fl.events.ColorPickerEvent;
public class pizarra extends MovieClip {        
private var colores:ColorPicker = new ColorPicker;      
private var boardActiva:board = new board;
private var tizaActiva:tiza = new tiza();
private var tabla:Shape = new Shape;
private var dibujando:Boolean;
    public function pizarra() {
        Mouse.hide();
        tabla.graphics.lineStyle(5,0xFFFFFF);
            // constructor code         
        boardActiva.x = 45;
        boardActiva.y = 40;
        addChild(boardActiva);
        addChild(tabla);
        addChild(colores);
        addChild(tizaActiva);
        dibujando = false;          
        stage.addEventListener(MouseEvent.MOUSE_DOWN, empezarDibujo);
        stage.addEventListener(MouseEvent.MOUSE_MOVE, dibujar);
        stage.addEventListener(MouseEvent.MOUSE_UP, detenerDibujo);
        colores.addEventListener(ColorPickerEvent.CHANGE,cambiar);
    }

    private function empezarDibujo(e:MouseEvent):void{          
        trace(e.localY);
        tabla.graphics.moveTo(e.stageX,e.stageY);
        dibujando = true;           
    }       
    private function dibujar(e:MouseEvent){         
        trace(e.localY);

        tizaActiva.x = e.stageX;
        tizaActiva.y = e.stageY;
        if(dibujando){
        tabla.graphics.lineTo(e.stageX,e.stageY);
        }
    }       
    private function detenerDibujo(e:MouseEvent){           
        trace(e.localY);
        dibujando = false;

    }           
    private function cambiar(e:ColorPickerEvent){
            tabla.graphics.lineStyle(5,e.color);

        }       

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:35:10+00:00Added an answer on May 26, 2026 at 6:35 am

    If I understood correctly your question, this should do it:

    private function dibujar(e:MouseEvent)
    {
    
        //trace(e.localY);
    
        tizaActiva.x = e.stageX;
        tizaActiva.y = e.stageY;
    
        if(dibujando && insideBoard(e.stageX,e.stageY) )
        {
            tabla.graphics.lineTo(e.stageX,e.stageY);
    
        }
    
    }
    
      private function insideBoard(x:Number,y:Number):Boolean
      {
        return ( (x>= boardActiva.x) 
               && (x <= boardActiva.x + boardActiva.width )
               && (y >= boardActiva.y) 
               && (y <= boardActiva.y + boardActiva.height ) );
      }
    

    Hope to be of some help, good luck with your pizarra 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So as the title says i want to prevent user from keep submiting $_POST
In my asp.net web application i want to prevent multiple user login from the
I know there are methods to prevent a class from being created on the
How can I prevent a user from accessing a page when they are not
I want to know is there any way to prevent elements of HTML form
I want to prevent my app doing certain things when the user is watching
I need to prevent user from selecting text (select all or select a portion
How can I prevent a user from neglecting the normal work flow of a
I'm trying to prevent a user from disabling style.(I HAVE A GOOD REASON TO
How would you prevent the user from adding or removing lines in a TextBox?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.