Code / Programs it’s hard to live without

p_package_custom_built

Here is a quick list of Classes / Packages and programs that seem to make life just that much easier. This is a list based off of things we use daily for quick development of agency type Flash sites. This is in no way a complete list but anyone just wanting to increase their productivity can start here.

Programs:

1) FlashDevelop (PC only - or via VMWare) :/

Use this and easily literally shave days off your coding time. If you don’t use this go with FlexBuilder.

2) Charles (Mac or PC)

Find the root of the real issues when you load dynamic content.

3) Smart FTP (PC only) :/

Quick uploads

Code:

1) Foomonger (Later)

Call a method / function a second later or a frame later. Also has a LoadWatcher for loadProgress

2) Tweener

Some use TweenLite I like Tweener. It always seems to yield the best results. I could be wrong but that’s my opinion.

2) I was wrong - TweenLite/Max

The results speak for themselves - TweenLite/Max vs other Tween Engines

3) BulkLoader (unless you’re using Gaia - see below)

The hotness for loading multiple files and having access to them across your whole project.

4) Papervision

Of course. :-D

Frameworks:

1) Gaia

Steven Sacks has created one of the best frameworks that is to be used on agency style Flash sites. You can have an entire simple flash site up in about 5 minutes or less. (not joking). Site scaffolding, asset loading, browser navigation, page loading, SEO, a place for your transitions (code or timeline) and much more. AS2 and AS3 supported. Check it out!

Are there any programs or code bases you can’t live without?

Let us know.

Papervision Double Sided Plane

Papervision double sided plane

Thanks to Luke I am the new proud owner of Papervision2.com. He is keeping busy and just ran out of time. I know he is sad to see it go, but glad that someone can take over and continue helping the Flash / Papervision community.

To introduce myself, I decided to take a tutorial from my site and add it to this new site.

The ole, doublesided plane. Lets get started.

Here are your options as we see it to create a double-sided plane.

Option 1:
Create two planes. Plane 1 with a z sorting of 1 and the other with 0 and the rotationY of one of those planes set to 180. You could then contain this in one display container.

Version 2:
Create one cube with a depth of 0. Then you just apply a material to the front and back. OK OK OK so this is not really a Plane... but I like this approach because it allows me to more easily use things like Bend Modifier.

If anyone has a better or more improved approach we would love to hear about it.

Here is what the code for Option 1:

Actionscript:
  1. package com.cs54.ui
  2. {
  3. import org.papervision3d.objects.primitives.Plane;
  4. import org.papervision3d.materials.MovieMaterial;
  5. import org.papervision3d.materials.utils.MaterialsList;
  6. import org.papervision3d.objects.DisplayObject3D;
  7. import com.everydayflash.pv3d.modifiers.Bend;
  8. import flash.display.DisplayObject;public class Tree2Planes extends DisplayObject3D
  9. {
  10. [Embed(source="/assets/tree-side-1.png")]
  11. public var TreeFront        :Class;[Embed(source="/assets/tree-side-2.png")]
  12. public var TreeBack            :Class;
  13.  
  14. protected var treeFront        :DisplayObject;
  15. protected var treeBack        :DisplayObject;
  16.  
  17. protected var treeFrontMat    :MovieMaterial;
  18. protected var treeBackMat    :MovieMaterial;
  19.  
  20. protected var treeMatList    :MaterialsList;
  21.  
  22. protected var _height        :Number = 175;
  23. protected var _width        :Number = 191;
  24. protected var _container    :DisplayObject3D;
  25.  
  26. protected var plane1        :Plane;
  27. protected var plane2        :Plane;
  28.  
  29. public function Tree2Planes():void
  30. {
  31. treeMatList     = new MaterialsList();
  32. treeFront        = new TreeFront();
  33. treeBack         = new TreeBack();
  34.  
  35. //Tree Materials
  36. treeFrontMat     = new MovieMaterial(treeFront, true);
  37. treeBackMat     = new MovieMaterial(treeBack, true);
  38.  
  39. treeFrontMat.allowAutoResize = false;
  40.  
  41. plane1        = new Plane(treeFrontMat,_width,_height);
  42. plane2        = new Plane(treeBackMat,_width,_height);
  43.  
  44. plane1.z = 1;
  45. plane1.rotationY = 180;
  46.  
  47. _container = new DisplayObject3D();
  48.  
  49. addChild(_container);
  50. _container.addChild(plane1);
  51. _container.addChild(plane2);
  52.  
  53. }
  54.  
  55. public function get height():Number
  56. {
  57. return _height;
  58. }
  59. public function get width():Number
  60. {
  61. return _width;
  62. }
  63.  
  64. }
  65.  
  66. }

Here is what the code for Option 2:

Actionscript:
  1. package com.cs54.ui
  2. {
  3. import org.papervision3d.materials.MovieMaterial;
  4. import org.papervision3d.materials.utils.MaterialsList;
  5. import org.papervision3d.objects.DisplayObject3D;
  6. import org.papervision3d.objects.primitives.Cube;
  7. import com.everydayflash.pv3d.modifiers.Bend;
  8. import flash.display.DisplayObject;
  9.  
  10. public class Tree extends DisplayObject3D
  11. {
  12. [Embed(source="/assets/tree-side-1.png")]
  13. public var TreeFront        :Class;
  14.  
  15. [Embed(source="/assets/tree-side-2.png")]
  16. public var TreeBack            :Class;
  17.  
  18. protected var treeFront        :DisplayObject;
  19. protected var treeBack        :DisplayObject;
  20.  
  21. protected var treeFrontMat    :MovieMaterial;
  22. protected var treeBackMat    :MovieMaterial;
  23.  
  24. protected var treeMatList    :MaterialsList;
  25.  
  26. protected var treeCube        :Cube;
  27. protected var _height        :Number = 175;
  28. protected var _width        :Number = 191;
  29. protected var _container    :DisplayObject3D;
  30.  
  31. public function Tree():void
  32. {
  33.  
  34. treeMatList     = new MaterialsList();
  35. treeFront        = new TreeFront();
  36. treeBack         = new TreeBack();
  37.  
  38. //Tree Materials
  39. treeFrontMat     = new MovieMaterial(treeFront, true);
  40. treeBackMat     = new MovieMaterial(treeBack, true);
  41.  
  42. treeFrontMat.allowAutoResize = false;
  43.  
  44. treeFrontMat.animated = true;
  45.  
  46. treeMatList.addMaterial( treeFrontMat, "front" );
  47. treeMatList.addMaterial( treeBackMat, "back" );
  48.  
  49. treeCube     = new Cube(treeMatList, _width, 0, _height, 6, 6, 6);
  50.  
  51. var bend:Bend = new Bend(treeCube);
  52.  
  53. bend.quickBend(1, .1);
  54.  
  55. addChild(treeCube);
  56.  
  57. }
  58.  
  59. public function get height():Number
  60. {
  61. return _height;
  62. }
  63. public function get width():Number
  64. {
  65. return _width;
  66. }
  67.  
  68. }
  69.  
  70. }

More to come in the weeks ahead. New papervision tutorials, full source, and support will all be provided.

Thanks for your continued support.

Charles Schulze,
CS54, LLC

Codebase Changes, Updates Soon!

Hi Everybody,

Firstly, I'm sorry for the massive delay in updating this site, I've been super-busy with work over the past few months but finally the time has come to update all of my tutorials and examples. As many of you have noticed, the Codebase for GreatWhite has changed, meaning that most of my tutorials no longer work,  but with some small tweaks to my code the tutorials can be made to work again.

Over the next week I'm going to be going through all of my tutorials and correcting the errors so that they work with the newest version of GreatWhite. The updates -should- be fairly straightforward so I'll update you all when they're done.

In other news, Paulo Robson  from paulorobsonluz.com is kindly going to be translating my tutorials into Portuguese. I will add a link to each tutorial as it is translated.

Updates coming soon!

-Luke

*EDIT*

I've been through all of my tutorials and can now say that they are up to date!

Be sure to update your base class - the download link in the sidebar is the newest version.

Have fun!

-Luke

12. Animation using Tweener

Hi,

In this tutorial we're going to use Tweener to move a cube around. This will teach you basics of animation, and how to use Tweener (which is awesome).

The example that I've produced is this:

So, in this example our solid red cube is trying to stay inside our green wireframe cube. Every time the red cube gets itself positioned completley inside the green cube, the green cube moves.

