Hallo zusammen
hilft mir bitte jemand, folgenden AS2 - Code AS3 tauglich zu machen.
Ich habe das Script online gefunden, erreich aber den Ersteller nicht um ihn um Hilfe zu bitten. Meine Versuche AS2 in AS3 umzuschreiben schlagen am laufenden Band fehl...
PHP-Code:
// a function to draw squares and rectangles. this is used to make the dots in the picture
MovieClip.prototype.drawRect = function(x, y, width, height, colour, alpha) {
this.moveTo(x, y);
this.beginFill(colour, alpha);
this.lineTo(x + width, y);
this.lineTo(x + width, y + height);
this.lineTo(x, y + height);
this.lineTo(x, y);
this.endFill();
};
// an array containing the x and y coordinates of the points in the picture (in the order they should be joined)
// this example is a simple square
var points = new Array();
points[0] = {x: 100, y: 100};
points[1] = {x: 100, y: 150};
points[2] = {x: 150, y: 150};
points[3] = {x: 150, y: 100};
points[4] = {x: 170, y: 120};
points[5] = {x: 120, y: 110};
var index = 0;
// create a movie clip to hold the picture, in your version you may want to create the clip yourself to draw the image
this.createEmptyMovieClip("drawing", 1);
// make a button for each point
var numPoints = points.length;
for (var i = 0; i < numPoints; ++i) {
this.drawing.createEmptyMovieClip("button" + i, i);
this.drawing["button" + i]._x = points[i].x - 2.5;
this.drawing["button" + i]._y = points[i].y - 2.5;
// draw a 5x 5 pixel black square to indicate the point
this.drawing["button" + i].drawRect(0, 0, 5, 5, 0x000000, 100);
// add a label to the point indicating the order they should be clicked
this.drawing["button" + i].createTextField("label", 1, 5, 5, 10, 20);
this.drawing["button" + i].label.text = i + 1;
this.drawing["button" + i].id = i;
// what to do when the point is clicked
this.drawing["button" + i].onPress = function() {
if (this.id == index) { // if this is the next point
// join a line from the end of the last line to here
this._parent.lineTo(points[index].x, points[index].y);
// keep track of where we are in the array, if we reach the end go back to the beginning
index = (index < points.length - 1) ? index + 1 : 0;
if (this.id == 5){
this._parent.lineTo(points[index].x, points[index].y);
trace("fertig");
}
}
};
}
// set the line that will be used to join the dots as 1 pixel wide and black
this.drawing.lineStyle(1, 0x000000, 100);
// start off from the first point in the array
this.drawing.moveTo(points[0].x, points[0].y);
Für Eure Hilfe will ich mich jetzt schon im voraus bedanken
Grüße
Schiggi2