Table of contents
- How To Use FIVe3D In Flex
- How To Use FIVe3D And Tweening in Flex
For some time I’ve been planning to use FIVe3D of Mathieu Badimon, in Flex, not in Flash. I’ve been trying to make it work but no success ’till now.
After more than 4, 5 tries, I’ve managed to take the example from the FIVe3D framework and implemented it in Flex. It was not an easy task because of some compile errors, regarding the missing fl.motion package. What I found out is that fl.motion package is included in Flash CS3 but not into Flex framework and although FIVe3D is AS3 is not fully compatible with Flex framework (see it in livedocs).
What I did to make it work?
- Downloaded the FIVe3D framework from five3d.mathieu-badimon.com. Sometimes the site is not working and the user is redirected to 404.online.net.
- Created a new Flex Project and copied the whole five3D folder (with display, geom, typography and utils) from the archive into it.
- Taken the Main.as file from first_example folder and started copying lines into my new project
- Commented out the lines of code from (commented where fl.motion is used):
- Shape3D.as - line 17 and from line 279 to 282
- Sprite3D.as - line 18 and from line 302 to 306
- Bitmap3D.as - line 21 and from line 477 to 480
My FIVe3D example is bellow (working application and code).
You can click on the rounded square to rotate it randomly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundGradientColors="[#dddddd,#dddddd]" layout="absolute" width="500" height="500" creationComplete="start()"> <mx:UIComponent id="mainUI"/> <mx:Script> <![CDATA[ import five3D.typography.HelveticaBold; import five3D.utils.Drawing; import five3D.display.Scene3D; import five3D.display.DynamicText3D; import five3D.display.Shape3D; import five3D.display.Sprite3D; private var scene3D:Scene3D; private var sprite3D:Sprite3D; private var star3d:Shape3D; private var flexerWord:DynamicText3D; private var hiWord:DynamicText3D; // start drawing private function start():void { // create the scene scene3D = new Scene3D(); scene3D.x = 250; scene3D.y = 250; // create the round rectangle/square sprite3D = new Sprite3D(); sprite3D.graphics3D.beginFill(0x000000); sprite3D.graphics3D.drawRoundRect(-150, -150, 300, 300, 40, 40); sprite3D.graphics3D.endFill(); // rotate the round rectangle/square randomly sprite3D.rotationX = Math.random()*100-50; sprite3D.rotationY = Math.random()*100-50; sprite3D.rotationZ = Math.random()*100-50; // create the star star3d = new Shape3D(); Drawing.star(star3d.graphics3D, 20, 60, 50, 0, 0x6699cc); star3d.x = 120; star3d.y = -80; // rotate the start star3d.addEventListener(Event.ENTER_FRAME, function (event:Event):void { // rotate on Z axe event.target.rotationZ++; } ); // "fxr" word flexerWord = new DynamicText3D(HelveticaBold); flexerWord.size = 45; flexerWord.color = 0xFFFFFF; flexerWord.text = "Fxr"; flexerWord.x = 88; flexerWord.y = -110; // "hi" word hiWord = new DynamicText3D(HelveticaBold); hiWord.size = 100; hiWord.color = 0x555555; hiWord.text = "Hi!"; hiWord.x = -112; hiWord.y = -34; // click event on the round rectangle/square sprite3D.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { // rotate the round rectangle/square randomly // all 3 axes event.target.rotationX = Math.random()*100-50; event.target.rotationY = Math.random()*100-50; event.target.rotationZ = Math.random()*100-50; } ); sprite3D.mouseChildren = false; sprite3D.buttonMode = true; // adding scene to the main UI component mainUI.addChild(scene3D); // adding round rectangle/square to the scene scene3D.addChild(sprite3D); // adding the start to the round rectangle/square sprite3D.addChild(star3d); // adding "fxr" word to the round rectangle/square sprite3D.addChild(flexerWord); // adding "hi" word to the round rectangle/square sprite3D.addChild(hiWord); } ]]> </mx:Script> </mx:Application> |
The FIVe3D framework is simple and is seems to draw very fast. What can be the next step: using tweening with FIVe3D in Flex.
Some related resources:
http://labs.vizar.de/blog/2008-05-12/first-steps-with-five3d/
http://tech.nitoyon.com/blog/2008/05/keynote_like_cube_transition.html
| ||
|
Tags: 3D, ActionScript, five3d
This post was written by Andrei Ionescu
Views: 7692
























[...] This tutorial shows how to get started with Five3D and Flex. Seems that Five3D employs methods from the fl.motion package that is only available for FCS3. One day, I’ll have to look at that package in more detail and consider adding a complete set of equivalent methods to Singularity for Flex users. [...]
Hi,
I had the same problem initially with Five3D but I got around it in a different way. I have Flash CS3 installed as well as flash and so I have the referenced classes. For me they were in:
C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes\fl\motion
I simply copied the relevant classes to the directory with Five3D (retaining the folders necessary for their package structure) and everything was A OK. I’m using FDT so I just added the Five3D directory (which now includes all dependant classes) into my source path and was ready to start using it
Hope that helps,
Kelvin
Thanks for comment Kelvin! Nice workaround. I’ll add fl.motion from Flash CS3 to my project.
Nice article, very detailed and very helpful.
Thanks
[...] of contentsHow To Use FIVe3D In FlexHow To Use FIVe3D And Tweening in [...]
[...] 完整的教程大家可以看这里:How To Use FIVe3D In Flex [...]
A Flash/Flex solution: using the Flash Component Kit For Flex, you can do the FIVe3D stuff in Flash and bring it over to Flex as a Flex Component.