It has been a busy winter/spring, but I’ll get back to that very soon. Just thought I’d post a quick solution to an Away3D issue that bit me recently and finding the bug took forever. The problem was in an Away3D FlipBook project where I used the excellent AS3DMod made by Bartek. It’s a fairly complex project featuring video, zoomable images and much more and it also has some clever coding to ensure that it never tries to load more pages than it needs at any given time and it’s all configured via XML. But - on to the problem:
I was tasked with adding a dynamic Table of Contents to the Book. No problem I thought - all the pages are using the MovieMaterial so I’ll just generate a MovieClip or Sprite that has the TOC and then I’ll Jump to pages based on that. The problem was - no matter what I did, I couldn’t get the MouseEvents in the MovieMaterial to trigger as it should. In fact - there was no MouseEvents being triggered at all. I spent almost a whole day fiddling around with it with no result. I searched the Google Group for answers, but all the threads that looked like they had a similar problem/bug were unanswered.
After a lot of testing and failing, I realized that there actually wasn’t any interactive layer present in the View, despite the material being set to interactive = true. My buddy Alejandro suggested that I change the blendmode for the _interactiveLayer in View3D to see what was going on and this really put me onto it. The _interactiveLayer is a transparent layer in View3D that holds the Movieclip that you use as material (the material itself uses a bitmap for display). When you’re clicking in the view, you are actually clicking on this transparent movieclip that the engine cleverly overlays and moves around so it will look as if you’re clicking the 3D object.
By changing _interactiveLayer.blendMode to BlendMode.ADD, I could see the layer and start realizing when it was active or not. Then it struck me - there is no mechanism in Away3D that notifies a material that is has been moved from one Mesh to another! I was swapping materials a lot and as soon as I did the first swap, the interactive material failed. All I had to do was to make sure that the MovieClip used in the material was removed from the _interactiveLayer and then it would be reset.
So - be careful when you swap MovieMaterials in Away3D. If you loose interactivity, change the BlendMode of the _interactiveLayer to debug and make sure that you reset the movieClip by moving it to a different location in the DisplayList. I hope this post can help someone in the same situation!
oh, and by the way - using the latest AS3DMod with Away3D 3.6 seems to have a bug as well. I couldn’t pinpoint it, but if you’re using AS3DMod and seeing performance problems, try downgrading to Away3D 3.5. It solved the problem for me.