Blending objects with eachother but not with background actionscript 3 -
i have number of objects (represented displayobjects) wish blend eachother.
however behind these objects there background not want involve in blending.
so want blend these objects eachother , afterwards use result of blending new displayobject (for example put on top of randomly colored background).
so have is:
var obj1:displayobject = getfirstobj(); var obj2:displayobject = getsecobj(); var background:displayobject = getbackground();  obj1.blendmode = blendmode.add; obj2.blendmode = blendmode.add;   a first attempt tried putting these objects common displayobjectcontainer hoping blending mode relative objects contained same displayobjectcontainer, not seem case.
var objectspool:sprite = new sprite(); objectspool.addchild( obj1 ); objectspool.addchild( obj2 );  addchild( background ); addchild( objectspool );   so diddent me anywhere. appreciated.
edit: changed displayobjectcontainer sprite in last code snippet
if put objects container, , remove stage, can draw bitmapdata class , create new bitmap object representing combination. have transparent background, , it's blendmode normal, allowing use on background.
var obj1:displayobject = getfirstobj(); var obj2:displayobject = getsecobj(); var background:displayobject = getbackground();  obj1.blendmode = blendmode.add; obj2.blendmode = blendmode.add;  var objectspool:displayobjectcontainer = new displayobjectcontainer(); objectspool.addchild( obj1 ); objectspool.addchild( obj2 );  var bmd:bitmapdata = new bitmapdata(objectspool.width,objectspool.height,true,0); bmd.draw(objectspool);  var drawnobject:bitmap = new bitmap(bmd);  addchild( background ); addchild( drawnobject );   (untested code, luck)
Comments
Post a Comment