{lang: 'de'}
Flashhilfe.de - Flash Community

Zeichnen zur Laufzeit in AS3 [Flash 11]

 


AntwortenRegistrieren Seite1  

Bergmann0#1
Benutzerbild von Bergmann0
Beiträge: 4
Registriert: May 2011

14.06.2011, 14:37

Bin gerade dabei, ein einfaches Linien-zeichnen von AS2 nach AS3 zu portieren
Das sah so aus:
ActionScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
this.createEmptyMovieClip("draw_mc", 10);

this.draw_mc.lineStyle(2.5, "0x333333");

this.onMouseDown = function()
{
     _root.draw_mc.moveTo(this._xmouse, this._ymouse);
     
     this.onEnterFrame = function()
     {
        this.my_txt.text = this.my_txt.text + "X-Position :" + this._xmouse + " - ";
        this.my_txt.text = this.my_txt.text + "Y-Position :" + this._ymouse + "n";
        _root.draw_mc.lineTo(this._xmouse, this._ymouse);
        this.my_txt.scroll += this.my_txt.maxhscroll;
     };
     
     updateAfterEvent();
};
this.onMouseUp = function()
{
     delete this.onEnterFrame;
}


Nun der versuch in AS3; ist mir auch unerklärlich wieso sowas einfaches nicht mehr geht, weil ja die ganze Struktur geändert wurde. Irgendwie ist Shape jetzt ein statisches Object, bei dem danach zur Laufzeit nichts mehr verändert werden kann.

ActionScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import flash.display.Graphics;
var myShape:Shape = new Shape();

myShape.graphics.lineStyle(2, 0x990000, .75);
myShape.graphics.beginFill(0x00FF00);
myShape.graphics.moveTo(100, 100);

stage.addEventListener(MouseEvent.MOUSE_MOVE, reportClick);

this.addChild(myShape);

function reportClick(event:MouseEvent):void
{
      //trace(event.currentTarget.toString() +         " dispatches MouseEvent. Local coords [" +         event.localX + "," + event.localY + "] Stage coords [" +         event.stageX + "," + event.stageY + "]");
   trace("Stage coords [" +         event.stageX + "," + event.stageY + "]");
     myShape.lineTo(event.stageX, event.stageY);
}
Schlagwörter: AS3.0, Drawing
Geändert von Bergmann0 am 14.06.11 um 14:40 Uhr
BackToDos#2
Benutzerbild von BackToDos
Beiträge: 571
Wohnort: LE
Registriert: Apr 2006

14.06.2011, 17:26