2012-11-21 2 views
2

pas un codeur si mal un peu ici:bitmapData AS3 sur nextframe();

Essayant d'attirer l'image actuelle dans la trame suivante comme un bitmap pour l'efficacité du processeur. Dans AS2 ce code fonctionne comme un charme:

import flash.display.*; 
// # create the bitmap 
var tBitmapData = new BitmapData(400, 200, true, 0x00000000); 

// # now draw this movieClip's content to the bitmap 
tBitmapData.draw(this); 
// # 2nd frame should be blank! 
nextFrame(); 
// # now attach the bitmap you made to this movieclip 
this.attachBitmap(tBitmapData, 1, "auto", true); 

Juste besoin de savoir comment réécrire cela pour AS3. Je vous remercie!

+0

devrait remplacer la ligne attachBitmap avec quelque chose comme: 'addChild (new Bitmap (tBitmapData)); –

Répondre

1

Tout d'abord, dans AS3 BitmapData n'est pas un DisplayObject. Vous devez l'envelopper dans un objet Bitmap. Ensuite, vous remplacez attachBitmap avec addChild comme George Profenza mentionné:

import flash.display.*; 
// # create the bitmap 
var tBitmapData:BitmapData = new BitmapData(400, 200, true, 0x000000); 

// # now draw this movieClip's content to the bitmap 
tBitmapData.draw(this); 
// # 2nd frame should be blank! 
nextFrame(); 
// # now attach the bitmap you made to this movieclip 
this.addChild(new Bitmap(tBitmapData)); 

Essayez aussi de taper vos variables (var tBitmapData:BitmapData). Cela augmente les performances et permet au compilateur d'intercepter certaines erreurs.