Tuesday, July 14, 2009

OOP is my friend

I have been building applications using more 'object oriented' techniques. An old dog like me who grew up coding basic, keying in machine code and the sort, may have trouble adapting to new methods.

After page upon page of confusing examples of inheritance, encapsulation, polymorphism and other oop terms, i decided to take some advice of a colleague and break it all down to the simplest parts. So I did and I think the fog is clearing a little concerning OOP.

Some tips about grasping oop:

1) Everything is an Object

2) Classes are blueprints

3) Extending a class opens up all of those methods to your new class, build on that foundation

4) An object does not exist util instantiated

5) OOP is a tool, it cannot replace procedural programming

OOP programming comes in many shades of gray, for this post lets consider that oop procedures are accomplished through the creation of Actionscript 3 class packages , hence objects. Each object is responsible for one thing, being itself.

Program for me a candle.

I would package an actionscript class called Candle . Within this actioncript file I would procedurally program the functionality of a candle. The candle should react to things just like a real one. Create a function
lightIt();
You call the function the candle brightens the room. The amount of functionality is totally up to you, the "object creator". There is no limit, your candle object could react to being left in the sun or even relight like a joke birthday candle. Just be sure that you don't go to far. Make the candle as basic as possible and extend it into new child classes, like a birthday candle class that extends Candle. You can always make objects more complicated , start simple.

Now store your candle in your special package directory and call upon it any time in the future when you need an object like a candle. Build upon objects, add functionallity simply and quickly, and then interact with other objects that you have created.

Friday, July 10, 2009

Game Archive and Review

Check out these game reviews and play our daily free flash game picks on the Hyperspatial web site!

About to go Live with Avangate

I am about to kick off my software selling endeavor through Avangate. I am very pleased with the experience so far. Avangate is a multi national software vendor. It was easy to setup my account and customize the shopping cart to match my web site's look with css. They set up a pre payed master card that arrived in the mail within a few days of joining up.
They work on a commission system with no monthly fee. I am very happy with their support team and hope to do business with them for a long time.

I am hoping to reach customers across the globe. Right now I am selling my nature sounds player that I created on the Adobe Air platform using As3, the program is absolutely fabulous. Check it out here

I am working on setting up my banners and pad files for my affiliate program right now and I will post some links to check out in a couple of days for you to join my affiliate program through Avangate. I have not decided on a commision yet but I will probably offer somewhere in the vicinity of a 20% commision on sales. All you have to do is sign up as an affiliate and put one of my .jpg images on your web site or blog as a link. The user's browser stores a cookie for 4 months that tracks their purchases of my software and then if they buy, you get the commision.

I will keep you posted.

Tuesday, July 7, 2009

Transparent SWF

I was creating a .swf file player for my website. The player is used to prevent the annoying "autoplay" that tend to be difficult to stop. Some flash games are setup so there is no easy way to prevent this, hence your page opens up and plays the game soundtrack right away. Sorry I need to control that, even setting javascript control for the flash to param play="false" does not always work.

Anyway, the .swf file I created that plays .swf files when you click on the play button. The problem I had was that I set the player to
param wmode="transparent"
this caused games controlled by the arrow keys to scroll the browser at the same time. That makes it impossible to play the game.

Moral = If you load a swf into another swf that is transparent you may have issues with browser scrolling

points and pixels

points = pixels * 72 / 96

75 = 100 * 72 / 96

pixels = points * 96 / 72

100 = 75 * 96 / 72

Vista and air

When you try to direct download an .air file via adobe air and ie7 or 8 on your vista os it will think that the air file is a zip file. The solution is simple, change the extension to .air

You can also do it the right way and set up an air badge to properly install the air program.

Object stuff

Just adding some of my daily epiphanies.

The ability of As3 to just assign description strings "I call them", to objects is as handy as a four armed butler. If you need some kind of switch in your program you don't necessarily need to declare a public variable to use as a switch. It is very simple to just add a string to an object. My object is Player. just add dot syntax and:

player.state = "off";

For the newbies you can add anything you want to your object, real time, like this:

player.happynessiocity = "groovy";

Makes for an easy conditional to check a condition, like this:

if(player.state == "off")
{
}


This is a bit of a hack and it throws a swf error but runs. Maybe will work in a pinch but here is a clever solution for a switch in a case where event flow won't allow you to access a listener somewhere. Just change the name of the button.

player.name = "off";

You are effectively negating listeners of parent display object containers elsewhere until you return the name to normal:

player.name = "playbutton";

Concerning functions, it is very handy to be able to send a function an object. You can then mass produce object modifications, like alpha, scale, with dot syntax. Just pass the function the object and then change it:
changeTheSize(myObject);

function changeTheSize(obj:myObject):void
{
obj.scaleX = 1.5;
obj.scaleY = 1.5;
}


You can create factories this way and just send in anything you want to make bigger, or whatever.