Zurück   Flashforum > Flash > Flash Fortgeschritten > Flash 8

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 25-09-2005, 20:51   #1 (permalink)
Neuer User
 
Registriert seit: May 2003
Ort: Berlin
Beiträge: 51
Bildausschnitt

hat jemand mal ein Beispiel wie ich nen Bildausschnitt mit BitmapData mache, welcher weg ist da der einfachste, mir schwebt da so was vor wie ein Puzzel oder so =)

Michael
pixelschlampe ist offline   Mit Zitat antworten
Alt 26-09-2005, 09:15   #2 (permalink)
Neuer User
 
Registriert seit: May 2003
Ort: Berlin
Beiträge: 51
ok ich antworte mir mal selber =), hab es geschaft hier der undokumentierte/optimierte Code:

ActionScript:
  1. import mx.utils.Delegate;
  2. var b = cont._width / 4;
  3. var h = cont._height / 4;
  4. var MovArr:Array = [];
  5. bitmapDat = new flash.display.BitmapData (400, 300, true, 0x000000);
  6. bitmapDat.draw (cont);
  7. btn.addEventListener ("click", Delegate.create (this, clickHandler));
  8. function clickHandler ()
  9. {
  10.     setNewDraw (cont);
  11. }
  12. btn2.addEventListener ("click", Delegate.create (this, clickHandler2));
  13. function clickHandler2 ()
  14. {
  15.     setNewDraw (cont2);
  16. }
  17. btn3.addEventListener ("click", Delegate.create (this, mische));
  18. function mische ()
  19. {
  20.     for (var i = 0; i < _root.MovArr.length; i++)
  21.     {
  22.         _root.MovArr[i]._y = random (200);
  23.         _root.MovArr[i]._x = random (300);
  24.     }
  25. }
  26. setNewDraw (cont);
  27. function setNewDraw (e)
  28. {
  29.     bitmapDat = new flash.display.BitmapData (400, 300, true, 0x000000);
  30.     bitmapDat.draw (e);
  31.     for (var i = 0; i < 4; i++)
  32.     {
  33.         for (var j = 0; j < 4; j++)
  34.         {
  35.             if (!_root["container" + i + j])
  36.             {
  37.                 _root.createEmptyMovieClip ("container" + i + j, this.getNextHighestDepth ());
  38.                 _root["container" + i + j].createEmptyMovieClip ("conB", 1);
  39.                 _root["container" + i + j]._x = (Stage.width / 2) - (_root.cont._width / 2);
  40.                 _root["container" + i + j]._y = (Stage.height / 2) - (_root.cont._height / 2);
  41.                 _root.MovArr.push (_root["container" + i + j]);
  42.             }
  43.             _root["bitmapData" + i + j] = new flash.display.BitmapData (400, 300, true, 0xCCCCCC);
  44.             _root["container" + i + j]["conB"].attachBitmap (_root["bitmapData" + i + j], 2);
  45.             var t = j * _root.b;
  46.             var z = i * _root.h;
  47.             rect = new flash.geom.Rectangle (t, z, _root.b, _root.h);
  48.             _root["bitmapData" + i + j].copyPixels (_root.bitmapDat, rect, rect);
  49.             _root["container" + i + j].createEmptyMovieClip ("mask", 2);
  50.             with (_root["container" + i + j]["mask"])
  51.             {
  52.                 lineStyle (1, 0x000000, 100);
  53.                 beginFill (0x000000, 100);
  54.                 lineTo (0, 0);
  55.                 lineTo (_root.b, 0);
  56.                 lineTo (_root.b, _root.h);
  57.                 lineTo (0, _root.h);
  58.                 lineTo (0, 0);
  59.                 endFill ();
  60.                 _x = t;
  61.                 _y = z;
  62.             }
  63.             _root["container" + i + j]["conB"].setMask (_root["container" + i + j]["mask"]);
  64.             _root["container" + i + j].onPress = function ()
  65.             {
  66.                 this.startDrag ();
  67.                 this.swapDepths (_root.getNextHighestDepth ());
  68.             };
  69.             _root["container" + i + j].onRelease = function ()
  70.             {
  71.                 this.stopDrag ();
  72.             };
  73.         }
  74.     }
  75. }

und was man damit machen kann könnt Ihr Euch hier anschauen.
pixelschlampe ist offline   Mit Zitat antworten
Alt 26-09-2005, 09:38   #3 (permalink)
AKQA
 
Benutzerbild von m00n
 
Registriert seit: Jul 2002
Ort: London
Beiträge: 300
gab auf der flashforum tour ein anderes nettes Beispiel dazu, war glaub ich von Andre Michelle.

Im Prinzip genau das gleiche was du mit Fotos gemacht hast. Nur mit einem Video
__________________
Never argue with an idiot. They bring you down to their level, then beat you with experience.
m00n ist offline   Mit Zitat antworten
Alt 26-09-2005, 09:43   #4 (permalink)
Neuer User
 
Registriert seit: May 2003
Ort: Berlin
Beiträge: 51
klar geht auch mit Videos, siehe hier.
pixelschlampe ist offline   Mit Zitat antworten
Alt 26-09-2005, 09:48   #5 (permalink)
faulancer
 
Benutzerbild von zerlettino
 
Registriert seit: Feb 2003
Beiträge: 281
das beste ist aber, dass man damit dynamisch geladene Bilder duplizieren kann

grüße
zerlettino ist offline   Mit Zitat antworten
Alt 26-09-2005, 09:50   #6 (permalink)
AKQA
 
Benutzerbild von m00n
 
Registriert seit: Jul 2002
Ort: London
Beiträge: 300
saucool, und viel Potential für nette Spiele
__________________
Never argue with an idiot. They bring you down to their level, then beat you with experience.
m00n ist offline   Mit Zitat antworten
Alt 26-09-2005, 11:25   #7 (permalink)
\x3a\x6f\x29
 
Benutzerbild von [je]
 
Registriert seit: Apr 2004
Ort: paris
Beiträge: 806
Du könntest dein BitmapData Objekt per attachBitmap einer Timeline zuweisen und dann über scrollRect den gewünschten Teil auswählen.
__________________
joa ebert
http://blog.joa-ebert.com/ - http://www.joa-ebert.com/
[je] 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 20:27 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele