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 8273659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:32:31+00:00 2026-06-08T07:32:31+00:00

I currently follow a flash tutorial online to create an interactive sketchpad. The link

  • 0

I currently follow a flash tutorial online to create an interactive sketchpad. The link to tutorial is http://flashexplained.com/actionscript/making-an-interactive-drawing-sketchpad/.

The only problem with this tutorial is that the code is for actionscript 2.0 instead of 3.0. I know how to redefine the variables but besides that I am clueless, so I was hoping that someone can help me convert the code to ActionScript 3.0.

Here is the ActionScript 2.0 code:

lineThickness = 0;
selectedColor = "0x000000";

_root.onMouseDown = startDrawing;
_root.onMouseUp = stopDrawing;

function startDrawing()
{
    if(_xmouse < 455)
    {
        _root.lineStyle(lineThickness, selectedColor);
        _root.moveTo(_root._xmouse, _root._ymouse);
        _root.onMouseMove = drawLine;
    }
}

function drawLine()
{
    _root.lineTo(this._xmouse, this._ymouse);
}


function stopDrawing()
{
    delete this.onMouseMove;
}

line0.onPress = function()
{
    lineThickness = 0;
}

line3.onPress = function()
{
    lineThickness = 3;
}

line6.onPress = function()
{
    lineThickness = 6;
}

colorRed.onPress = function()
{
    selectedColor = "0xFF0000";
}

colorGreen.onPress = function()
{
    selectedColor = "0x00FF00";
}
  • 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-06-08T07:32:32+00:00Added an answer on June 8, 2026 at 7:32 am

    AS2:

    lineThickness = 0;
    selectedColor = "0x000000";
    

    AS3:

    var lineThickness:int = 0;
    var selectColor:uint = 0x000000;
    

    AS2:

    _root.onMouseDown = startDrawing;
    _root.onMouseUp = stopDrawing;
    
    function startDrawing()
    {
        if(_xmouse < 455)
        {
            _root.lineStyle(lineThickness, selectedColor);
            _root.moveTo(_root._xmouse, _root._ymouse);
            _root.onMouseMove = drawLine;
        }
    }
    
    function stopDrawing()
    {
        delete this.onMouseMove;
    }
    
    function drawLine()
    {
        _root.lineTo(this._xmouse, this._ymouse);
    }
    

    AS3:

    stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
    stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
    
    function startDrawing(e:MouseEvent):void
    {
        if(mouseX < 455)
        {
            this.graphics.lineStyle(lineThickness, selectedColor);
            this.graphics.moveTo(mouseX, mouseY);
    
            stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
        }
    }
    
    function stopDrawing(e:MouseEvent):void
    {
        stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
    }
    
    function mouseMove(e:MouseEvent):void
    {
        this.graphics.lineTo(mouseX, mouseY);
    }
    

    AS2:

    line0.onPress = function()
    {
        lineThickness = 0;
    }
    
    line3.onPress = function()
    {
        lineThickness = 3;
    }
    
    line6.onPress = function()
    {
        lineThickness = 6;
    }
    
    colorRed.onPress = function()
    {
        selectedColor = "0xFF0000";
    }
    
    colorGreen.onPress = function()
    {
        selectedColor = "0x00FF00";
    }
    

    AS3:

    line0.addEventListener(MouseEvent.CLICK, changeLine);
    line3.addEventListener(MouseEvent.CLICK, changeLine);
    line6.addEventListener(MouseEvent.CLICK, changeLine);
    colorRed.addEventListener(MouseEvent.CLICK, changeColor);
    colorGreen.addEventListener(MouseEvent.CLICK, changeColor);
    
    function changeLine(e:MouseEvent):void
    {
        switch(e.currentTarget)
        {
            default: lineThickness = 1; break;
    
            case line0: lineThickness = 0; break;
            case line3: lineThickness = 0; break;
            case line6: lineThickness = 0; break;
        }
    }
    
    function changeColor(e:MouseEvent):void
    {
        switch(e.currentTarget)
        {
            default: selectedColor = 0x000000;
    
            case colorRed: selectedColor = 0xFF0000; break;
            case colorGreen: selectedColor = 0x00FF00; break;
        }
    }
    

    Additional (clear the graphics):

    eraser_btn.addEventListener(MouseEvent.CLICK, erase);
    function erase(e:MouseEvent):void
    {
        this.graphics.clear();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a postgresql user and I'm trying to follow this : http://www.postgresql.org/docs/current/interactive/sql-createtrigger.html CREATE TRIGGER
I'm trying to follow this documentation on Symfony : http://symfony.com/doc/current/book/forms.html ok so here is
I am currently attempting to follow along with section 10.38 from RoR Tutorial. All
Currently I have the follow ps that reads a list of user names and
I'm currently playing with a bar chart implemented through Open Flash Charts (I believe
I'm currently trying to follow the OpenGL intro guide here . I've pulled the
I try to set up devise and omniauth by follow https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview and deploy to
I am currently using the follow query: SELECT * FROM `wp_usermeta` WHERE meta_key='avatar' AND
Currently I have a simple class for users, like the follow: public class Users
I'm currently experimenting with jade template engine. I've got the follow basic code in

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.