CHILD_REMOVE Event Triggered Before Actual Child Removal

One of the many things I learned from my development experience with Tongits is that the CHILD_REMOVE event of the ChildExistenceChangedEvent object actually happens just when a child is about to be removed and not after the child was removed. This means numChildren is still the same inside a CHILD_REMOVE event listener. On the other hand, the CHILD_ADD event happens after the child has been added to the display list.

Thrower - A Simple Ball Throwing Game in AS3

 A Simple Ball Throwing Game in AS3

This is a small experiment on simple ball physics and collision detection wrapped in a frustratingly difficult game. You have to successfully shoot a ball to progress to the next level. The arrow simply rotates by 1 degree on each level. If you successfully complete all 51 levels you’ll be able to play the game in “free play” mode where you can control the direction of the arrow with the mouse. If you manage to finish the game please do tell us about your accuracy rating and how many minutes it took you to win the game. It took me about 15 minutes to finish the game with a very low 24% accuracy. I think this kind of gameplay coupled with a nicer reward system plus better graphics has potential to be a nice little flash game.

Play Thrower

Source Code 

How to Make a Tetris Game in AS3

TINT - Tint Is Not Tetris

I had some free time this week so I tried to make a Tetris clone. It is a complete game in under 600 lines of pure AS3 code. It mainly uses 2 dimensional arrays to represent masks for the bricks and to make collision detection easier. The output is simply a bitmap data filled onto a shape object and then scaled to a more comfortable zoom level. I did not refer to available algorithms online, I tried figuring them out by myself so you might find them to not be the most efficient.

Just add some sound, fancy graphics and high score submission and this could be a nice little online game though TTC won’t be too happy about that. I named the game TINT for Tint Is Not Tetris.

Play TINT

Source Code

Disclaimer: This is purely for educational purposes only.

Custom Menu Project Files

Custom Menu

Shashikurlemali asked a few days ago for the projects files for my Creating a Custom Menu Using Item Renderers tutorial so here it is. Just right click on the demo to view the source and download the zipped project files. I lost the original project files so I had to create a new one with new SWF objects. I also added item click event handlers.

Here the SWF objects are loaded at runtime, it is better to just embed them since they’re just a few kilobytes. I’ll leave that as an exercise for you.

Tongits: An AIR Powered Game

Tongits Game ScreenshotI have just released version 1.0 of Tongits, an Adobe® AIR™ based game that I’ve been working on for almost 2 months now. It is a significantly improved version of my old open source Tongits game. This time I decided to release it as shareware, registration is $15. I think this will greatly help in motivating me to continue working on and improving the game.

This is also a sort of experiment on the commercial viability of AIR as a game development platform. I have big plans for this little game including multiplayer support and online betting.

I hope you enjoy playing and if you think it is worth the $15 then please register. Thanks!

Visit Tongits’ Website

Simple Way To Invert The Colors Of An Image

Simple Way To Invert The Colors Of An ImageSimple Way To Invert The Colors Of An Image

We need to put the Image object inside a Canvas and create another Image object with the same source file inside the parent Canvas. We then set the new image’s blendMode to invert.

private function invert(holder:Canvas):void {
if (holder.numChildren > 1) {
// remove the invert effect
holder.removeChildAt(1);
} else {
var img:Image = holder.addChild(new Image()) as Image;
img.source = Image(holder.getChildAt(0)).source;
img.blendMode = BlendMode.INVERT;
}
}

New Custom Shapes For The Dynamic Abstraction Demo

New Custom Shapes For The Dynamic Abstraction Demo

I’ve added some new functionality to the random art app including drawing custom shapes created using curves, and repositioning the drawn objects.

Create some art now.

Dynamic Abstraction Or Randomly Generated Art

Dynamic Abstraction Or Randomly Generated Art

Here is a simple demonstration on how to create randomly generated computer art or Dynamic Abstraction. This demo was inspired by Joshua Davis‘ work.

The application accepts a range of values for the color of the fill, size and number of circles, transparency, thickness and color of the stroke, etc. The program then randomly chooses values from the given range to create the artwork. The program can be enhanced by adding other shapes and objects

Create your own dynamic artwork now. Right click on the application to view and download the source code.

Add Slight Delay When Dragging an Object

Add Slight Delay When Dragging an Object

To add a delayed drag effect to an object, call startDrag in the rollOut event of a smaller canvas contained in the object instead of in the object’s mouseDown event. We would need to dynamically move the smaller canvas relative to where the mouse pointer is located after a mouseDown event.

One practical use of this is for image editing applications that require the mouse to appear slightly less sensitive when dragging objects around. This avoids “accidentally” moving an object by a few pixels.

See the live demo of this concept. You can also right click to view or download the source code.

Thanks to Bjorn Basar for the idea.

TextArea.text.length not TextArea.length

To get the updated count of the number of characters typed in a TextArea control, bind the length property of the TextArea control’s text property instead of directly using the TextArea’s length property. Use this alongside the maxChars property of the TextArea to display the current number of characters typed or the remaining characters that can be typed.

here are some example text properties to put on a label control:

text=”{myTextArea.text.length} chars typed (max {myTextArea.maxChars})”

sample output:
99 chars typed (max 500)

text=”{myTextArea.maxChars - myTextArea.text.length}/{myTextArea.maxChars} characters”

sample output:
401/500 characters

Next Page »