Showing only posts with tag actionscript
Page 2 of 2
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...
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)...
In Actionscript 3 there are usually different coding methods to achieve the same output (this can be said of any programming language). Variables can be declared in different ways, math equations can be performed in different ways, you can move code into functions, perform things on single lines or multiple lines, and so on and so forth. While different methods may achieve the same output, certain methods are often faster than others. This post is dedicated to finding as many performance tweaks and enhancements as I can, and I will update it as I find more...
Functions are useful tools that allow you to reuse code, reducing file size and keeping your application better organized. There is a trade-off however, and that is function overhead. An Actionscript 3 application will take a small hit in performance when moving a section of code out of the normal flow of the program and into a function...
Unsigned integers are integers that can be positive values only. They are useful to have in programming languages because they can hold a higher maximum positive value than a signed integer, without using additional memory. For example, int in Actionscript 3 is a 32-bit signed integer and can hold a range from -2,147,483,648 to 2,147,483,647, while uint is a 32-bit unsigned integer and can hold a range from 0 to 4,294,967,295. It is useful to use unsigned when dealing with large counters that will never be negative, as it gives you a higher maximum...
While creating a dynamic music player for the web in flash (AC3) I ran across a bit of an issue. When attempting to get the length of a song using the .length function, flash only returns the length of what it has loaded so far. Until the sound is fully loaded, flash is unable to tell you the length in seconds of that sound file. I found a solution that works well and doesn't rely on the length being manually inputted or pulled from the ID3 tags...
Page 2 of 2
