Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 18-05-2006, 19:05   #1 (permalink)
Neuer User
 
Registriert seit: Jun 2004
Beiträge: 135
Zeichnenfunktion

Hallo, sicherlich ein nur kleines Problem. Auf der Homepage von macromedia findet sich für das Zeichnen einer Linie in Abhängigkeit von der Position zweier MC folgendes Script:
Code:
// place the two handles for the endpoints
_root.attachMovie("squareHandle", "h1", 5);
_root.attachMovie("squareHandle", "h2", 6);
h1._x = 50;
h1._y = 150;
h2._x = 250;
h2._y = 150;
// create a clip to draw to
_root.createEmptyMovieClip("mc", 1);
// this function redraws the line
function draw() {
	// clear out the old line
	mc.clear();
	// set our line style
	mc.lineStyle(1, 0x000000);
	// draw the line based on handle locations
	mc.moveTo(h1._x, h1._y);
	mc.lineTo(h2._x, h2._y);
}
// call draw every 25 milliseconds
setInterval(draw, 25);
Jetzt wollte ich das ganze in eine eigene Funktion schreiben. Die Linie ist sichtbar aber sie wird beim Bewegung der MC's nicht mehr neu gezeichnet. Wo habe ich den Fehler eingebaut. Danke und Gruß Martina
Code:
function zeichnen(movieClip, pos1X, pos1Y, pos2X, pos2Y) {
	movieClip.clear();
	movieClip.lineStyle(1, 0x000000);
	movieClip.moveTo(pos1X, pos1Y);
	movieClip.lineTo(pos2X, pos2Y);
}
_root.attachMovie("squareHandle", "h1", 5);
_root.attachMovie("squareHandle", "h2", 6);
h1._x = 50;
h1._y = 150;
h2._x = 250;
h2._y = 150;
_root.createEmptyMovieClip("mc", 1);
zeichnen(mc, h1._x, h1._y, h2._x, h2._y);
setInterval(zeichnen, 25);

Geändert von MartinaBiomech (18-05-2006 um 19:54 Uhr)
MartinaBiomech ist offline   Mit Zitat antworten
Alt 18-05-2006, 20:18   #2 (permalink)
muh
 
Benutzerbild von Janoscharlipp
 
Registriert seit: Apr 2002
Ort: Freiburg / Stuttgart
Beiträge: 4.338
durch das Interval wird zwar zeichen aufgerufen, allerdings ohne Parameter.
Du musst also erstmal die Koordinaten der MovieClips auslesen, z.B. so:
PHP-Code:
function zeichnen(movieClippos1Xpos1Ypos2Xpos2Y) {
    
movieClip.clear();
    
movieClip.lineStyle(10x000000);
    
movieClip.moveTo(pos1Xpos1Y);
    
movieClip.lineTo(pos2Xpos2Y);
}
_root.attachMovie("squareHandle""h1"5);
_root.attachMovie("squareHandle""h2"6);
h1._x 50;
h1._y 150;
h2._x 250;
h2._y 150;
_root.createEmptyMovieClip("mc"1);
zeichnen(mch1._xh1._yh2._xh2._y);

function 
positionen(timeline) {
  var 
h1 timeline.h1;
  var 
h2 timeline.h2;
  
zeichnen(timelineh1._xh1._yh2._xh2._y);
}

setInterval(positionen25mc); 
__________________
»Carpe diem«, sagte der Graf. (Terry Pratchett: Ruhig Blut!)
Janoscharlipp ist offline   Mit Zitat antworten
Alt 18-05-2006, 20:22   #3 (permalink)
Neuer User
 
Registriert seit: Jun 2004
Beiträge: 135
Dein Code hat zur Folge das beim Filmtesten die Linie sich kurz zeigt und dann wieder verschwindet. Auch beim Bewegen der MC passiert nicht. Kannst du vielleicht noch mal schauen? Danke Martina
MartinaBiomech ist offline   Mit Zitat antworten
Alt 18-05-2006, 20:45   #4 (permalink)
muh
 
Benutzerbild von Janoscharlipp
 
Registriert seit: Apr 2002
Ort: Freiburg / Stuttgart
Beiträge: 4.338
sry, ich dachte h1 und h2 lägen in mc.

PHP-Code:
function zeichnen(movieClippos1Xpos1Ypos2Xpos2Y) {
    
movieClip.clear();
    
movieClip.lineStyle(10x000000);
    
movieClip.moveTo(pos1Xpos1Y);
    
movieClip.lineTo(pos2Xpos2Y);
}

_root.attachMovie("squareHandle""h1"5);
_root.attachMovie("squareHandle""h2"6);

h1.onPress h2.onPress = function(){this.startDrag(true);};
h1.onRelease h2.onRelease h1.onReleaseOutside h2.onReleaseOutside = function(){this.stopDrag();};

h1._x 50;
h1._y 150;
h2._x 250;
h2._y 150;

_root.createEmptyMovieClip("mc"1);
zeichnen(_root.mch1._xh1._yh2._xh2._y);

function 
positionen(timelinecanvas) {
  var 
h1 timeline.h1;
  var 
h2 timeline.h2;
  
zeichnen(canvash1._xh1._yh2._xh2._y);
  
updateAfterEvent();
}

setInterval(positionen10this_root.mc); 
__________________
»Carpe diem«, sagte der Graf. (Terry Pratchett: Ruhig Blut!)
Janoscharlipp 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 15:27 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele