Monthly Archives: April 2012

7 Days of ActionScript – Day (and Night) Seven

0
Filed under 7 Days of ActionScript, Code, The Quest

I finished my little Sudoku thing the other day.

Day Seven was very productive, though due to starting late, it did drift into late night/early morning!
Although I didn’t get sound done ( or bitmap loading, either.. it was all drawn shapes, ) I did get a lot done, and my little Sudoku game actually worked out fairly well considering I did a crash course in ActionScript within a week.

I’ll put it up soon for a giggle.

One thing that tripped me up a huge amount was variable scoping.
Usually, variable scope is to the current code block.. so if you were to do:

1
2
3
4
5
6
7
8
9
10
void myFunction(const bool inputBool) {
    bool myBool(false);
    if (true == inputBool) {
        bool anotherBool(true);
        myBool = true;
    } else {
        bool anotherBool(false);
        myBool = false;
    }
}
void myFunction(const bool inputBool) {
    bool myBool(false);
    if (true == inputBool) {
        bool anotherBool(true);
        myBool = true;
    } else {
        bool anotherBool(false);
        myBool = false;
    }
}

You wouldn’t have a problem, as anotherBool loses scope in each block.

However, doing something like:

1
2
3
4
5
6
7
8
9
10
public function myFunction(inputBool:Boolean):void {
    var myBool:Boolean = false;
    if (true == inputBool) {
        var anotherBool:Boolean = true;
        myBool = true;
    } else {
        var anotherBool:Boolean = false;
        myBool = false;
    }
}
public function myFunction(inputBool:Boolean):void {
    var myBool:Boolean = false;
    if (true == inputBool) {
        var anotherBool:Boolean = true;
        myBool = true;
    } else {
        var anotherBool:Boolean = false;
        myBool = false;
    }
}

You’d get an error, as anotherBool was declared in the first block.
ActionScript’s variables are scoped to the function.
Which is really flippin’ annoying when you come from a background of coding the first way!

But yes, I’m proud of my little Sudoku game, done in 7 days, in ActionScript, on Linux.
It’s not very fancy or pretty, but it does the job. ActionScript has a rather large amount of support code that I didn’t get anywhere near ( like for Images, the preloader stuff, Audio, etc… ) so maybe I’ll have a look at them next time.

Still, it was fun :)

7 Days of ActionScript – Days Five and Six

0
Filed under 7 Days of ActionScript, Code, The Quest

Day Five was not wholly productive as I found out I had managed to download the 4.1 version of the Flex SDK… they’re up at version 4.6, which added, amongst other things, “native” JSON support.
That was clever of me.
So the few hours I had were spent banging my head against the wall, wondering why stuff wasn’t working, then spending the rest of it downloading the _correct_ SDK. I did at least get some working file utils going, so wasn’t completely wasteful.

Luckily, Day Six has been very productive and I now have my example up and running.
It’s a little Sudoku game. Why? Because Sudoku itself is a relatively straight-forward game with some nice little mathematical fun to it – especially when figuring out a decent solver.
All you need to do is fill a grid with numbers from 1 to 9, and ensure each block has unique numbers, along with each row and column.
Granted, my solver just brute forces it at the moment, but I’ll take simplicity over complexity any day… that and I’ve still got to try and make it look pretty, as all it’s doing is reading an array from a file, fiddling with it, and spitting it back out to another file. Not really game material, eh?

So, tomorrow is effectively my last day on this… and I’ve still to figure out input, displaying graphics, proper event management, playing sounds… at least my shoulder has healed up a bit, and I can work a bit later into the night again.

7 Days of ActionScript – Days Three and Four

0
Filed under 7 Days of ActionScript, Code, The Quest

Wow, time flies when you’re not paying attention!

Yesterday, it wasn’t until about 10pm before I had time to look at anything, and was rather knackered so the extent of it was further testing of the toolchain with something a bit more advanced than my “hello world” apps. I compiled a few Flixel examples and they ran without any issues. Then I fell asleep. But the toolchain did spit out the examples correctly, so I feel confident enough that I set it up correctly!

Tonight, I’ll get started on something myself, as I’ve a big base of code that I can look over if need be, and I’m about half way through the 7 day deadline. I’ve a feeling the next few nights could be all-nighters to get it done, but with it being the Easter Holidays and with a 4 and a 5 year old running around, that’s looking like the likely option!

( The extra proof that I’m perhaps run ragged by these two little whirlwinds, is that I posted this as a page rather than a post originally *cough* )