Mouse Events update
This time only a small post regarding Mouse Events. The AS3 Event model is way more complex than the old one. You have to carefully enable/disable events for every DisplayObject in your hierarchy if you want your listeners to receive the events.
In the FFilmation engine there’s an added complexity, as occluded elements ( those that were made transparent so you could see behind ) should also be transparent to mouse events, but If one alement inside that occluded element had a Mouse event (a door in an occluded wall) , that particular event should be accessible.
It took me more than expected, but finally sprite hierarchy is properly setup so you can add Mouse Events to fElements and the appropiate element receives the event. Also I added the fHole class, which gives control over holes in fPlanes. Now holes can be opened and closed.
I have updated the demo to reflect this new developments, try approaching a door and clicking on it to open it. You can checkout the code from Googlecode.

Hey, love the work but am having trouble running My name is poncho. I’ve download the latest version and updated my code from the SVN. My compiler throws me about 20 warning all saying “Warning: Scatter0_Obj18 extends out of bounds.” and I can’t get out of the main room since when I mouse over the doors the interactivity you’ve added since the previous version does not seem to be work. Hopefully you can help me out. Either way, awesome project, keep up the good work.
Phil said this on May 14th, 2008 at 5:04 pm
How exactly do I apply a mouse event to an object that has been loaded via an XML Scene? For instance, once my scene has been loaded I tried the following code and it did not work:
private function sceneLoaded(e:Event):void {
for each(var o:fObject in this.scene.objects)
o.flashClip.addEventListener(MouseEvent.CLICK, this.objectClick);
}
private function objectClick(e:MouseEvent):void {
trace(”click”);
}
What am I doing wrong? I’m trying to apply a mouse click to every object in the scene and it doesn’t seem to work. When I click the objects in the scene, nothing happens.
Michael Lawrence said this on July 3rd, 2008 at 10:22 pm
Hi Michael,
I assume your are using the latest sources from SVN, otherwise it will possibly not work: If you want to add a Mouse Event to an Element, use its .container property.
Due to the complex nature of AS3 events, I had to disable events in all Sprites in the hierarchy but the .container, so you know where to capture your events. Your code should go like this:
private function sceneLoaded(e:Event):void {
for each(var o:fObject in this.scene.objects)
o.container.addEventListener(MouseEvent.CLICK, this.objectClick);
}
This will be documented in the next release, that I plan to do during the weekend.
Best,
admin said this on July 4th, 2008 at 10:43 am
Thanks a ton for the quick response! Yep, I’m using the latest SVN source. I’ll give it a try. Thanks again!
Michael Lawrence said this on July 7th, 2008 at 6:16 pm