Programming, Visualization and Game Development Theory

02Sep Static Initializers… Flash has ‘em

While blog stumbling this morning, I have discovered that AS3 allows static initializers (or sometimes called static constructors). This allows a chunk of code to execute when the class is first referenced in a static fashion (for example while grabbing a static property). Below is a quick example of the syntax needed:

package {
  public class Test {
     {trace("Static Initializer");}
  }
}

I can’t think of anything particularly useful for this method except for very unique cases where frameworks or singletons need immediate initialization functionality sometime before their instance constructor is run…

Blog stumbles:
New ActionScript 3 Singleton Method
43 Hot Flex and ActionScript 3.0 APIs, tips and tools for Autumn 2008

Tags:

28Aug Flash Tween Proxy Theory

In the quest to find the most flexible, lightweight, and best performing tweening engine for Flash, I have come across a variety of packages including TweenMax/TweenLight, Go/HydroTween, and the new gTween. Currently, I swing towards TweenMax as the benchmarks have been favorable to it when dealing with hundreds of objects simeltanously. This aside though, I have been fascinated with Grant Skinner‘s gTween proxy idea. He creates a proxy object for a movieclip that allows automatic tweening on properties that the user would normally find and operate without a tween engine manually. See the below examples as they will make much more sense than a written explanation in this case.

Grant explains his proxy idea below:
(more…)

Tags:

27Aug Flash Develop 3.0.0 Beta8 released

Flash Develop 3 is one of those tools that really shouldn’t exist if Adobe had done their job right with the code editor in Flash. The Flash code editor is absolutely HORRID… no refactoring, almost no code hinting, poor highlighting, no visual class hierarchy, and the list goes on. Here is where Flash Develop comes to the rescue and solves all these problems. The only minor issue I have with Flash Develop is that it can be a hassle to get into a comfortable track of compiling out large Flash applications as its a little janky rigging it to the Flash compiler. On the up side, did I mention it’s free!

Well today Flash Develop 3 Beta8 is released and includes some of the following new features:
GUI and ActionScript:
* New “fullscreen” editor mode
* New common GUI for AS2Api and ASDoc
* SWF exploration shows the frame where definitions are imported
* Fine tuned code completion
* Dynamic syntax highlighting: custom classes get colored like flash classes (MovieClip, Event, etc)
* Completion for package-level declarations and Flash 10′s Vector. type
* Go To Declaration (F4) with SWC classes display a generated pseudo-class
* Improved generators

Link: http://www.flashdevelop.org/community/viewtopic.php?f=11&t=3470

Tags:

25Aug Papervision3d updates

Well, someone has finally done it… quasi-real reflections and shadows in Papervision3d. While this is only an experimental test done by the blogger Andy Zupko, it’s a great step towards better visuals in the engine. Now if only PV3D was 10 times faster and fixed z-sorting issues. ><

Andy Zupko – Flash Experimentation, tutorials, and portfolio.

Tags: ,

21Aug Flash – Working with Arrays

While working on a project that dealt with some heavy array manipulations, I have started using more and more of Flash’s utilities for quick array modifications. A couple of useful commands are the following:

// sorting movieclips in an array by x position
myArrayofMCs.sortOn("x", Array.NUMERIC);
// Fast 'for each' method for array item operations
// This is generally faster than the common for(var i:int=0, i < arrayLength; i++) {}
for each ( var mc:MovieClip in myArrayofMCs ) mc.buttonMode = true;
// Finding the index position of an item that is in an array that was clicked on
function onClick(e:MouseEvent):void {
 var itemIndex:int = myArrayofMCs.indexOf(e.currentTarget);
}

Tags:

07Aug Flash Tutorial: Flash Stage Size

Recently stumbled onto a blog post that pointed out the fact that you could use loaderInfo.width/height properties in junction with determining the center of the stage. This information helps a lot as I have found that IE6 will sometimes not report the correct size of the SWF in the browser on the stage properties .width or .stageWidth for example.

  • stage.width + stage.height – the size of the content on the stage.
  • stage.stageWidth + stage.stageHeight – that dimensions of the monitor the flash player is currently consuming
  • loaderInfo.width + loaderInfo.height – that of the Fla’s publish settings

http://troyworks.com/blog/

Tags: ,

06Aug Flash TOTD: Reverse loop with increment iterator

This can be done several ways… here are two of the faster performance-wise ways for this:

var maxNum:int  = 5;
var inverse_i:int;
for(var i:int=maxNum; i => 0 ; i--) {
   inverse_i = maxNum - i;
   trace(inverse_i);
}
// or you can do this:
var inverse_i:int;
for(var i:int=5; i => 0 ; i--) {
   trace(inverse_i);
   inverse_i++;
}

Tags: ,

05Aug Flash Links of the Day

Science&Code: Actionscript optimization

Posting on FinalFinal.com on the makings of the Red Invaders Flash Game.

Casual Game Development Blog – Techniques and Algorithms (most theories can be applied to Actionscript)

Tags: ,

05Aug Flash: Creation of general children

In the event of making new children, especially like library movieclips, you could create a generic function that receives the class reference for the movieclip you wish to create. For the below example, let’s say in your library is a RedBox linked movieclip with a variety of other movieclips like it that all need to be created the same way:

addChild( create(RedBox) );

function create(ObjectType:Class):MovieClip{
  // Adding "as MovieClip" tells Flash that ObjectType will be
 // some kind of MovieClip derived class.
  var newMC:MovieClip = new ObjectType() as MovieClip;
  // Add new event listeners to newMC
  // Add logic or variable settings like X and Y
  // returns the newMC to be added to the stage.
  return newMC;
}

The benefit is you can dynamically create objects that all get setup the same way… the function does not care what type of movieclip needs to be created just as long as it’s a type of movieclip.

Tags: ,




Bad Behavior has blocked 104 access attempts in the last 7 days.