I start working on a photo library in papervision, so I look around I got an example from flashEnabledBlog, one of the problems was that the example was in flash cs3 and I need it in flex actionscript project, the other one was that the example was done with old papervision and tweener versions, so I had to port it. It’s a good start if you have to do something like it. I Include lasted versions of Tweener and Papervision in the zip file, you just have to run it.
If you remember in as2 we had _root which let us access to methods and variables in the root of the project and refer to absolute paths, I thought that as3 didn’t have _root propriety, but I was wrong. root property can be useful if you want to share some value to all the classes in the project, add events to main class that call methods declared inside the class where we are working on or call generic methods declare in root class.
To use root propriety the class that you are working on most extend a DisplayObject (Sprite,MovieCLip,etc…) because you have to add the class to the parent class. And note, you can’t use the root propriety in the constructor method, because the addChild haven’t been process yet! Well let’s stop writing and see some code:
Main.as
In the Main class I’m declaring a variable named myValue which I did the proper sets and get. I am declaring two classes, in one of them I will set the value at the Main class and in the other I will get that value back. I’m also creating a movieClip just for test purposes.
ExampleClass.as
In ExampleClass I’m setting myValue that is propriety of the Main class with some text and I’m tracing the movieClip that I create in the Main Class.
AnotherClass.as
In AnotherClass I’m tracing the myValue propriety. So the result should be: [object MovieClip]
This value is inside the Main Class
So it works ok, you only have to be carefull not refer root inside the constructor method, have the certain that you already addChild the class when you are referring to root and that the class extends a display object. If you do that, you can too have access to stage propriety, let’s check the next example:
ExampleClass.as
The result should be or stage width.
Another way to access to main proprieties, methods, etc… is with static members. In the next example I’m declaring a static property in the main class and setting and trace the value of it in the example class.
Main.as
ExampleClass.as
The result should be “Hello Word!â€, if you didn’t know this, read some books about object oriented programming and static members.
Another way to do the same thing is to pass the instance of main class as an argument to the other classes.
Main.as
Example.as
There are still another ways to access to the Main class code. I don’t know which techniques are more correct, I usually use them all depending in what I need. I hope I help someone.
Object-based animation
Gain complete control over individual animation attributes with object-based animation, which applies tweens directly to objects instead of to keyframes. Easily make changes to motion with Bezier handles.
3D transformation
Animate 2D objects through 3D space with exciting new 3D translation and rotation tools, which allow you to animate along the x, y, and z axes. Apply local or global transformation to any object.
Procedural modeling with Deco and Spray Brush
Turn symbols into instant design tools. Apply symbols in a variety of ways: Quickly create kaleidoscope-like effects and apply fills using the Deco tool, or randomly spray symbols across any defined area using the Spray Brush.
Metadata (XMP) support
Add metadata to SWF files using the new XMP panel. Quickly assign tags for enhanced collaboration and better mobile experiences.
Authoring for Adobe AIR
Deliver interactive experiences to the desktop with new integrated capability to publish to the Adobe® AIR™ runtime. Reach even more audiences across more devices — web, mobile, and now the desktop.
XFL support
Open content from Adobe InDesign® or After Effects® software and retain file integrity. With the cross-application XFL format, easily import content for further development in Adobe Flash®.
Inverse kinematics with the Bones tool
Create chain-like animation effects with a series of linked objects, or quickly distort a single shape using the new Bones tool.
Motion editor
Experience detailed control over keyframe parameters, including rotation, size, scale, position, filters, and more, using the new motion editor. Refine easing control with graphical displays similar to those in After Effects.
Motion presets
Jump-start your project with prebuilt animations that can be applied to any object. Select from dozens of presets or create and save your own. Share presets with others to save animation time.
H.264 support
Encode to any format recognized by the Adobe Flash Player runtime with Adobe Media Encoder, the same tool found in other Adobe video products and now with support for H.264.
In the last month I thought Adobe had protect the loadBytes method from the loader so that only “regular†files like mp3, jpg, etc could be loaded, lots of good library’s like Benjamin Dobler wav reader stop working. What I think it is that in last version of flash player Adobe turn allowLoadBytesCodeExecution to false. If you see Adobe documentation they have written “Note: This API is likely to be replaced in a future release of AIR.†If anyone knows what really happen let me know. Now the good part, to solve that is simple, you only need to set allowLoadBytesCodeExecution to true.
I usually work in desktop application and we like it or not flash is optimized for the web so normally we have to put complete event ever time we load anything, and it’s logic, because for the web things have to be asynchronous but for desktop applications they not.
We have already load text and xml files synchronous and done some things with sql lite synchronous, I think for now images and sounds can’t be done, because even if you get the bytes, you always need to invoke loadBytes method from the loader and put a complete event listener, fuck! lol, I hope that in the next release of flash the loader have an synchronous method of load the bytes.
There it’s a class to load an xml file synchronous.
+ Help the community
+ Explore the Flash platform
+ Create a better world
+ Research and play
Startups
We're looking for stories about startups using Flex/Flash technology. Drop us a quick e-mail or mention it to us via our Twitter account @dreaminginflash, thanks!