Messing about with the AS3DMod library

December 10th, 2009

I don’t know why but I have had AS3DMod in my collection of libraries for some time now, but have never gotten around to having a play with it….what fun I have been missing out on!.
It is a nice lightweight library that allows you to modify the vertex geometry of primitives in many of the most popular AS3 3D engines. It is very simple to use and applying a modifier is as simple as creating a modifier stack – targeting which ever 3D library you want which AS3Dmod supports, creating an instance of the modifier wanted and adding it to the stack. You can animate the variables of the modifer with your favourite tweening engine and come up with some nice effects.


The Flash plugin is required to view this object.




In the example here, I have used the four modifiers I think work best with a plane primitive and letting the tweens interact with each other if they have tweened in. I have also used Keith Peters minimalComps library for the radio buttons due to their simplicity and very low footprint, which are great for testing apps. You will also need to have the tweenLite library for this example and of course for the 3D library I have used Papervision.

If you want to have a look you can get the source here.

If I get a bit more time later I will have more of a play and see if I can produce something more interesting!

Categories: Actionscript 3.0, Papervision | Tags: , , | 4 Comments

AS3 3D Tunnel effect tutorial now up on Vimeo

July 24th, 2009

3D Tunnel effect tutorial – Flash & Actionscript 3.0 from UltraVisual on Vimeo.

Re-creation of a tutorial I recently saw which created the same effect but with AS2…so I thought I would bring things up to date and show you how simple this was to create using Actionscript 3.0 instead.

I have just recently finished my first of many video tutorials for this site. I have posted it on Vimeo so the video is viewable there or you could just watch it straight from this site here. The tutorial covers a recreation of an effect I saw posted in this months Digital Arts Magazine. Shockingly the magazine’s article covered it in AS2 – the scoundrels! So I thought I would cover the same effect here, but show how simple it is to create by using Actionscript 3.0 instead! Enjoy!

Categories: Actionscript 3.0, Tutorials | Tags: , , , | 1 Comment

Simple grass / hair effect with actionscript

June 11th, 2009

Well I have been very busy lately and sadly away from flash and totally immersed in Blender3D for a current project. I love Blender to bits but missing flash and actionscript badly. Anyway Blender has some great effects and one is the hairs creation from particles, which gave me an idea for a little test in actionscript to see how simple it would be to create a grass or hair strand effect in flash. It proved to be incredibly easy. I will explain here.
All I have done is created a movie clip in flash with 7 frames, on each of these frames I have drawn a blade of grass by using the stroke tool and assigning a green color. I have then exported this for action script and in the class file for this I have assigned a random number (between 1 & 7) as a variable and in the constructor told the movie clip to stop at this frame.

Actionscript:
  1. private var num:int = Math.ceil(Math.random()*7);
  2.  
  3. public function Hair()
  4. {
  5.         this.addEventListener(Event.ADDED_TO_STAGE, added);
  6. }
  7. private function added(e:Event):void
  8. {
  9.         this.removeEventListener(Event.ADDED_TO_STAGE, added);
  10.         this.gotoAndStop(num);
  11. }

In the main document class I have created a for loop and created 3000 instances of the hair movie clip and given them a random place on the stage, making sure that if the movie clip passes the 'bounds' of the stage it is moved to another random place on the stage.

Actionscript:
  1. private function init():void
  2. {
  3.     for(var i:int = 0; i <2000; i++){
  4.         var h:Hair = new Hair();
  5.         randomPos(h);
  6.         h.x = xPos;
  7.         h.y = yPos;
  8.         h.filters = [drop];
  9.         this.addChild(h);
  10.     }
  11. }
  12. private function randomPos(object:Object):void
  13. {
  14.     xPos = (Math.random()*stage.stageWidth);
  15.     yPos = (Math.random()*stage.stageHeight);
  16.     if(xPos> stage.stageWidth || xPos <0){
  17.         randomPos(object);
  18.     }
  19.     else if(yPos> stage.stageHeight || yPos <0 + (object.height + 30)){
  20.         randomPos(object);
  21.     }
  22. }

Now this will just look like a bunch of green lines on the stage if it is published now so to finish it off we just add a drop shadow filter to each blade to give them depth and presto! Totally pointless but pretty sweet grass. Next to add some interactivity?!

Get the source here

Categories: Actionscript 3.0 | Tags: | No Comments