Malerei Flash CS3: Echtzeit Lösch-Funktion

Beginnend mit den Codes versehen in Flash CS3 Erstellen Sie eine Farbe und Durchführung kleinerer Änderungen, erheblich verbessern kann das Instrument der "löschen". Hinzufügen einer Form nicht sichtbar ist, können Sie es als einen "Plan" zu verwenden, um den Lauf draw() Mischmodus "löschen". Wie im Beispiel unten gezeigt, nach der Zeichnung etwas, halten Sie die Strg-Taste und die Wirkung der "Annullierung" ist jetzt in Echtzeit.

Loading Flash ...

Der Code wird wie folgt - Quelle :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
. MouseEvent ; Import flash.events. MouseEvent ;
. BitmapData ; Import flash.display. BitmapData ;
. Bitmap ; Import flash.display. Bitmaps ;
. GradientType ; . import flash.display GradientType ;
/ /
. Matrix ; flash.geom Importe. Matrix ;
/ /
Boolean = false ; md var: Boolean = false;
/ /
Sprite = new Sprite ( ) ; var event_spr: Sprite = new Sprite ();
event_spr ) ; addChild (event_spr);
/ /
Number = event_spr . stage . stageWidth ; var area_width: Anzahl = event_spr Praktika stageWidth;..
Number = event_spr . stage . stageHeight - 32 ; var area_height: Anzahl .. = event_spr Praktika stageHeight - 32;
/ /
String = GradientType . LINEAR ; fillType var: String = GradientType . LINEAR;
: Array = [ 0xFF0000 , 0x00FF00 , 0x0000ff ] ; var Farben: Array = [0xFF0000, 0x00FF00, 0x0000FF];
: Array = [ 1 , 1 , 1 ] ; var alphas: Array = [1, 1, 1];
: Array = [ 0 , 128 , 255 ] ; var ratios: Array = [0, 128, 255];
String = SpreadMethod . PAD ; spreadMethod var: String = SpreadMethod PAD;.
: Matrix = new Matrix ( ) ; var matrix: Matrix = new Matrix ();
createGradientBox ( area_width , area_height , 1 , 0 , 0 ) ; . Matrix createGradientBox (area_width, area_height, 1, 0, 0);
/ /
event_spr . graphics ) { mit (event_spr. Grafiken) {
fillType , colors , alphas , ratios , matrix , spreadMethod ) ; beginGradientFill (fillType, Farben, Alphas, Verhältnisse, Matrix, spreadMethod);
0 , 0 , area_width , area_height ) ; drawRect (0, 0, area_width, area_height);
; endFill ();
}
/ / Paint-Ereignis
( MouseEvent . MOUSE_DOWN , _onMouseDown ) ; . event_spr addEventListener ( MouseEvent MOUSE_DOWN, _onMouseDown.);
( MouseEvent . MOUSE_MOVE , _onMouseMove ) ; . event_spr addEventListener ( MouseEvent MOUSE_MOVE, _onMouseMove.);
( MouseEvent . MOUSE_UP , _onMouseUp ) ; . event_spr addEventListener ( MouseEvent MOUSE_UP, _onMouseUp.);
( MouseEvent . MOUSE_OUT , _onMouseUp ) ; . event_spr addEventListener ( MouseEvent MOUSE_OUT, _onMouseUp.);
/ /
BitmapData = new BitmapData ( event_spr . width , event_spr . height , true , 0 ) ; var bmpd: BitmapData = new BitmapData (event_spr. Breite, Höhe event_spr, true, 0.);
Bitmap = new Bitmap ( bmpd ) ; var bmp: Bitmap = new Bitmap (bmpd);
bmp ) ; addChild (bmp);
/ /
/ / Temporäre Form
Shape = new Shape ( ) ; var draw_shape: Form = new Form ();
draw_shape ) ; addChild (draw_shape);
/ /
/ / Shape nicht sichtbar ist, verwendet für die "Stornierung"
Shape = new Shape ( ) ; var erase_shape: Form = new Form ();

/ /
e : MouseEvent ) : void { _onMouseDown Funktion (e: MouseEvent ): void {
) ; debug ("_onMouseDown");
. lineStyle ( 10 , 0xffffff , 1 ) ; .. draw_shape Grafiken lineStyle (10, 0xffffff, 1);
. lineStyle ( 20 , 0xffffff , 1 ) ; .. erase_shape Grafiken lineStyle (20, 0xffffff, 1);
. moveTo ( e . localX , e . localY ) ; .. draw_shape Grafiken moveTo (and. localX und localY.);
. moveTo ( e . localX , e . localY ) ; .. erase_shape Grafiken moveTo (and. localX und localY.);
md = true;
}
/ /
e : MouseEvent ) : void { _onMouseUp Funktion (e: MouseEvent ): void {
md = false;
. draw ( draw_shape ) ; .. bmp bitmapData draw (draw_shape);
. clear ( ) ; . draw_shape Grafiken clear ().;
. clear ( ) ; . erase_shape Grafiken clear ().;
}
/ /
e : MouseEvent ) : void { _onMouseMove Funktion (e: MouseEvent ): void {
) ; debug ("_onMouseMove");
md && ! e . ctrlKey ) { if (md & &! und. ctrlKey) {
. lineTo ( e . localX , e . localY ) ; .. draw_shape Grafiken lineTo (and. localX und localY.);
( md && e . ctrlKey ) { } Else if (md & & und. CtrlKey) {
. lineTo ( e . localX , e . localY ) ; .. erase_shape Grafiken lineTo (and. localX und localY.);
. draw ( erase_shape , null , null , "erase" ) ; bmp bitmapData draw (erase_shape, null, null, "löschen")..;
}
}
/ /
v : String ) : void { Funktion debug (v: String ): void {
: Date = new Date ( ) ; var d: Date = new Date ();
d . getMinutes ( ) + ":" + d . getSeconds ( ) + ":" + d . getMilliseconds ( ) + ": " + v ) ; trace (d. getMinutes () + "" + d. getSeconds () + "" + d. getMilliseconds () + "" + st);
}

): Wir haben eine neue Form, fügte erase_shape nicht sichtbar (es war nicht jedem durchgeführt addChild() ):

1
2
3
...
/ / Shape nicht sichtbar ist, verwendet für die "Stornierung"
Shape = new Shape ( ) ; var erase_shape: Form = new Form ();

Das Stück Code, das kümmert Zeichnung wurde für die Steuer-Taste eingeführt und, wenn diese Taste gedrückt, ist daran interessiert, genau die Form erase_shape und kopiert die Bitmap:

1
2
3
....
. lineTo ( e . localX , e . localY ) ; .. erase_shape Grafiken lineTo (and. localX und localY.);
. draw ( erase_shape , null , null , "erase" ) ; bmp bitmapData draw (erase_shape, null, null, "löschen")..;

3 Kommentare zu "Malerei Flash CS3: Echtzeit Lösch-Funktion"

  1. 20. November 2009 Greg:

    Ein Mejora Hebel y en la Bauart mí der drenaje Hizo ein clase.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    package {

    . Sprite ; Import flash.display. Sprite ;
    . MouseEvent ; Import flash.events. MouseEvent ;
    . BitmapData ; Import flash.display. BitmapData ;
    . Bitmap ; Import flash.display. Bitmaps ;
    . GradientType ; . import flash.display GradientType ;
    . SpreadMethod ; Import flash.display. SpreadMethod ;
    . Shape ; Import flash.display. Form ;
    . Matrix ; flash.geom Importe. Matrix ;
    . setInterval ; . flash.utils Importe setInterval;
    . clearInterval ; flash.utils Importe clearInterval.;

    BitmapErase extends Sprite { BitmapErase öffentlichen Klasse erweitert Sprite {

    md : Boolean = false ; md private var: Boolean = false;
    event_spr : Sprite ; private var event_spr: Sprite ;
    area_width : Number ; area_width private var: Anzahl ;
    area_height : Number ; area_height private var: Anzahl ;
    fillType : String = GradientType . LINEAR ; fillType private var: String = GradientType . LINEAR;
    colors : Array = [ 0xFF0000 , 0x00FF00 , 0x0000ff ] ; private var Farben: Array = [0xFF0000, 0x00FF00, 0x0000FF];
    alphas : Array = [ 1 , 1 , 1 ] ; private var alphas: Array = [1, 1, 1];
    ratios : Array = [ 0 , 128 , 255 ] ; private var ratios: Array = [0, 128, 255];
    spreadMethod : String = SpreadMethod . PAD ; spreadMethod private var: String = SpreadMethod . PAD;
    matrix : Matrix = new Matrix ( ) ; private var matrix: Matrix = new Matrix ();
    erase_shape : Shape ; private var erase_shape: Form ;
    draw_shape : Shape ; private var draw_shape: Form ;
    bmpd : BitmapData ; private var bmpd: BitmapData ;
    bmp : Bitmap ; private var bmp: Bitmap ;
    interval : uint ; private var interval: uint ;

    BitmapErase ( ) { BitmapErase public function () {
    ( ) ; draw_shape = new Form ();
    draw_shape ) ; addChild (draw_shape);
    ( ) ; erase_shape = new Form ();
    ( ) ; event_spr = new Sprite ();
    event_spr ) ; addChild (event_spr);
    . stageWidth ; . area_width = event_spr Praktika stageWidth.;
    . stageHeight - 32 ; . area_height = event_spr Praktika stageHeight - 32.;
    createGradientBox ( area_width , area_height , 1 , 0 , 0 ) ; . Matrix createGradientBox (area_width, area_height, 1, 0, 0);

    . beginGradientFill ( fillType , colors , alphas , ratios , matrix , spreadMethod ) ; .. event_spr Grafiken beginGradientFill (fillType, Farben, Alphas, Verhältnisse, Matrix, spreadMethod);
    . drawRect ( 0 , 0 , area_width , area_height ) ; .. event_spr Grafiken drawRect (0, 0, area_width, area_height);
    . endFill ( ) ; . event_spr Grafiken endFill ().;

    ( MouseEvent . MOUSE_DOWN , _onMouseDown ) ; . event_spr addEventListener ( MouseEvent MOUSE_DOWN, _onMouseDown.);
    ( MouseEvent . MOUSE_MOVE , _onMouseMove ) ; . event_spr addEventListener ( MouseEvent MOUSE_MOVE, _onMouseMove.);
    ( MouseEvent . MOUSE_UP , _onMouseUp ) ; . event_spr addEventListener ( MouseEvent MOUSE_UP, _onMouseUp.);
    ( MouseEvent . MOUSE_OUT , _onMouseUp ) ; . event_spr addEventListener ( MouseEvent MOUSE_OUT, _onMouseUp.);

    ( event_spr . width , event_spr . height , true , 0 ) ; bmpd = new BitmapData (event_spr. Breite, Höhe event_spr, true, 0.);
    ( bmpd ) ; bmp = new Bitmap (bmpd);
    bmp ) ; addChild (bmp);
    }

    _onMouseDown ( e : MouseEvent ) : void { _onMouseDown private function (e: MouseEvent ): void {
    / / Debug ("_onMouseDown");
    . lineStyle ( 10 , 0xffffff , 1 ) ; .. draw_shape Grafiken lineStyle (10, 0xffffff, 1);
    . lineStyle ( 20 , 0xffffff , 1 ) ; .. erase_shape Grafiken lineStyle (20, 0xffffff, 1);
    . moveTo ( e . localX , e . localY ) ; .. draw_shape Grafiken moveTo (and. localX und localY.);
    . moveTo ( e . localX , e . localY ) ; .. erase_shape Grafiken moveTo (and. localX und localY.);
    md = true;
    }
    _onMouseUp ( e : MouseEvent ) : void { _onMouseUp private function (e: MouseEvent ): void {
    md = false;
    . clear ( ) ; . draw_shape Grafiken clear ().;
    . clear ( ) ; . erase_shape Grafiken clear ().;
    interval ) ; clearInterval (Intervall);
    }
    _onMouseMove ( e : MouseEvent ) : void { _onMouseMove private function (e: MouseEvent ): void {
    / / Debug ("_onMouseMove");
    md && ! e . ctrlKey ) { if (md & &! und. ctrlKey) {
    . lineTo ( e . localX , e . localY ) ; .. draw_shape Grafiken lineTo (and. localX und localY.);
    drawNow , 1 ) ; interval = setInterval (drawNow, 1);
    ( md && e . ctrlKey ) { } Else if (md & & und. CtrlKey) {
    . lineTo ( e . localX , e . localY ) ; .. erase_shape Grafiken lineTo (and. localX und localY.);
    . draw ( erase_shape , null , null , "erase" ) ; bmp bitmapData draw (erase_shape, null, null, "löschen")..;
    }
    }
    debug ( v : String ) : void { public function debug (v: String ): void {
    : Date = new Date ( ) ; var d: Date = new Date ();
    d . getMinutes ( ) + ":" + d . getSeconds ( ) + ":" + d . getMilliseconds ( ) + ": " + v ) ; trace (d. getMinutes () + "" + d. getSeconds () + "" + d. getMilliseconds () + "" + st);
    }
    drawNow ( ) : void { private function drawNow (): void {
    . draw ( draw_shape ) ; .. bmp bitmapData draw (draw_shape);
    }
    }
    }
  2. 27. Januar 2011 Sarah-Jane:

    Das ist total genial! Great job. Ist es möglich, die gleiche Sache, nur hier ist es Löschen eines movieclip Aussetzen des Hintergrundbildes darunter ist?

    Das ist total genial! Great job. Sie können das Gleiche hier, außer dass sich das Löschen eines Clips des Films, dass das Hintergrundbild setzt?

Hinterlasse einen Kommentar

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL