Groups | Blog | Home
all groups > flash actionscript > may 2006 >

flash actionscript : Please help me with AS error


DPSwebmaster
5/18/2006 9:23:47 PM
I am using a class called DrawingUtilities.as and the file is placed at the
same root level as my .fla file, but I get an error when testing the movie. The
error is:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: The class or
interface 'actionscriptbible.drawing.DrawingUtilities' could not be loaded.
var duDrawer:DrawingUtilities = new DrawingUtilities(mButton);

Total ActionScript Errors: 1 Reported Errors: 1


why can't it find the damn class!?

here is the entire AS code I am using if that helps...

import actionscriptbible.drawing.DrawingUtilities;

var mLoginButton:MovieClip;
var mSaveButton:MovieClip;

makeLoginScreen();

//the drawButton() function makes a new MovieClip object with a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {

//Make a movieclip object nested in the parent object. Use a unique
// instance name and depth.

var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip = mParent.createEmptyMovieClip("mButton" + nDepth,
nDepth);

//Draw a rectangle in the MovieClip object
var duDrawer:DrawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();

// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;

return mButton;
}

function makeLoginScreen():Void {

//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(), 100, 100, 200,
20);
this.createTextField("tPassword", this.getNextHighestDepth(), 100, 140, 200,
20);
this.createTextField("tMessage", this.getNextHighestDepth(), 100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);

//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;

//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;

mLoginButton.onRelease = function():Void {

//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text =="admin") {
login();
}
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
}
};
}

function login(): Void {

//Remove the TextField and MovieClip objects that made up the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();

//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(), 100, 100, 350,
200);
mSaveButton = drawButton(this, "Save", 100, 25);

//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";

//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;

//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");

// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" : lsoNotes.data.notes;

//When the user clicks and releases the button store the current
//current notes. in the shared object

mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush();
}
}


blemmo
5/18/2006 10:52:58 PM
The name of the class represents the directory structure, starting from the
file where it is imported. So
actionscriptbible.drawing.DrawingUtilities
should be placed in a directory 'drawing' inside a directory
'actionscriptbible' inside the directory where the main file is located.
You could also rename the class to 'DrawingUtilities' and place it in the same
directory as the root file (and probably change some other lines, if it's
necessary... the compiler will tell you).

greets,
blemmo
DPSwebmaster
5/19/2006 2:04:42 PM
thanks,

I can get my form to dispay now, but the first input isn't alowing any text
input

here is tha code

import DrawingUtilities;

var mLoginButton:MovieClip;
var mSaveButton:MovieClip;

makeLoginScreen();

//the drawButton() function makes a new MovieClip object with a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {

//Make a movieclip object nested in the parent object. Use a unique
// instance name and depth.

var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip = mParent.createEmptyMovieClip("mButton" + nDepth,
nDepth);

//Draw a rectangle in the MovieClip object
var duDrawer:DrawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();

// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;

return mButton;
}

function makeLoginScreen():Void {

//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(), 100, 100, 200,
20);
this.createTextField("tPassword", this.getNextHighestDepth(), 100, 140, 200,
20);
this.createTextField("tMessage", this.getNextHighestDepth(), 100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);

//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;

//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;

mLoginButton.onRelease = function():Void {

//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text =="admin") {
login();
}
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
}
};
}

function login(): Void {

//Remove the TextField and MovieClip objects that made up the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();

//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(), 100, 100, 350,
200);
mSaveButton = drawButton(this, "Save", 100, 25);

//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";

//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;

//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");

// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" : lsoNotes.data.notes;

//When the user clicks and releases the button store the current
//current notes. in the shared object

mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush();
}
}


circledot
3/14/2007 4:08:11 PM
Check Username case throughtout

From http://www.developmentnow.com/g/69_2006_5_0_0_758050/Please-help-me-with-AS-error.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button