
Код AS3:
package
{
import flash.display3D.textures.Texture;
import starling.display.Image;
import starling.display.Sprite;
import starling.events.Event;
import starling.textures.Texture;
public class Main extends Sprite
{
private var image:Image;
private var text:starling.textures.Texture;
public function Main()
{
super();
text = starling.textures.Texture.fromBitmapData( PsevdoTexture.getBitmapdata() );
image = new Image(text);
image.x =
image.y = 100;
addChild( image );
this.addEventListener( Event.ENTER_FRAME, customRender );
}
private function customRender(e:Event):void
{
flash.display3D.textures.Texture(text.base).uploadFromBitmapData( PsevdoTexture.getBitmapdata() );/**/
}
}
}

Код AS3:
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.PixelSnapping;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.geom.Rectangle;
public class PsevdoTexture
{
private static var _bd:BitmapData;
private static var bitmap:Bitmap;
private static var sprite:Sprite;
private static var debug:Boolean = true;
public static function getBitmapdata():BitmapData
{
var size:Number = 400;
var spr:Sprite = new Sprite();
spr.graphics.beginFill(0xAAAAAA,0);
spr.graphics.drawRect(0,0,size,size);
spr.graphics.endFill();
spr.graphics.lineStyle(2,0xFF0000*Math.random(),1);
spr.graphics.moveTo(0,0);
spr.graphics.lineTo(Math.random()*size,Math.random()*size);
var cont:Sprite = new Sprite();
cont.addChild( spr );
return get(cont);
}
private static function get( ARG_object:DisplayObject, ARG_x:Number = 0, ARG_y:Number = 0, ARG_width:Number = 0, ARG_height:Number = 0,transpend:Boolean=false):BitmapData {
if (!ARG_width) ARG_width = (ARG_object.mask) ? ARG_object.mask.width : ARG_object.width;
if (!ARG_height) ARG_height = (ARG_object.mask) ? ARG_object.mask.height : ARG_object.height;
var cropArea:Rectangle = new Rectangle(0, 0, ARG_width, ARG_height);
var fillColor:uint = transpend
? 0x00000000
: 0x0;
var bmpd:BitmapData = new BitmapData(ARG_width, ARG_height,true,fillColor);
var croppedBitmap:Bitmap = new Bitmap(bmpd, PixelSnapping.ALWAYS, true);
var cropMatrix:Matrix = new Matrix();
cropMatrix.translate(-ARG_x, -ARG_y);
bmpd.draw( ARG_object, cropMatrix, null, null, cropArea, true );
return bmpd;
}
}
}