Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-10-2005, 10:33   #1 (permalink)
Neuer User
 
Registriert seit: Nov 2003
Beiträge: 7
Question Linie zeichnen und verändern

Hallo,

ist folgendes möglich?

Ich möchte eine Linie mit Actionscript zeichnen. // funktioniert

Wenn man jetzt mit der Maus auf die Linie klickt soll es möglich sein einen weiteren Punkt herauszuziehen und die Linie soll an dieser Stelle geknickt werden.

War das verständlich?

Ist es auch möglich Start- und End- Punkt der Linie per Drag&Prop zu verändern?

Hat vielleicht jemand ein Code-Beispiel oder einen Link dazu?

Danke und Grüße, Benny
Benny80 ist offline   Mit Zitat antworten
Alt 13-10-2005, 13:05   #2 (permalink)
-
 
Benutzerbild von pape
 
Registriert seit: Jan 2004
Beiträge: 3.002
Hm... Hab grad mal was gemacht... meinst sowas?
ActionScript:
  1. _global.tl = _root;
  2. _global.p_id = 0;
  3. _global.p_arr = [];
  4. _global.l_arr = [];
  5. function neuen_punkt (x, y, h, no_h) {
  6.     if (!no_h) {
  7.         var p = tl.createEmptyMovieClip("p"+p_id, p_id+100);
  8.         p.x = x;
  9.         p.y = y;
  10.         with (p) {
  11.             lineStyle(0, 0xFF0000, 100);
  12.             beginFill(0xFF0000);
  13.             moveTo(x-3, y-3);
  14.             lineTo(x+3, y-3);
  15.             lineTo(x+3, y+3);
  16.             lineTo(x-3, y+3);
  17.             lineTo(x-3, y-3);
  18.             endFill();
  19.         }
  20.         if (h || h===0) {
  21.             _global.p_arr.splice(h+1, 0, p);
  22.         } else {
  23.             _global.p_arr.push(p);
  24.         }
  25.         _global.p_id++;
  26.         if (p_arr.length>=2) {
  27.             linien_ziehen();
  28.         }
  29.     } else {
  30.         startRelease(h);
  31.     }
  32. }
  33. function linien_ziehen () {
  34.     while (l_arr.length>0) {
  35.         l_arr[0].removeMovieClip();
  36.         _global.l_arr.splice(0,1);
  37.     }
  38.     for (var i = 0; i<p_arr.length-1; i++) {
  39.         var l = tl.createEmptyMovieClip("l"+i, 10000+i);
  40.         _global.l_arr.push(l);
  41.         with(l) {
  42.             lineStyle(3, 0x000000, 100);
  43.             moveTo(p_arr[i].x, p_arr[i].y);
  44.             lineTo(p_arr[i+1].x, p_arr[i+1].y);
  45.         }
  46.     }
  47. }
  48. tl.onMouseDown = function () {
  49.     var no_h = false;
  50.     var h = false;
  51.     if (l_arr.length>0) {
  52.         for (var i = 0; i<l_arr.length; i++) {
  53.             for (var j = 0; j<p_arr.length; j++) {
  54.                 if (p_arr[j].hitTest(tl._xmouse,tl._ymouse, false)) {
  55.                     no_h = true;
  56.                     h = j;
  57.                     break;
  58.                 }
  59.             }
  60.             if (l_arr[i].hitTest(tl._xmouse,tl._ymouse, true)) {
  61.                 if (!no_h) {
  62.                     h = i;
  63.                 }
  64.                 break;
  65.             }
  66.         }
  67.     }
  68.     neuen_punkt(tl._xmouse, tl._ymouse, h, no_h);
  69. }
  70. function startRelease (pid) {
  71.     tl.pid = pid;
  72.     tl.onMouseUp = function () {
  73.         delete this.onMouseUp;
  74.         p_arr[this.pid].stopDrag();
  75.         p_arr[this.pid].x = tl._xmouse;
  76.         p_arr[this.pid].y = tl._ymouse;
  77.         delete this.pid;
  78.         if (p_arr.length>=2) {
  79.             linien_ziehen();
  80.         }
  81.     }
  82.     p_arr[pid].startDrag();
  83. }
Einfach in nen leeren Film packen und ausführen...

grz
pape
pape ist offline   Mit Zitat antworten
Alt 13-10-2005, 18:22   #3 (permalink)
Neuer User
 
Registriert seit: Nov 2003
Beiträge: 7
Thumbs up

Hallo pape,

vielen Dank das funktioniert ganz gut.
Damit kann ich jetzt ein wenig herumexperimentieren.


Grüße, Benny
Benny80 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 19:34 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele