VectorSwf tutorial
[UPDATE] VectorSwf.as is now deprecated. The replacement is Swf.as, which provides a much simpler workflow. See upcoming post!
This tutorial attempts to explain the features described in the previous post, so you can use them, and hopefully apply them for something more useful than this demo!
Setting up the project.
--------------------------------------------------------------------------------
1 - Create a new Actionscript project in Flex. Delete the default class created by Flex and paste these 2 classes into the project src folder. Set Main.as as the Default Application.
2 - Link your project to the latest Away3D trunk. You can either do this by setting up a separate library project and linking the AS project via properties/ActionScript Build Path/Library path or simply pasting a copy of the away3d lib in the src folder of your AS project.
3 - In the project properties/ActionsScript Compiler, add "-use-network=false" in the Additional Compiler arguments field to avoid security sandbox problems.
4 - In the src folder of your project create a new flash file named Assets.fla and allow it to publish at the same level Assets.swf.
Prepare your assets in Flash:
--------------------------------------------------------------------------------
5 - Create a new clip and, in it, draw some vector graphics. Make sure not to use strokes because they are not supported yet. Sorry! In my case I downloaded an .eps from www.freevectors.net and copy pasted the content into the clip.
6 - We now need to run a JSFL command from Flash in order to inject its vector data into a variable in the clip's timeline. For this download the jsflaway lib and place it in your flash commands folder. In my case it is "Users/yourUserName/Library/ApplicationSupport/Adobe/FlashCS3/en/Configuration/Commands/"... then while in the clip's edit mode (in its stage) in Flash, go to Commands, run Command and go to the jsflaway lib you just copied to your HD and select VectorDataInjector.jsfl in the components package of the lib. You will see that this should create a new layer in your clip called "vectorData".
7 - Drag an instance of your clip to the main stage of your Assets.fla and publish it.
8 - Repeat steps 5 to 7 to add more elements. As long as an element is on the stage, and the clip contains the vectorData layer, Away3D should be able to port it to 3D.
Away3D code.
--------------------------------------------------------------------------------
9 - You can tweak some settings in the src:
var vectors:ObjectContainer3D = VectorSwf.load("Assets.swf", {scaling:1, zOffset:100});
_scene.addChild(vectors);
Scaling speaks for itself, and zOffset is the z spacing applied between each clip in the main stage of the Assets fla.
SOURCE: http://www.lidev.com.ar/demos/textfieldsmerge/vectorswf/v5/tutorial_vectorSwf.zip
I hope you can find useful applications for this feature. You can use it to show vector interfaces in 3D, text, and practically anything made out of vectors. Steps 5 to 8 should be greatly simplifyed soon thanks to feedback I already recieved from you guys. I'll let you know when I have some updates. Enjoy!
Away3D and Vectors
[UPDATE] VectorSwf.as is now deprecated. The replacement is Swf.as, which provides a much simpler workflow. See upcoming post!
Long time no post. Sorry for that. The good news is that I've been extremely busy, specially with the way Away3D handles vector graphics, and this is the main reason why I haven't brought news any earlier. Let me get you updated now, tell you what's been going on, what tools I'm currently developing and what you can expect the future of vectors in Away3D to be.
First of all, development on the textfields branch has stopped. You can still use it for any of the functionalities described in previous posts, but the thing is that the branch was simply an experimental space intended for 3D vector graphics research and we've now moved on to the official development on the main trunk, where we've taken a completely different approach. The core concept is that now, a regular face can handle more than 3 sides, and these sides can be curved. It's a pretty radical approach since the basis of 3D is triangles. These triangles can now mutate and take any shape that can be described with bezier curves.
Another significant change is the priority given to the Flash IDE as a source for vector graphic elements. Although development on external ttf loading, dynamic font parsing, svg compatibility, etc, is still planned to be supported, the focus is redirected to using Flash for managing text and other vector graphics and then exporting them for a 3D project. This is done by using JSFL to extract vector data in the Flash IDE and then export it in order to use it in a 3D project. In my personal experience, I've found that until Adobe decides to release the vector data that conforms sprites, this is the most practical way to work with such data in order to project it onto the 3rd dimension.
The above demo (click on first image) was achieved by downloading a free eps (Illustrator) file from the web, copy pasting it in Flash, running a JSFL script in Flash in order to inject the vector data in an accessible way into an assets swf and then reaching such data from the 3D project with a couple of lines of code:
_vectorObj = VectorSwf.load("assets/vectorScene.swf", {scaling:1, zOffset:100});
_scene.addChild(_vectorObj);
As you can see, the compiled .swf is treated by VectorSwf as Collada treats .dae files, so these features should make it really easy to work with vector assets in 3D and provide a series of practical means to obtain crisp 3D graphics. I promise to include a tutorial for the above demo in my next post so you can start playing with it and providing me some feedback in order to continue the development of these features.
On the mean time, if you feel like exploring the demo, here is what you need to get it running:
DEMO: http://www.lidev.com.ar/demos/textfieldsmerge/vectorswf/v4/
SOURCE: http://www.lidev.com.ar/demos/textfieldsmerge/vectorswf/v4/test_vectorSwfLoader.zip (Link it to the latest Away3D source).
JSFLAWAY: http://www.lidev.com.ar/demos/textfieldsmerge/vectorswf/v4/jsflaway.zip (Run VectorDataInjector.jsfl in order to inject the vectorData array into a clip).


