Snippets (AS3): MouseEvent targets nested child objects

Annoying. If you have objects with child objects and put addEventListener(MouseEvent.CLICK, mouseClickEvent); on it,

function mouseClickEvent(e:MouseEvent):void
{
trace(e.target.name);
}

will trace the child objects instead of the parent. I’m not exactly sure why that happens, but putting MovieClip.mouseEnabled = false; on every child object helps (which was OK in my case).

Found here: http://www.communitymx.com/blog/index.cfm?newsid=895

Reducing Collada/DAE Filesize

My .dae is currently 150KBs large – which isn’t much – but more complex models can probably easily get into the megabyte-range. And then it will definitely sum up and take time to load. An easy way to reduce Collada filesizes:

  1. Open the file and delete double spaces, tabs, line breaks.
  2. Delete Collada overhead not required for Papervision3D’s Collada parser (trial & error)
  3. Search & Replace long object names like Bip01_Arm_Torso_Spine-node-transform_Bip01_Spine-node_transform-input-array into b1ats_nt_b1sn_tia or something even smaller, as long as it’s unique (trial & error again)
  4. Insert the XML into a Flash-file and load the .swf instead of the .dae.

While the second and third part are optional and only recommendable once the model is final, the flash-part is really efficient, because (unlike .dae-files) swf-files use compression. All in all I got from 150kb to mere 10kb. Nice, nice.