24 December 2013

Educational Games and 2D Animation

This blog exists for more than 6 years now, which is by all standards very long. Last two years, however, due to huge changes around Flash and web development there was very low activity here, if any. Some other things prevail and I just couldn't find courage to end it. 

However, things changed again recently and I'm moving this blog towards new more sustainable future which is also presented as new blog description text: "Educational Games and 2D Animation". This new direction will provide some clear goals for this blog and my personal contribution to programming and animation world. More narrow niche means better posts and more results. I would like to promise at least three two new posts per month for first three months of 2014.

If you are involved in making Educational Games, not only using Flash but any tool available and you are interested in SmartBoard Games, let me know and leave your blog/website link. If you are 2D Animator and you have job to offer don't hesitate to tell me about it :)

*_*

15 March 2013

Random Array AS3 function

For my upcoming Memory variation game I needed a function to generate known length Array of random numbers out of given 0-n integers Array. For example when we call this function with this call:

randomArray(3, 10)

result is array with 3 random numbers from range 0-10, so it can be [0, 6, 3] or [9, 3, 2] or [0, 2, 1] but numbers cannot repeat. We can also call randomArray(n, n) in which case [0, 1, ..., n] is returned, but first function parameter must be less or equal to second parameter.

Here is how function might look like, comments are for testing purposes:

function randomArray(number:uint, total:uint):Array {

    var omega:Array = new Array();

    if (number <= total) {
        var alfa:Array = new Array();
        var pick:uint;
        var index:uint;
        for (var i:uint = 0; i<total; i++) {
            alfa.push(i);
        }
        // trace("alfa = "+alfa);
        while (omega.length < number) {
            index = Math.floor(Math.random()*alfa.length);
            // trace("index = "+index);
            pick = alfa[index];
            // trace("pick = "+pick);
            omega.push(pick);
            // trace("omega = "+omega);
            alfa.splice(index,1);
            // trace("alfa = "+alfa);
        }
    }
    return omega;
}

// function test
var om:Array = randomArray(5, 10);
trace(om);

If you are interested to read more about generating random stuff with ActionScript check these articles:
- Fastest Random Array Generator
- Simple Flash Snowflake Generator
- ActionScript Random Number Generator With Blur Effect
or type "random" in search box :)

*_*

11 March 2013

Reverse display list objects in AS3

Some simple tricks must be included to reverse display list objects in AS3 and that trick uses name MovieClip property, getChildByName and swapChildrenAt methods. Let's see code first.


import flash.display.MovieClip;
import flash.events.*;
import flash.events.MouseEvent;

var temp:MovieClip = new box();

for (var i:Number = 0; i < 50; i++) {
    temp.x = Math.random()*500;
    temp.y = Math.random()*350;
    temp.name = String(i);
    temp.alpha = i/50;
    addChild(temp);
    temp = new box();
}

stage.addEventListener(MouseEvent.CLICK, onStageClick);
function onStageClick(evt:MouseEvent):void {
    for (var j:Number = 0; j < numChildren/2; j++) {
        swapChildrenAt(j, numChildren-j-1);
        getChildByName(String(j)).name = String(numChildren-j-1);
        getChildByName(String(numChildren-j-1)).name = String(j);
        getChildByName(String(j)).alpha = j/50;
        getChildByName(String(numChildren-j-1)).alpha = (numChildren-j-1)/50;        
    }
}


For this example I will use MovieClip alpha property for visual representation of change after list reversing. First simple shape (sqaure in my case) has box class as linkage name.

Using for loop place on stage 50 of those boxes on random positions, but inside stage width and height dimensions. Using temp.name = String(i) line every box is named after its depth value, meaning first box added to stage will have name "0", second name "1", etc. Last one will have name "49".

Then, with temp.alpha = i/50 line we make every new box have slightly higher alpha value than previous one. We will reverse those alpha values later.

Function onStageClick will have single for loop, but with index going only half of number of boxes. In this way using swapChildrenAt we replace depth of box "0" with depth of box "49", depth of box "1" with depth of box "48", etc while entire list is reversed.

All that is left is to change names and alphas of new order using getChildByName method.



Image shows two different states, before and after the reverse.

*_*

08 March 2013

Learning Multimedia Development Online for Free

I just can't ignore some subjects here and have to touch them just a bit. One of those is for sure huge raise in MOOC in recents times (which stands for massive open online course).

There are many platforms right now that offer different types of online courses from free to paid ones, from beginners video tutorials to full-scale high class Universities courses.

I won't mention them all, instead I will only provide this link, which is place to find Top 50 Sites to Get Educated for Free.

I will however say that me personaly have used Coursera to learn Python, some Astrobiology and Sustainability :) and my experience is positive every step of the way. If you are in pursuit for knowledge Coursera is great, however if you need certifications, try some other place (for now, but it seems like that will change in the future). Coursera also won Best New Startup Of 2012.

Since I'm always hungry for more, my next project will be Diploma in Multimedia Development on Alison platform. It is free course where you can learn few multimedia tools like Adobe Photoshop, Windows Movie Maker, Adobe Flash, Audacity, Director MX and Adobe After Effects. I'm already familiar with some of those tools and I'm interested to see what new tricks can I learn.

Alison also offers free individual courses on PhotoShop, Flash, After Effects and Adobe Connect.

*_*

17 February 2013

Pure Citrus madness

As I can see from my first readings Flash game development market is huge, even growing on web and devices. Facebook is pretty big market. Pure madness.

Many are talking about Citrus engine which also uses Stage3D, Starling, Away3D, Box2D and NAPE. It seems like they are moving forward very fast. Citrus is higher level layer above mentioned libraries, which makes gamedev process easier.

Complete SWC engine with all extra libraries included in about 2.5 Mb available from downloads page and full API docs are easy to find.

Here is only one of many examples of how game may work if it is made using Citrus Engine.


New market files: Breakout Game Starter Kit | Top Down Shooter Kit

*_*

16 February 2013

Is Flash still alive?

I don't really know what happened, where was I and this blog for the past two years. It's like some space-time wormhole got me into its unimaginable depths and spit me out a couple of days ago.

Anyway, you can all assume I was in another dimension or something (I wanted to say prison but then I realized I could have had computer and Internet access inside it, so that's not good excuse) because I didn't touch Flash, web or mobile development or anything similar all this time! I know it sound incredible but it's true.

This means first I'll have to see what in the world happened with Flash in all this time :) Is it still alive and can I countinue with it?

I can see from my stats people still visit this blog quite often, so I guess there are some good info here for you to read and enjoy. If I need some help in catching up with new stuff don't be a stranger and help me out!

You can still connect with me via Twitter or Facebook page.

Flanture
*_*

 

template by blogger templates