Tuesday, January 31, 2012

Loader And Functional Menu Framework complete

Thankyou Tyler for the music.
The "pre-loader" I made worked fine when testing on my computer in CS5...
But something is going wrong here... I think that... The pre-loader glitches
out when it tries to load but the .swf is not in focus. Just a hunch.

After trying multiple versions of loading I have decided the best way to
get the loader to work is by hard-coding the file-sizes to be downloaded in the
I just tried a 3rd party plugin with file: "F37_D" (version D) and it still had
the same problem. I hear this can be solved with a server side solution that
can answer requests for file sizes. BUT... Lets patch it up the simple way.
My loader class will have an optional parameter for a file-size override.
When in effect, it ignores the file-size given by flashes progress event.

Version D has had the 3rd party plugin removed.
For the time being, my solution is a simple "sizeOverride"
parameter in the items I add to the loader.

As3 TLFTextField instance problems: may be a struct, not a class

I made a class that takes TLFTextfield objects on the stage and passes them to a constructor that uses them to setup an instance of my PL_PreLoader class. While testing I found that it looks like TLFTextFields do not work like ordinary display objects in that when I passed their instance name to my constructor they seem to have been passed by value rather than reference. This would explain why there are now DUPLICATE copies of each TLFTextfield sent to my constructor. I will do another simle test to see if this theory holds. I am thinking maybe TLFTextField internally is actually a STRUCT and not a CLASS.

Update: Further testing shows this problem only happens when the text object is
passed to a class that extends Sprite or MovieClip. And my guess, any display object. Also interesting is that this duplication only happens ONCE. Meaning taking the TLFTextField instance on stage and passing it multiple times to constructors of a class that extends sprite... the cloning will only happen once.

Friday, January 13, 2012

Crazy Comets Clocking In

Total Work Time for this span of awake time: 9HRS
1. Made new art assets at smaller resolution.
2. Researched standard flash game sized. 700x500 is max for kongregate (spelling?)
3. Made stand-in menus for game.
4. Respawn menu being only one that works.
5. Fixed collision so that bounding boxes are correct when object is scaled.
6. Fixed collision so that circle-circle collision now works.
7. Added "reSpawnSpecific" method to physics manager.
8. Added a "resetMenu" method to UI_FocusButtonMenu class.
9. Talked with Tyler about music for game. :)
I think that is it... but I am a bit delirious.

Thursday, January 12, 2012

.getBounds "wrong" results.

When getting bounds of an object relative to it's OWN coordinate system,
those values will NOT be scaled. I was trying to figure out why my bounding
boxes were off with the explosions in my game. I realized it was because
I created the explosions by scaling the objects in the game, which made
the results of .getBounds unreliable.

var oBnd:Rectangle = someObject.getBounds(someObject);
var bLft:Number = oBnd.left   * someObject.scaleX;
var bRgt:Number = oBnd.right  * someObject.scaleX;
var bTop:Number = oBnd.top    * someObject.scaleY;
var bBot:Number = oBnd.bottom * someObject.scaleY;
//Now use bLft,bRgt,bTop & bBot to make your calculations.

3HRS30MIN. Time For Bed.
Sleep on why my collision checking is not working when trying to go from bounding box collision to circle-circle collision.

Website Portfolio

Note: My schedule is not consistent and I always find myself working on things
add very odd hours. From now on... Add progress to blog every day. No matter
how mundane, and leave how many hours of work (According to your stopwatch)
it was. Today: 6HRS 30MIN

[ What I finished: ]


Tuesday, January 10, 2012


Testing a class that takes the original position of objects
and makes them scroll to swap positions with each other.
Going to use in a "slideShow" type portfolio layout...
Unfortunately... the new "goto" command only moves forward to it's target...
I need to fix this... Possible quick hack may be to emulate the forward
or backward button pressing the amount of times needed to get to the target.

EDIT: Fixed. Made a utility that that finds the closest distance between two
points on a circle. Or rather, a tessellating/wrapping range of numbers.

Example: On the range 0-10, the closest distance from 3 to 10 is 4.
3,2,1,0,10 is shifting 4 places from the number 3.

Simply Debugging Code JMIM02.UI_FocusMenuButton.as

Debugging a UI menu class I wrote. Mostly internal debugging.
Already tested the visible results earlier. I made adjustments to
the constructor for this class so that setting up arrays of buttons
in a set would be less verbose.

Get number of arguments in bound function in AS3

function threeArgs(a1:int,a2:uint,a3:Number){};
var f2:Function = threeArgs;

Set Text Size in AS3

set text size in as3:
Not as simple as theTextField.size = someNumber
Solution Below:

import flash.text.TextField;
import flash.text.TextFormat;

function setTextSize(i_txtFld:TextField, i_ptSize:Number){
    var tmpF:TextFormat = i_txtFld.defaultTextFormat;
    tmpF.size = i_ptSize;
    i_txtFld.defaultTextFormat = tmpF;
    //Not simply this easy..
    //i_txtFld.defaultTextFormat.size = i_ptSize;

Efficient bounding box collision

I made a bounding box collision that uses bit-shifting.
By multiplying the bounds of each object and then rounding the result,
I get 2 numbers between 0-31 for the min/max on the Y and the min/max on the X.

I then create two unsigned integers that have bits set in a pattern to represent
the space the object takes up on the X and Y axis. After that, I sort the object
on both the X and Y axis by 32 different rough positions.

After that, I do collision tests between the first sorted object in the sorted
X array. If X is NOT colliding with the next sorted object on the X-axis, I know that object collides with nothing. If it DOES collide on the X, I check the Y to
see if it is also colliding on the Y.

If it is NOT colliding on the Y, rather than go in a pattern of:
1. Look at next x. Then look at that x's y if they are colliding...

I go back and forth between going through the sorted x's and going through the
sorted y's. I do this to avoid a worst case scenario where ALL objects are colliding
on the X axis, yet very few are colliding on the Y. Or vise versa.

Also, if "A" is colliding with "B", we do NOT test "B" against "A".

Something is wrong with calculating the bounding box after scaling objects in AS3.
At least, with how I am doing it. After I figure that out, I will use the bounding
box to create an inscribed circle to turn my bounding-box collision into circle-circle collision.

Monday, January 9, 2012

Pop Up Score Display For Destroyed Asteroids

Note: Gaining focus is a bit weird... You'll have to mouse in, then mouse out...
Will work on fixing this later as it is very user unfriendly.