, Sr. Member
var currentCaseBitmap:Bitmap = new flash.display.Bitmap (p.material.texture.bitmapData)
var caseMC:MovieClip = new flash.display.MovieClip;
caseMC.addChild(currentCaseBitmap);
caseMC.addChild(frontCoverloader);
//test to see where the loader is positioned. This add to the screen so I could see if the bitmap I was adding was being resized and positioned in the right place
//addChild (caseMC)
var yRatio = (caseMC.height / 2) / frontCoverloader.height;
var xRatio = (caseMC.width / 3) / frontCoverloader.width;
frontCoverloader.y = caseMC.height / 2
frontCoverloader.x = caseMC.width /3
frontCoverloader.scaleY = yRatio;
frontCoverloader.scaleX = xRatio;
//create new bitmapData
//TODO: figure out whether maybe updateTexture would be a better way?
var caseBMD = new flash.display.BitmapData (512, 512)
caseBMD.draw (caseMC)
//TODO replace bitmapmaterial
caseMaterials = new TextureMaterial(new BitmapTexture(caseBMD))
caseMaterials.ambientColor = 0x505080;
caseMaterials.gloss = 5000;
caseMaterials.specular = .5;
caseMaterials.lightPicker = lightPicker;
p.material = caseMaterials;
( ‘p’ in this case is a cube, which has already been defined, and has a bitmap texture)
Hopefully you can make some sort of sense of what is going on there…
The above works for if you;re using a bitmap texture, if you just want, say a coloured texture, and then update the number, you would skip the top bit which grabs the current texture, and just use the as3 graphics draw functions,
private var newTexFill:Shape = new Shape ();
.....
...
...
newTexFill.graphics.beginFill(0xFFCC00, 1);
newTexFill.graphics.drawRect (0, 0, width, height);
newTexFill.graphics.endFill();
newTexFill.alpha = 1;
newTexMC.addChild(newTexFill);
You’ll need to make sure the dimensions are a power of 2 sized ( google them), and then just adapt the first bit I posted to add in your graphics, like I say, you’ll need to experiment with the position and orientation to get it in the right place..
I’d expect there to be a more elegant solution, sugggestions gratefully received!