Excellent!

I have exactly the same problem! If you look back I posted it 2 weeks
ago.
My version does not work with an embedded png. With Away 3.5, it
worked.
Any idea how I could work around the problem?

[Embed(source='../OBJ_FILE_FLASH.png')]
public var ObjIcon:Class;

...

var bitmap:Bitmap = new ObjIcon();
var material:BitmapMaterial = new BitmapMaterial(bitmap.bitmapData);
material.smooth = true;
var labelIcon:DirectionalSprite = new DirectionalSprite(material);
labelIcon.scaling = 12;
labelIcon.x = iQ3d.SCALE * meta.x;
labelIcon.z = iQ3d.SCALE * meta.y;
labelIcon.y = iQ3d.SCALE * meta.z + iQ3d.SCALE * 0.036;
var objs3D:Object3D = new ObjectContainer3D();
objs3D.addSprite(labelIcon);
obj3D.useHandCursor = true;
obj3D.addOnMouseDown(iQ3d.mouseControl.MouseDown);
obj3D.addOnMouseUp(MouseUp);

On Oct 19, 3:07 pm, "[email protected]" <[email protected]>
wrote:
> When I create a bitmapmaterial based on bitmapdata with transparency
> true and transparency color different from default and then use it as
> Sprite3D's material, all interactivity dissapears.
>
> Here is the code to reproduce the bug.
>
> package
> {
>         import away3d.cameras.Camera3D;
>         import away3d.containers.ObjectContainer3D;
>         import away3d.containers.Scene3D;
>         import away3d.containers.View3D;
>         import away3d.events.MouseEvent3D;
>         import away3d.materials.BitmapMaterial;
>         import away3d.materials.WireColorMaterial;
>         import away3d.primitives.Cube;
>         import away3d.sprites.Sprite3D;
>
>         import flash.display.BitmapData;
>         import flash.display.Shape;
>         import flash.display.Sprite;
>         import flash.events.Event;
>         import flash.events.MouseEvent;
>
>         public class ShowSpriteBug extends Sprite
>         {
>                 private var view:View3D;
>                 private var scene:Scene3D;
>                 private var camera:Camera3D;
>
>                 private var testCube:Cube;
>                 private var container:ObjectContainer3D;
>                 private var sprite:Sprite3D;
>
>                 //bitmapdata to be used in sprite3d's bitmapmaterial
>                 private var bmd:BitmapData;
>                 private var shape:Shape;
>                 //bitmapmaterial to be used as sprite3d material
>                 private var material:BitmapMaterial;
>
>                 private var cubeMat:WireColorMaterial;
>
>                 public function ShowSpriteBug()
>                 {
>                         this.init();
>                 }
>
>                 private function init():void
>                 {
>                         this.initEngine();
>                         this.initMaterials();
>                         this.initObjects();
>                         this.initListeners();
>                 }
>
>                 private function initEngine():void
>                 {
>                         this.view = new View3D();
>                         this.scene = new Scene3D();
>                         this.view.scene = this.scene;
>                         this.view.x = this.stage.stageWidth/2;
>                         this.view.y = this.stage.stageHeight/2;
>                         this.addChild(this.view);
>
>                         this.camera = this.view.camera;
>                         this.camera.moveBackward(1000);
>
>                         this.view.render();
>                 }
>
>                    //Here I initialise materials for cube and sprite3D
>                 private function initMaterials():void
>                 {
>                         //this.bmd = new BitmapData(200,200,true); //this 
> works fine!
>                         this.bmd = new BitmapData(200,200,true,0x000000); 
> //in this case
> all sprite3D interactivity disappears!
>
>                         this.shape = new Shape();
>                         this.shape.graphics.beginFill(0xFF0000);
>                         this.shape.graphics.drawCircle(100,100,100);
>                         this.shape.graphics.endFill();
>                         this.bmd.draw(this.shape);
>
>                         this.material = new BitmapMaterial(this.bmd);
>                         this.material.smooth = true;
>
>                         this.cubeMat = new  WireColorMaterial(0x00FF00);
>                 }
>
>                 private function initObjects():void
>                 {
>
>                         this.container = new ObjectContainer3D();
>                         this.container.useHandCursor = true;
>                         this.container.mouseEnabled = true;
>
>                         this.testCube = new Cube();
>                         this.testCube.material = this.cubeMat;
>                         this.testCube.moveForward(100);
>                         this.container.addChild(this.testCube);
>
>                         this.sprite = new Sprite3D(this.material);
>                         this.sprite.y = 180;
>
>                         this.container.addSprite(this.sprite);
>                         this.scene.addChild(this.container);
>
>                         this.camera.lookAt(this.container.position);
>
>                 }
>
>                 private function initListeners():void
>                 {
>                         
> this.addEventListener(Event.ENTER_FRAME,this.onEnterFrame);
>
> /*Testing sprite3d interactivity, if mouse is down, out or over
> container containing sprite3D, cube changes its color*/
> this.container.addOnMouseOver(this.onOver);
>                         this.container.addOnMouseOut(this.onOut);
>                         this.container.addOnMouseDown(this.onDown);
>                 }
>
>                 private function onOver(event:MouseEvent3D):void
>                 {
>                         this.cubeMat.color = 0xFF00FF;
>                 }
>
>                 private function onOut(event:MouseEvent3D):void
>                 {
>                         this.cubeMat.color = 0x00FF00;
>                 }
>
>                 private function onDown(event:MouseEvent3D):void
>                 {
>                         this.cubeMat.color = 0xFF0000;
>                 }
>
>                 private function onEnterFrame(event:Event):void
>                 {
>                         this.view.render();
>                 }
>
>         }
>
>
>
> }

Reply via email to