Flash Player 10 meets 3D

about 3 years ago malczak actionscript, graphics comments

It have been over one month since last post, but there were so many things that needed to be done :) In this post i will just drop a line about 3d in new Flash Player 10. Recently Im writing some experiments, tring to understand how 3d in fp10 works. Doing this I also came across one very interesting site - http://wonderfl.kayac.com. At this page You can write and build Your AS3 code. But lets get back to 3d...
Writing 3d 'worlds' using flash drawing API is hard, because 3d philosophy is a bit twisted. This post shows how to manage multiple sprites in a 3d as3 world. You will see how to create 3d spiral, that can be used as an image gallery. To create 3d spiral from a set of DisplayObject's we need to perform these steps :

  • place objects on a circle in XZ plane
  • add some shift in Y direction
  • append some additional rotation (just to look better)

There is also one important step that need to be done. Flash Player doesn't do any Z sorting of DisplayObjects. Drawing order is based on objects depth (child index) not on its Z coordinate. This is how it works.

Flash player (ver. 10.0.0) is required to see this content. Please update to newest possible version.

Get newest Adobe Flash player

And here is code (check out woderfl to modify online) with few comments:
 1 package {
 2  import flash.display.*;
 3  import flash.geom.*;
 4  import flash.filters.*;
 5  import flash.events.Event;
 6 
 7  [SWF(width="400", height="400", backgroundColor="0xffffff", frameRate="15")]    
 8   
 9   /**
10   * @author : Mateusz Malczak (http://segfaultlabs.com)
11   */
12   public class Main extends MovieClip {
13 
14      private var bv:Vector.<bitmap> = new Vector.<bitmap>(0,false);
15      private var stepRotMtx : Matrix3D;
16 
17      public function Main():void
18      {
19 /* You can use images instead of this */
20         var s:BitmapData = new BitmapData(120,120);
21         s.perlinNoise(200,200,8,Math.random(),true,true,BitmapDataChannel.BLUE,true);
22         
23         var blurf:BlurFilter = new BlurFilter(8,0);    
24 
25 /*constants*/
26         var R:Number = 200; /* spiral radius */
27         var sd:Number = 18; /* spiral leap */
28 
29         var rdl:Number = R * Math.sqrt( 2*(1 - Math.cos( 36*Math.PI/180 ) ) );
30         rdl = Math.atan2( rdl, sd ) *180/Math.PI; /* side radius beetween two elements */
31         
32         /* create bitmaps */
33         var i:uint;
34         var b:Bitmap;
35         var m3d:Matrix3D;
36         var alfa:Number;
37             for ( i=0; i b2.z ) return -1;
38         return 0;
39     };
40 
41   }
42 }
43 </bitmap></bitmap>

Comments

over 1 year ago hariSbabu http://www.onemg.in/ #0

Hello,
when I copied the code and try to execute as a document class basic vector itself is unable to create.

1046: Type was not found or was not a compile-time constant: Vector.
How o execute or impliment this code?

New comment

  1. (with http or https prefix)

  2. (use [code][/code] tags to post a code snippet)

  3. (javascript is required)

Website content premeditately commited by malczak & sobstel.
Layout by mlando. Icons by dryicons.com. All rights reserved.