Interactive MovieClipSprite

Software: Away3D 4.x

gjacob, Newbie
Posted: 18 July 2012 08:50 PM   Total Posts: 3

Hi,

I just spent the good portion of the day trying to get a MovieClipSprite to be interactive.

This seems to be a big problem that lots of people are having. And I was unable to find a good sollution in other posts.

So I thought I would share what I now have working.

The hotspot material has its own mouse listener in it and dispatches the event HOTSPOT_DOWN when it is pressed.

Give the material a name and save the hotspot and its container in an array with the same name so that when you recive the event you can access the Object3DContainer and the HotSpot.

This seems like a dirty workaround for a function that the MovieClipSprite should have on its own.

private function initHotSpots():void {
            
var tempMaterial:HotSpotMaterial = new HotSpotMaterial();
            
tempMaterial.name "hotSpot1";
            
tempMaterial.addEventListener(HotSpotMaterial.HOTSPOT_DOWNonHotSpotDown);

            var 
tempHotSpot:MovieClipSprite = new MovieClipSprite(tempMaterial"center"1true);
            
tempHotSpot.Number(configFactory.radius);

            
hotSpots["hotSpot1"[tempHotSpotContainertempHotSpot];

            
scene.addSprite(tempHotSpot);
}

private function onHotSpotDown($e:Event):void {
        hotSpotContainerDrag 
hotSpots[$e.target.name][0];
        
hotSpot hotSpots[$e.target.name][1];

        
//put your code here

   

Richard Olsson, Administrator
Posted: 19 July 2012 07:57 AM   Total Posts: 1192   [ # 1 ]

I’m not sure I follow your code, but the best way to make a material interactive would be to listen for 3D mouse events, find the local “movieclip-space” coordinate using the UV coordinate where the cursor hit the surface, and then perform picking within the display-list on that point.

But I’m not sure what version of the engine you are using to begin with?

   

gjacob, Newbie
Posted: 19 July 2012 08:05 AM   Total Posts: 3   [ # 2 ]

Hi,

All Im going it putting a listener on the material and giving the material a name. Then making a Object3D container and MovileClipSprite and saving a reference to them in an array.

I dont really know why the MovieClipSprite and Sprite3D dont have MouseEvent3D functionality built in.

Im using the newest build of 4. That may work as well but i could not find any info on this solution.

Thanks for the other alternative Ill try this next time I need it.

   

Richard Olsson, Administrator
Posted: 19 July 2012 08:12 AM   Total Posts: 1192   [ # 3 ]

Are you sure you’re using Away3D 4.0? There should be no MovieClipSprite class, and no addSprite() method in that version at all.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X