--Ashiq--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
Cheers
You may need to explore bitmapdata and bitmap methods in NME/flash more, copypixels may not be ideal for speed,
but fairly sure it will work but you maybe able to modify code to be faster in NME, but will give you a start.
Although I have not tested this specific example, based on my own code this example should work ( assumes standard NME structure )
private function init(e)
{
// entry point
var swf = new SWF ( Assets.getBytes ("img/asset.swf") );
//name of linkage MovieClip in asset swf is assumed to be MyMovieNeedingRastering
var mc = swf.createMovieClip ("MyMovieNeedingRastering");
addChild( new Bitmap( copyToBitmapWithTransparency( mc ), PixelSnapping.ALWAYS, true )) ;
}
private function copyToBitmapWithTransparency( sp: Sprite ): BitmapData
{
mc.cacheAsBitmap = true; var wide: Int = Std.int( mc.width );
var hi = Std.int( mc.height );
var point = new Point( 0, 0 );
var rect = new Rectangle( 0 , 0, wide, hi );
var abitmap = new BitmapData( wide, hi, true, #if flash 0xff000000 #else BitmapData.createColor( 0x00,
0x000000 ) #end );
abitmap.draw( sp ); abitmap.copyPixels( abitmap, rect, point, abitmap, point, false );
return abitmap;
}
var swf:SWF = new SWF(swfLoader.data);
var cl:MovieClip = swf.createMovieClip(""); // if no given name, then the whole loaded SWF will be created
cl.cacheAsBitmap = true;
var bdata:BitmapData = new BitmapData(Std.int(cl.width), Std.int(cl.height), true, 0), bmp:Bitmap = new Bitmap(bdata, PixelSnapping.ALWAYS, true);
bdata.draw(cl);
bmp.x = 100;
bmp.y = 100;
Lib.current.addChild(bmp);
package net.justinfront.kitty;
import nme.display.Sprite;
import nme.display.Bitmap;
import nme.display.BitmapData;
import nme.geom.Matrix;
import nme.geom.Point;
import nme.geom.Rectangle;
import nme.Assets;
import format.SWF;
import nme.display.PixelSnapping;
import neash.display.BitmapInt32;
/**
* ...
* @author JLM
*/
class Kitty
{
private var scope: Sprite;
public function new( scope_: Sprite )
{
scope = scope_;
var swf = new SWF ( Assets.getBytes ("img/KittyCS4.swf") );
//name of linkage MovieClip in asset swf is assumed to be MyMovieNeedingRastering
var mc = swf.createMovieClip ("Kitten");
scope.addChild( mc );
var bd = copyToBitmapWithTransparency( mc );
var bm = new Bitmap( bd, PixelSnapping.ALWAYS, true );
bm.x = 100;
bm.y = 100;
scope.addChild( bm ) ;
}
private function copyToBitmapWithTransparency( mc: Sprite ): BitmapData
{
mc.cacheAsBitmap = true;
var wide = Std.int( mc.width );
var hi = Std.int( mc.height );
var point = new Point( 0, 0 );
var rect = new Rectangle( 0 , 0, wide, hi );
var abitmap = new BitmapData( wide, hi, true, #if flash 0x00000000 #else BitmapData.createColor( 0xff,
0xff0000 ) #end );
abitmap.draw( mc ); abitmap.copyPixels( abitmap, rect, point, abitmap, point, false );
return abitmap;
}
}
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- NMML reference: https://gist.github.com/1763850 -->
<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
<meta title="Kitty" package="net.justinfront.kitty.Kitty" version="1.0.0" company="JLM" />
<!-- output -->
<app main="net.justinfront.kitty.Main" file="Kitty" path="bin" />
<window background="#ffffff" fps="60" />
<window width="800" height="480" unless="mobile" />
<window orientation="landscape" vsync="true" antialiasing="0" if="cpp" />
<!-- classpath, haxe libs -->
<source path="src" />
<haxelib name="nme" />
<haxelib name="swf" />
<haxelib name="format" />
<!-- assets -->
<icon path="assets/nme.svg" />
<assets path="assets/img" rename="img" />
<!-- DLLs -->
<ndll name="std" />
<ndll name="regexp" />
<ndll name="zlib" />
<ndll name="nme" haxelib="nme" />
<!-- optimize JS output -->
<haxeflag name="--dead-code-elimination" if="html5" />
<haxeflag name="--js-modern" if="html5" />
</project>
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
Below is the code called from main so very easy to set the project up just add this to the main class.new Kitty( this );and enclosed the application nmml with the project setup. Does any one have any advice on how I need to modify my test kitty to make sure he is rendered on android properly or any changes I need to make in the nmml?Many ThanksJustinPS you can remove the scope.addChild( mc ); line it was just there for checking if the render was same as bitmap version.
But the kitty does not seem to render properly in windows.