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

nested array funzt nicht [Flash 10]

 


AntwortenRegistrieren Seite1  

drpelz#1
Benutzerbild von drpelz
Beiträge: 15
Registriert: Jul 2011

10.09.2011, 03:40

Hallo Leute,

also ich habe da folgendes Problem: ich habe einen nested Array (multidimensional Array); dieser beinhaltet zwei weitere Arrays; Array 1 (Reihe 1 in nested Array) ist gefüllt mit rotierten bitmapData-Objekten, Array 2 (Reihe 2 in nested Array) ist gefüllt mit eingefärbten und rotierten bitmapData-Objekten.

Ich versuche nun Reihe 2 des nested Arrays zu erreichen aber das geht bisher nicht. Ich bekomme da folgende Fehlermeldung ("TypeError: Error #1034: Type Coercion failed: cannot convert []@36d7e9e9 to flash.display.BitmapData. at BasicBlitArrayObject/updateFrame()").

Kann mir bitte da jemand weiterhelfen? Ware echt super von Euch. Danke.

diese Funktion ist zum Rotieren und einfärben der bitmapData-Objekte da; an sich funktioniert diese aber irgendwie bekomme ich von ausserhalb keinen Zugriff auf die Daten im nestedArray
[CODE]
public function createColoredRotationBlitArrayFromBD(sourceBitmapData:BitmapData, inc:int, offset:int = 0, color:Number = 1, $alpha:Number = 1):Array
{
         
   tileList = [];
   tileListSec = [];
   levelArray = [tileList, tileListSec];
   var rotation:int = offset;
         
   while (rotation < (360 + offset))
   {
      var angleInRadians:Number = Math.PI * 2 * (rotation / 360);
      var rotationMatrix:Matrix = new Matrix();
            
      rotationMatrix.translate(-sourceBitmapData.width * .5, -sourceBitmapData.height * .5);
      rotationMatrix.rotate(angleInRadians);
      rotationMatrix.translate(sourceBitmapData.width * .5, sourceBitmapData.height * .5);
            
            
      var matrixImage:BitmapData = new BitmapData(sourceBitmapData.width, sourceBitmapData.height,
                           true, 0x00000000);
            
      matrixImage.draw(sourceBitmapData, rotationMatrix);
      tileList.push(matrixImage.clone());
            
            
      bitmapData = new BitmapData(matrixImage.width, matrixImage.height, true, 0x00000000);
      bitmapData = matrixImage;
            
            
      var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter (
                     [color, 0, 0, 0, 0,
                     0, 0, 0, 0, 0,
                      0, 0, 0, 0, 0,
                      0, 0, 0, $alpha, 0]);
            
      matrixImage.applyFilter(bitmapData, bitmapData.rect, point0, colorMatrix);

            
      tileListSec.push(matrixImage.clone());
            
                        
      rotation += inc;

      matrixImage.dispose();
      matrixImage = null;
      rotationMatrix = null;
      bitmapData.dispose();
      bitmapData = null;
      colorMatrix = null;
      }
         
   return(levelArray);
         
}[/CODE]

hier greife ich auf die Funktion zu um meine bitmapData-Objekte mit Hilfe der Funktion zu verändern
[CODE]
animationFrames = tempBlitArrayAsset.createRotationBlitArrayFromBD($bitmapData, 1, 270);

[/CODE]

und hier versuche ich von ausserhalb auf die 2. Reihe im nested Array zuzugreifen
[CODE]
tempEnemy.animationList = animationFrames;
tempEnemy.bitmapData = tempEnemy.animationList[1][tempEnemy.frame];
[/CODE]


hier werden frames aktualisiert (anhand der frame-Zahl wird die Pos. im Array (entsprechende Reihe) angegeben)
[CODE]
public function updateFrame(inc:int, row:int = 0):void
{
   frame += inc;
      
   if (frame > animationList.length - 1){
      frame = 0;
   }
   bitmapData = animationList[row][frame];               
               
               
   }
         
}   

[/CODE]

so sieht das im hauptcode aus wenn die Frames aktualisiert werden (trueRotation ist anfangs auf null gesetzt)
[CODE]
tempEnemy.updateFrame(tempEnemy.trueRotation);

[/CODE]
vindel#2
Benutzerbild von vindelFlashhilfe.de Moderator
Beiträge: 3000
Wohnort: Köln
Registriert: Oct 2007

10.09.2011, 09:17