Tweener is the package which is smoothly moving the red cube around. The Tweener package is also firing the event to move the green cube when the tween is complete.

1: To start off, you'll need Tweener. You can download it here if you don't already have it: http://code.google.com/p/tweener/

Once you've got tweener, either add the source directory containing the "caurina" folder to your project's classpaths, or add the caurina folder into your current project.

2: Import tweener - Add this line to your imports:

import caurina.transitions.Tweener;

3: Add a Tween. You can add tweens to any parameter of any object. The Tweener package will gradually change any parameter in your code to a new value over time, so only numeric values will work nicely. Anyway, you can read a load more about tweener at the google code page above.

To add a tween, we use the code

Tweener.addTween(object, {parameter1: value, parameter2: value2, time: X, 
transition:"transition", onComplete: functionname});

This may look a little bit confusing at first, but it's really simple. Let's show you a real example..

Tweener.addTween(cube, { x: 1000, z: 500, time: 2, onComplete: randomize } );

The line above will add a tween. This tween will change the values "x" and "y" on the object "cube" to 1000 and 500 respectively. It will smoothly change the values over a period of 2 seconds and once the tween is complete and the cube.x is 1000 and cube.y is 500, it will trigger the "randomize" function.

Experiment with more ways to tween your objects. You can apply tweens to anything, including cameras, lights, rotations, sizes and camera zooms. Any numerical value you can think of.

Here is my source code (Uses latest version of my base class):

Actionscript:
  1. package 
  2. {
  3.      import org.papervision3d.lights.PointLight3D;
  4.      import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
  5.      import org.papervision3d.materials.utils.MaterialsList;
  6.      import org.papervision3d.materials.WireframeMaterial;
  7.      import org.papervision3d.objects.primitives.Cube;
  8.      import org.papervision3d.objects.primitives.Plane;
  9.  
  10.      import caurina.transitions.Tweener;
  11.  
  12.      public class Main extends PaperBase
  13.      {
  14.           private var cube:Cube;
  15.           private var cube2:Cube;
  16.           private var mat:FlatShadeMaterial = new FlatShadeMaterial(new PointLight3D(), 0xFFFFFF, 0xFF0000);
  17.           private var mat2:WireframeMaterial = new WireframeMaterial(0x00FF00);
  18.           private var plane:Plane = new Plane(null, 2000, 2000, 10, 10);
  19.  
  20.           public function Main()
  21.           {
  22.                init(600, 300);
  23.           }
  24.  
  25.           override protected function init3d():void
  26.           {
  27.                cube = new Cube(new MaterialsList( { all: mat } ), 100, 100, 100);
  28.                cube.y = 0;
  29.                cube2 = new Cube(new MaterialsList( { all: mat2 } ), 100, 100, 100);
  30.                cube2.y = 0;
  31.                cube2.x = 1000;
  32.                cube2.z = 1000;
  33.                plane.material.lineColor = 0x777777;
  34.                plane.material.doubleSided = true;
  35.                plane.pitch(90);
  36.                plane.y = -50;
  37.                default_scene.addChild(plane);
  38.                default_scene.addChild(cube);
  39.                default_scene.addChild(cube2);
  40.                Tweener.addTween(cube, { x:1000, z:1000, time:2, onComplete: randomize } );
  41.                default_camera.x = 0;
  42.                default_camera.z = 1000;
  43.                default_camera.y = 1000;
  44.           }
  45.  
  46.           public function randomize():void
  47.           {
  48.                var xp:Number = (Math.random() * 2000) - 1000;
  49.                var yp:Number = (Math.random() * 2000) - 1000;
  50.                Tweener.addTween(cube, { x:xp, z:yp, time:2, onComplete: randomize } );
  51.                cube2.x = xp;
  52.                cube2.z = yp;
  53.           }
  54.  
  55.           override protected function processFrame():void
  56.           {
  57.                default_camera.lookAt(cube);
  58.           }
  59.      }
  60. }

Update and Downloads Section

Hi,

I haven't written a post in a while so I felt it was time to share what I've been playing around with.

I've put up a new downloads section where you can download various pieces of code that I've been creating, including code for parsing Heightmaps (click here) and Sculpted Prims (click here).

I'll have a proper update soon, and another Tutorial, I promise :)

-Luke


Tell a Friend

RSS Feed