Einzelnen Beitrag anzeigen
Alt 08-08-2005, 15:57   #1 (permalink)
Madokan
[Matthias K.] - Moderator
 
Benutzerbild von Madokan
 
Registriert seit: Jun 2001
Ort: Berlin/Germany - and the hole World !
Beiträge: 9.971
Post ColorMatrixFilter (Einsatz der Matrix)

Was zum ausprobieren und umbauen.

Erstes Schlüsselbild:
ActionScript:
  1. // Original MC
  2. orig_mc = this.createEmptyMovieClip("orig_mc", 2);
  3. orig_mc._alpha = 0;
  4. orig_mc._visible = false;
  5.  
  6. // Loader
  7. loader = new MovieClipLoader();
  8. loaderListener = new Object();
  9. loaderListener.onLoadComplete = function() {
  10.     play();
  11. };
  12. loader.addListener(loaderListener);
  13. loader.loadClip("testbild.jpg",orig_mc);
  14.  
  15. stop();

Zweites Schlüsselbild
ActionScript:
  1. // kopie_mc stellt eine Kopie des original_mc dar
  2. kopie_mc = this.createEmptyMovieClip("kopie_mc", 1);
  3. bd_obj = new flash.display.BitmapData(orig_mc._width, orig_mc._height, true, 0);
  4. bd_obj.draw(orig_mc);
  5. kopie_mc.attachBitmap(bd_obj,1,"auto",true);
  6.  
  7. // Filter-effekt (Objekt samt Matrix)
  8. graustufen = new flash.filters.ColorMatrixFilter();
  9. graustufen.matrix = new Array(
  10.     1/3,1/3,1/3,0,0,
  11.     1/3,1/3,1/3,0,0,
  12.     1/3,1/3,1/3,0,0,
  13.      000, 1,0);
  14.  
  15. // Anwenden des Filters
  16. kopie_mc.filters = [graustufen];
  17.  
  18. // Kleine Spielerei mit der Maus
  19. kopie_mc.useHandCursor = false;
  20.  
  21. kopie_mc.onRollOver = function() {
  22.     orig_mc._visible = true;
  23.     orig_mc.onEnterFrame = function() {
  24.         this._alpha += 10;
  25.         if (this._alpha>=100) {
  26.             delete this.onEnterFrame;
  27.         }
  28.     };
  29. };
  30.  
  31. kopie_mc.onRollOut = function() {
  32.     orig_mc.onEnterFrame = function() {
  33.         this._alpha -= 10;
  34.         if (this._alpha<=0) {
  35.             this._visible = false;
  36.             delete this.onEnterFrame;
  37.         }
  38.     };
  39. };
  40. stop();

Hinweis
In Flash 8 sind die Bildformate JPG, GIF und PNG zugelassen.
Ihr könnt jedoch auch eine externe SWF einlesen und mit dem Farbeffekt
versehen.

Graustufen:
ActionScript:
  1. graustufen.matrix = new Array(
  2.     1/3,1/3,1/3,0,0,
  3.     1/3,1/3,1/3,0,0,
  4.     1/3,1/3,1/3,0,0,
  5.      000, 1,0);

Rot:
ActionScript:
  1. rotstufen.matrix = new Array(
  2.     1/3,1/3,1/3,0,0,
  3.     0,0,0,0,0,
  4.     0,0,0,0,0,
  5.      000, 1,0);

Grün:
ActionScript:
  1. gruenstufen.matrix = new Array(
  2.     0,0,0,0,0,
  3.     1/3,1/3,1/3,0,0,
  4.     0,0,0,0,0,
  5.      000, 1,0);

Blau:
ActionScript:
  1. blaustufen.matrix = new Array(
  2.     0,0,0,0,0,
  3.     0,0,0,0,0,
  4.     1/3,1/3,1/3,0,0,
  5.      000, 1,0);

Hinweis
Natürlich könnt Ihr für die Matrix auch andere Werte ausprobieren.

Liebe Grüsse
Matze K.
Angehängte Dateien
Dateityp: zip colormatrix_bsp.zip (11,6 KB, 139x aufgerufen)
Madokan ist offline   Mit Zitat antworten