Zurück   Flashforum > Flash > ActionScript > Spielkonzepte und Spieleprogrammierung

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 01-11-2011, 09:53   #1 (permalink)
Neuer User
 
Registriert seit: Jan 2011
Beiträge: 90
Join the Points von AS2 auf AS3 umschreiben

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(xywidthheightcolouralpha) {
    
this.moveTo(xy);
    
this.beginFill(colouralpha);
    
this.lineTo(widthy);
    
this.lineTo(widthheight);
    
this.lineTo(xheight);
    
this.lineTo(xy);
    
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] = {x100y100};
points[1] = {x100y150};
points[2] = {x150y150};
points[3] = {x150y100};
points[4] = {x170y120};
points[5] = {x120y110};
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 
0numPoints; ++i) {
    
this.drawing.createEmptyMovieClip("button" ii);
    
this.drawing["button" i]._x points[i].2.5;
    
this.drawing["button" i]._y points[i].2.5;
    
// draw a 5x 5 pixel black square to indicate the point
    
this.drawing["button" i].drawRect(00550x000000100);
    
// add a label to the point indicating the order they should be clicked
    
this.drawing["button" i].createTextField("label"1551020);
    
this.drawing["button" i].label.text 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].xpoints[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 0;
            if (
this.id == 5){
                
this._parent.lineTo(points[index].xpoints[index].y);
                
trace("fertig");
                }
            
        }
    };
}
// set the line that will be used to join the dots as 1 pixel wide and black
this.drawing.lineStyle(10x000000100);
// start off from the first point in the array
this.drawing.moveTo(points[0].xpoints[0].y); 
Für Eure Hilfe will ich mich jetzt schon im voraus bedanken

Grüße
Schiggi2
Schiggi2 ist offline   Mit Zitat antworten
Alt 02-11-2011, 07:55   #2 (permalink)
Keine Panik
 
Registriert seit: Apr 2010
Ort: Düsseldorf (im ernst)
Beiträge: 1.869
PHP-Code:
var drawing:Shapeindex:intbuttons:Array;
init();

createPoints([
    new 
Point(100100),
    new 
Point(100150),
    new 
Point(150150),
    new 
Point(150100),
    new 
Point(100100)
]);



function 
init():void
{
    
drawing = new Shape();
    
addChild(drawing);
    
buttons = [];
    
    
addEventListener(MouseEvent.CLICKonClick);
}

function 
createPoints(points:Array):void
{
    
removePoints();
    
drawing.graphics.clear();
    
    for 
each(var p:Point in points){
        var 
btn:Sprite = new Sprite();
            
btn.graphics.beginFill(00);
            
btn.graphics.drawRect(0010);    //für Grobmotoriker
            
btn.graphics.beginFill(0x000000);
            
btn.graphics.drawRect(-2.5, -2.555);
            
btn.graphics.endFill();
            
btn.p.x;
            
btn.p.y;
        
addChildAt(btn0);
        
buttons.push(btn);
    }
}

function 
removePoints():void
{
    for 
each(var btn:Sprite in buttons){
        if(
btn.parentbtn.paren.removeChild(btn);
    }
    
buttons.length index 0;
}

function 
onClick(e:Event):void
{
    var 
t:DisplayObject DisplayObject(e.target);
    if(
!= buttons[index]) return;
    
    if(
index == 0){
        
drawing.graphics.lineStyle(20xFF0000);
        
drawing.graphics.moveTo(t.xt.y);
    }else{
        
drawing.graphics.lineTo(t.xt.y);
    }
    
    
//wenn zwei Punkte übereinander liegen feuertn nur der oberste ein Event
    //deshalb deaktiviere ich das für alle abgelaufenen Punkte.
    
t.mouseEnabled false;
    
//oder so:
    //removeChild(t);
    
    
if(++index == buttons.length){
        
trace("fertig");
        
removePoints();
    }

__________________
greetz Thomas

plz RTFM & Coding Conventions
thomas_E ist offline   Mit Zitat antworten
Alt 02-11-2011, 14:34   #3 (permalink)
Neuer User
 
Registriert seit: Jan 2011
Beiträge: 90
Hi Thomas

wahnsinn - einfach klasse- und ich hatte mich da mit umständlichen functions rumgeschlagen, die bis auf Fehlermeldungen nichts generierten

Nochmals vielen, vielen, vielen DANK

Grüßung

Schiggi
Schiggi2 ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
JOIN oder nicht join ? ran2 PHP und MySQL 7 24-01-2009 10:24
Unterschied zwischen inner join und equi-Join Jochi PHP und MySQL 3 03-06-2008 16:29
Cue points sunsetpictures Flash 8 2 14-05-2007 16:58
_root.points = points+1 Anfänger123456 Flash Einsteiger 2 18-01-2007 18:43
flv cue points nonverbla Flash 8 1 19-11-2006 16:32


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:18 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele