Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 09-07-2004, 09:00   #1 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 19
Question attachMovie auf Maus-Ereignisse reagieren klappt nicht

Hallo,

ich habe mir ein kleines Zeichnen-Flash zusammengestellt (siehe zip).
Im MC mappe wird bei onPress mittels createEmptyMovieClip der mc zeichnung angelegt und bis zum Doppelklick Punkte gezeichnet (attachMovie vertex usw.) und mit moveTo, lineTo verbunden.

Ich will aber ermöglichen, die Stützpunkte der Linie hinterher noch zu ändern.
Aber es will mir nicht gelingen, den Punkten (mc vertex) Ereignisfunktionen zuzuweisen:

var myVertex = _root.mappe.zeichnung.attachMovie("vertex", "vertex", gDepth, {_x: _root.fromX, _y: _root.fromY});
gDepth += 1;
_root.mappe.zeichnung.vertex.onRollOver=function() {
trace("huhu");
}

die Punkte reagieren nicht auf das mausereignis, z.B. RollOver

Ich habe mir schon viel actionscript angeschaut, komme aber nicht weiter.


Vielen Dank im Voraus

Stefan
Angehängte Dateien
Dateityp: zip STIFT4.zip (6,6 KB, 10x aufgerufen)
gisworks ist offline   Mit Zitat antworten
Alt 09-07-2004, 11:05   #2 (permalink)
The Man Who Wasn't There
 
Benutzerbild von fraggle two
 
Registriert seit: Jul 2003
Ort: BÄRLIN
Beiträge: 1.156
hi,

mach mal so...

ActionScript:
  1. var myVertex = _root.mappe.zeichnung.attachMovie("vertex", "vertex", gDepth, {_x: _root.fromX, _y: _root.fromY});
  2. gDepth += 1;
  3. myVertex.onRollOver=function(){
  4. trace("huhu");
  5. }

gruß
mike
__________________
Dot-Realities
Mike Broders
Berlin

ICQ:105925103

Dot-Realities v4.0 under construction!
fraggle two ist offline   Mit Zitat antworten
Alt 09-07-2004, 11:25   #3 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Beiträge: 1.244
ersetzte mal nein Script mit diesem :

PHP-Code:
// mit Stift zeichnen 
var dragX "";
//Koordinaten während dragStylus();
var dragY "";
var 
firstPoint true;
//initialisierung
var linePoints = new Array ();
//Array mit Arrays [x,y] der geklickten Punkte
var gDepth 1;
//Tiefenvariable der verschiedenen Grafik-Elemente
_root.mappe.onPress = function () {
    
//oder onRelease  
    //trace("onPress");
    
_root.fromX _root.mappe._xmouse;
    
_root.fromY _root.mappe._ymouse;
    
//Prüfen, ob klickPoint identisch mit vorherigem (Doppelklick)
    
if (linePoints.length 1) {
        
lastX linePoints[linePoints.length 1][0];
        
lasty linePoints[linePoints.length 1][1];
        if (
lastX == _root.fromX && lastY == _root.fromY) {
            
//identisch: Doppelclick
            
dropStylus ();
            return;
        }
    }
    
linePoints.push ([_root.fromX_root.fromY]);
    
//klickPoint hinzufügen
    
if (firstPoint == true) {
        var 
myZeichnung _root.mappe.createEmptyMovieClip ("zeichnung"gDepth);
        
gDepth += 1;
        
firstPoint false;
        
//StartPunkt setzen
        
mynode myZeichnung.attachMovie ("node""startPoint"gDepth);
        
gDepth += 1;
        
//set position for node
        
myZeichnung.startPoint._x _root.fromX;
        
myZeichnung.startPoint._y _root.fromY;
        
//dragable stylus setzen        
        
myStift myZeichnung.attachMovie ("mcStylus""mcStylus"gDepth);
        
gDepth += 1;
        
//set starting position for stylus
        
myStift._x _root.fromX;
        
myStift._y _root.fromY;
        
dragStylus ();
        
//drag function aufrufen
    
}
    else {
        var 
myVertex _root.mappe.zeichnung.attachMovie ("vertex""vertex" gDepthgDepth, {_x:_root.fromX_y:_root.fromY});
        
_root.mappe.zeichnung["vertex" gDepth].onRollOver = function () {
            
trace ("huhu");
        };
        
gDepth += 1;
    }
};
function 
dragStylus () {
    
//starts dragging the stylus
    
_root.mappe.zeichnung.mcStylus.startDrag (true00200200);
    
_root.mappe.zeichnung.mcStylus.onMouseMove lineCalc;
}
function 
dropStylus () {
    
delete _root.mappe.onPress;
    
//drops the stylus
    
_root.mappe.zeichnung.mcStylus.stopDrag ();
    
//_root.mappe.zeichnung.mcStylus.onMouseMove = null;
    
_root.mappe.zeichnung.mcStylus.removeMovieClip ();
    
//stift entfernen
    
_root.mappe.zeichnung.attachMovie ("node""endPoint"gDepth 1);
    
_root.mappe.zeichnung.endPoint._x _root.fromX;
    
_root.mappe.zeichnung.endPoint._y _root.fromY;
}
function 
lineCalc () {
    
//calculates the coords of the drag point to 1 above/below min/max so it fits inside the window)
    
if (_root.mappe.zeichnung.mcStylus._x _root.mappe._width) {
        
//wenn stylus außérhalb, dann dragX 1 pt innerhalb 
        
dragX _root.mappe._width 1;
    }
    else {
        if (
_root.mappe.zeichnung.mcStylus._x 0) {
            
dragX 1;
        }
        else {
            
dragX _root.mappe.zeichnung.mcStylus._x;
        }
    }
    if (
_root.mappe.zeichnung.mcStylus._y _root.mappe._height) {
        
dragY _root.mappe._height 1;
    }
    else {
        if (
_root.mappe.zeichnung.mcStylus._y 0) {
            
dragY 1;
        }
        else {
            
dragY _root.mappe.zeichnung.mcStylus._y;
        }
    }
    
_root.mappe.zeichnung.clear ();
    
_root.mappe.zeichnung.lineStyle (20xFF0000);
    
//color of rectangle outline
    //wenn mindestens zwei punkte in linePoints
    
if (linePoints.length 1) {
        
//trace("linePoints > 1");
        //Startpunkt holen
        
startX linePoints[0][0];
        
startY linePoints[0][1];
        
//bisherige Segmente zeichnen
        
for (var 1linePoints.lengthi++) {
            
nextX linePoints[i][0];
            
nextY linePoints[i][1];
            
drawLine (startXstartYnextXnextY);
            
startX nextX;
            
//startpunkt für Folgesegment
            
startY nextY;
        }
    }
    
drawLine (_root.fromX_root.fromYdragXdragY);
    
updateAfterEvent ();
}
//method for drawing the rectangle
function drawLine (xyxxyy) {
    
//trace(x+", "+y+", "+xx+", "+yy);
    // x, y = start point of line
    // xx, yy = end point of line
    
_root.mappe.zeichnung.moveTo (xy);
    
_root.mappe.zeichnung.lineTo (xxyy);

__________________
Mfg aus Brandenburg.

harego

Spiel

Zur Page
harego ist offline   Mit Zitat antworten
Alt 09-07-2004, 12:42   #4 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 19
Danke, aber wo wurde was geändert??

Herzlichsten Dank harego,

aber die Änderung in:

var myVertex = _root.mappe.zeichnung.attachMovie ("vertex", "vertex" + gDepth, gDepth, {_x:_root.fromX, _y:_root.fromY});
_root.mappe.zeichnung["vertex" + gDepth].onRollOver = function () {
trace ("huhu");
};
gDepth += 1;

allein wars wohl nicht.
Wo ist denn was geändert?
gisworks ist offline   Mit Zitat antworten
Alt 09-07-2004, 13:03   #5 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Beiträge: 1.244
Diese von dir genannten Zeilen und:

PHP-Code:
function dropStylus () {
    
delete _root.mappe.onPress; <=== 
__________________
Mfg aus Brandenburg.

harego

Spiel

Zur Page
harego 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



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

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


Copyright ©1999 – 2012 Marc Thiele