|
[kml_flashembed movie="http://www.acmewebworks.com/Images/blog/FlashLibDemo/FlashLibDemo.swf" width="600" height="300"/]
|
|
Grant Skinner just posted his FlashLib extension for the Flash 9 alpha IDE / Flash CS3 with a great explanation of how it prepares your library for use in Flex2. He calls em’ "Shake n’ Bake SWF’s", I call em’ buiscuits of joy! Ok enough with the Southern references Why do I think this is SO friggin’ cool?? Because it allows me to VERY easily work with my MovieClip textures for my Papervision3D models – THAT’S WHY. The Xwing above, which we’ve seen on several occasions, now uses a MovieClip ( MovieMaterial ) for the skin rather than an externally loaded JPG or embedded bitmap within the compiled Flex2 app. For this demo, you’ll see that I’ve added some really simple animations. Engine Glows on the back and an orange dash that flows along the body in the front. The orange dash also has a Glow filter applied Now the workflow is rediculously cool. Modify the texture as a MovieClip in the Flash IDE like any other day, use the new FlashLib Create command in the commands list and bam – I have a FlashLib.swf and a FlashLib.as class to compile with my Flex2 app. Usage in Flex2 is straight forward:
[as] import mx.containers.Canvas; import org.papervision3d.core.utils.Collada; public class ColladaSceneLoader extends EventDispatcher public var container:Canvas; private var collada:PaperworldCollada; public function ColladaSceneLoader(target:IEventDispatcher=null) public function getObject():DisplayObject3D public function init(p_file:String, p_scene:Scene3D):void private function loadCollada():void private function handleBitmapLoaded(e:FileLoadEvent):void private function handleImageInit(e:Event):void loadCollada(); private function handleTimerUpdate(e:TimerEvent):void private function handleColladaLoadComplete(e:ObjectReadyEvent):void In the init for the class, I call [as]FlashLib.eventDispatcher.addEventListener(Event.INIT, handleImageInit); [/as] When the INIT event fires handleImageInit creates the instance using FlashLib and then goes on normally to create the MovieMaterial object that can be added to the materials list for the COLLADA scene: [as]private function handleImageInit(e:Event):void loadCollada(); And, as usual, this was JUST in time for something I’m cooking up for FITC – Grant’s timing couldn’t have been more perfect as this little gem brought it all together Check it out over on Grant’s blog: RockOn Rating: |


