Fatty Owl
%Europe/Berlin %591 %2005, 14:11
ik ben voor te oefenen een class aan het schrijven voor een rechthoek te tekenen. Ik heb begrepen uit de errors dat een class geen createEmptyMovieClip kan gebruiken, ook niet binnen een functie? hoe kan ik dit dan oplossen? dit is mijn code:
class Box {
public var Width:Number;
public var Height:Number;
public function setBoxSize(W:Number, H:Number) {
if (W == undefined) {
W = 50;
}
if (H == undefined) {
H = 50;
}
Width = W;
Height = H;
}
public function setLineStyle(Linethickness:Number, Linecolor:String, Fillcolor:String, Fillalpha:Number) {
var LineStyle:Array = [Linethickness, Linecolor, Fillcolor, Fillalpha];
}
public function Draw() {
var box:MovieClip = _root.createEmptyMovieClip("box", 10);
box.lineStyle(LineStyle[0], LineStyle[1], 100);
if (LineStyle[2] !== undefined) {
if (LineStyle[3] == undefined) {
LineStyle[3] = 100;
}
box.beginFill(LineStyle[2], LineStyle[3]);
}
box.lineTo(0, Width);
box.lineTo(Width, Height);
box.lineTo(Width, 0);
box.lineTo(0, 0);
}
}
En dit zijn de errors die ik krijg als ik typ var box:Box = new Box(); :
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 19: There is no property with the name 'LineStyle'.
box.lineStyle(LineStyle[0], LineStyle[1], 100);
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 20: There is no property with the name 'LineStyle'.
if (LineStyle[2] !== undefined) {
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 21: There is no property with the name 'LineStyle'.
if (LineStyle[3] == undefined) {
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 22: There is no property with the name 'LineStyle'.
LineStyle[3] = 100;
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 24: There is no property with the name 'LineStyle'.
box.beginFill(LineStyle[2], LineStyle[3]);
Total ActionScript Errors: 5 Reported Errors: 5
class Box {
public var Width:Number;
public var Height:Number;
public function setBoxSize(W:Number, H:Number) {
if (W == undefined) {
W = 50;
}
if (H == undefined) {
H = 50;
}
Width = W;
Height = H;
}
public function setLineStyle(Linethickness:Number, Linecolor:String, Fillcolor:String, Fillalpha:Number) {
var LineStyle:Array = [Linethickness, Linecolor, Fillcolor, Fillalpha];
}
public function Draw() {
var box:MovieClip = _root.createEmptyMovieClip("box", 10);
box.lineStyle(LineStyle[0], LineStyle[1], 100);
if (LineStyle[2] !== undefined) {
if (LineStyle[3] == undefined) {
LineStyle[3] = 100;
}
box.beginFill(LineStyle[2], LineStyle[3]);
}
box.lineTo(0, Width);
box.lineTo(Width, Height);
box.lineTo(Width, 0);
box.lineTo(0, 0);
}
}
En dit zijn de errors die ik krijg als ik typ var box:Box = new Box(); :
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 19: There is no property with the name 'LineStyle'.
box.lineStyle(LineStyle[0], LineStyle[1], 100);
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 20: There is no property with the name 'LineStyle'.
if (LineStyle[2] !== undefined) {
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 21: There is no property with the name 'LineStyle'.
if (LineStyle[3] == undefined) {
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 22: There is no property with the name 'LineStyle'.
LineStyle[3] = 100;
**Error** C:\Documents and Settings\Kobe\My Documents\AS\Box.as: Line 24: There is no property with the name 'LineStyle'.
box.beginFill(LineStyle[2], LineStyle[3]);
Total ActionScript Errors: 5 Reported Errors: 5