Showing only posts in the series ActionScript 3 Tutorials

ActionScript 3: Array vs Vector Performance
ActionScript 3With Flash version 10, Adobe added the Vector class, which is similar to an Array but more strict. Each Vector can only contain data of the same type and its data type must be declared during instantiation. I'm not going to go over the syntax to use Vectors in this post, but they are very similar to Arrays and have a lot of the same methods and properties...
Aug 2, 2012   Nick Vogt   Programming

ActionScript 3 Object Pool Tutorial
ActionScript 3If you're unfamiliar with object pooling, it is a way to speed up processing time by keeping objects in memory and reusing them, instead of always instantiating new ones and garbage collecting them.

This example uses package and custom class syntax. If you are unfamiliar with these, see my introduction to package and classes post...
Jul 17, 2012   Nick Vogt   Programming

Fast Unit Vector Calculation for 2D Games
Here's a quick description of a unit vector for those that don't know. A unit vector is a vector with a magnitude (distance) of 1. The vector can be pointing in any direction, but the magnitude will always be 1. To get a unit vector from any old vector, you "normalize" that vector, which gives you a new vector with the same direction but a magnitude of 1. Unit vector and normalized vector are often used interchangeably...
Jun 17, 2011   Nick Vogt   Programming

ActionScript 3 Semi-Transparent CopyPixels
When working with BitmapData and copyPixels, you'll quickly run into the limitation of not having an alpha attribute with which to change the transparency level of objects. If you're like me, you started out using Sprite and MovieClip in your games and could easily fade-in or fade-out objects using the alpha attribute. Unfortunately, BitmapData does not have the alpha attribute, so how do you adjust transparency dynamically while using copyPixels?
May 31, 2011   Nick Vogt   Programming

ActionScript 3 Semi-Transparent BitmapData, ARGB
Creating semi-transparent BitmapData in ActionScript 3 is done using an ARGB hexadecimal value (32-bit). ARGB stands for Alpha-Red-Green-Blue and is just like an RGB hex value but with an alpha level at the beginning. Due to the alpha level, ARGB hex values are 8 hex digits and not 6. If you aren't familiar with hexadecimal, I suggest reading up on it before continuing...
May 31, 2011   Nick Vogt   Programming

Actionscript 3 Beginner Introduction to Package and Classes
Most Flash Actionscript 3 developers start out by writing code directly into the Actions window (F9), or into a separate .as file and using include to include that code into the Actions window. This works fine for quick, simple programs, but to get the most out of Flash and Actionscript 3, you should learn how to use Packages and Classes...
Mar 10, 2011   Nick Vogt   Programming

Actionscript 3 Passing Variables from HTML to Flash (FlashVars, Query String)
Passing variables to a Flash movie that is embedded in a web page can be done using either the query string or FlashVars. The difference between these methods is that using query string will cause browsers to re-download the Flash movie each visit, while FlashVars allows browsers to use the cached version. Depending on the functionality you want, one method may suit you better than the other...
Jan 17, 2011   Nick Vogt   Programming

Actionscript 3: Faster Math.floor and Math.ceil using int typecast
In order to use int typecasting in place of Math.floor or Math.ceil, you must first understand exactly what these functions do: Math.floor takes a number and returns the next lowest whole integer. Passing 0.9 will return 0 and -0.9 will return -1. Math.ceil returns the next highest integer, so will return 1 from 0.9 and 0 from -0.9. This is different than truncating, which would return 0 in all cases, and is why typecasting using int (usually used to truncate) wouldn't seem to work at first.

In order to make int typecasting work, you need to add a condition check to see if the number is negative or positive (negative for floor, positive for ceil), and adjust it by 1 if it is. Why do this instead of just using Math.floor or Math.ceil? Because it is faster and you can avoid a function call if desired. Look at these examples...
Nov 19, 2010   Nick Vogt   Programming

Bounding Box vs. Bounding Circle Collision Detection Performance AS3
Before doing more complex collision detection in a game, it is useful to first check and make sure a larger bounding area is colliding. This is so that only one calculation needs to be done for each collision detection most of the time, and then further collision detections are only done if objects are close and potentially colliding...
Nov 17, 2010   Nick Vogt   Programming

Fast Distance Threshold Formula AS3, C++, Java, Python
Most game programmers are familiar with the distance (magnitude) equation and how inefficient it is. Using a square root is a costly function that usually can't be afforded many times per frame. Here is a much more efficient distance equation for situations in which you want to check the distance against a threshold (such as determining if two bounding spheres collide)...
Nov 17, 2010   Nick Vogt   Programming



Categories

All Posts
Computer Hardware
PC Gaming
Programming
Web and Internet
Miscellaneous

Tags

youtube
minecraft
skyrim
call of duty
crysis
facebook
actionscript
php
javascript
tutorial

Series

› ActionScript 3 Tutorials
PHP Tutorials
Game Reviews