I want to create a basic drawing utility as a part of my project. Since the drawing needs to be saved I wanted to convert it to a bitmap. I searched for help on google and found this example.

However since the rest of my program is programmed in AS2, I'm getting errors these errors:
The class or interface 'flash.display.Sprite' could not be loaded. // source: var canvas:Sprite = new Image();
The class or interface 'flash.utils.ByteArray' could not be loaded. // source: var bytes:ByteArray;
The class or interface 'flash.display.Shape' could not be loaded. // source: var child:Shape = new Shape();
The class or interface 'MouseEvent' could not be loaded. // source: function mouseDownHandler (event:MouseEvent)
The class or interface 'MouseEvent' could not be loaded. // source: function mouseDownHandler (event:MouseEvent)
The class or interface 'MouseEvent' could not be loaded. // source: function mouseMoveHandler (event:MouseEvent)
Here in the script:

PHP Code:
// http://www.flashscript.biz/flashas3/SaveImage/SaveImage.html
// We start with importing several classes. 
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.utils.ByteArray;
import flash.geom.Rectangle;
import flash.net.SharedObject;
import flash.events.*;
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;

// We create a variable canvas and add it to the stage 
var canvas:Sprite = new Image();
canvas.10;
canvas.10;
stage.addChild(canvas);

// We declare several other variables, which we will later need. 

var myBitmapData:BitmapData = new BitmapData (canvas.widthcanvas.heightfalse0x00FFFFFF);
var 
bytes:ByteArray;
var 
child:Shape = new Shape();
var 
isDrawing:Boolean false;


// Then we give canvas some mouse functions, since we need to draw an image. 

canvas.stage.addEventListener(MouseEvent.MOUSE_DOWNmouseDownHandler);
canvas.stage.addEventListener(MouseEvent.MOUSE_MOVEmouseMoveHandler);
canvas.stage.addEventListener(MouseEvent.MOUSE_UPmouseUpHandler);


// We sart with a function when the mouse is pressed.
// We enter the point where the drawing is supposed to start. 

function mouseDownHandler (event:MouseEvent)
{
    
isDrawing true;
    if( 
isDrawing)
    {
        
child.graphics.lineStyle (20xFF0000);
        
child.graphics.moveTo (mouseXmouseY);
    }
}

// The next function contains all the script to draw an image, when the mouse pressed is moving.
// We set a limit to the drawing, since we want the drawing only in a certain space.

function mouseMoveHandler (event:MouseEvent)
{
    if (
isDrawing)
    {
        
child.graphics.lineTo (mouseXmouseY);
    }
    if(
mouseX canvas.stage.getBounds(this).|| mouseX >295)
    {
        
isDrawing false;
    }
    if(
mouseY canvas.stage.getBounds(this).|| mouseY >145)
    {
        
isDrawing false;
    }                                               
}


// When we don't want drawing to occur we do not press the mouse.
// However, a number of other events are then happening.
// First of all the drawing (child) is saved by using addChild.
// We then convert the drawing to a bitmap.
// The bitmapdata will be stored in the byteArray object.

function mouseUpHandler (event:MouseEvent)
{
    
canvas.addChild (child);
    
isDrawing false;
    var 
rect:Rectangle = new Rectangle(00canvas.widthcanvas.height);
    
myBitmapData.draw (canvas);
    
bytes myBitmapData.getPixels(rect);
    
bytes.position 0;

I have not used classes before and is only used to programming in AS2.

Merry Christmas everyone!