Posts Tagged ‘Flash’

This week in the news

Wednesday, October 7th, 2009

Adobe MAX is going on right now in Los Angeles, California, and while I wasn’t one of the lucky few selected to attend from my company this year (not sour grapes, I went to Chicago in ‘07 and had a blast), I have had to follow it’s updates through Twitter.

Anyway, Monday morning they made an announcement that when Flash CS5 is released, you will be able to port Flash games, applications, etc. to native iPhone apps. For a Flash developer like me, this has been a long time coming and I have to say I’m excited.

Couple this with the news that Bell (my cellphone provider) has recently confirmed they will be selling the iPhone next month, and you have someone in me who I would title as an “eager-soon-to-be-iPhone-owner”.

Here is a video showing off some of the apps for the iPhone built in Flash. I’ve already seen people coming out saying that this is a terrible idea, but I think those people are wrong and any questions and concerns they may have will surely be considered and fixed by Adobe.

Some great Box2D tutorials

Tuesday, August 11th, 2009

As a Flash developer, I’ve always been interested in learning a physics engine. It’s no secret that Box2D is considered one of the best physics engines around for any language, and there is a port to ActionScript 3.

What’s even better are these tutorials, which go over a nice introduction to Box2D in Flash, as well as a great tutorial on how to create a Peggle (another one of my beloved casual games) clone!

Anyway, I thought this was well worth a blog post as these tutorials have really helped me out and I believe they can do the same for others.

Flash Library Symbols in Flex

Monday, June 29th, 2009

Currently I am working on some games for my full time job with theRedSpace. The team I am a part of decided that what would be best is that we go with Flex (now Flash Builder) rather than Flash. Now I am by no means “afraid” of Flex, but as a very visual person I prefer to program in Flash, games especially. The main reason for this of course is because in Flash I have my beloved library where I can build my Movieclips to my heart’s content.

So the problem for me was “how can I use my Flash symbol inside my Flex project easily?”. At first I was thinking about simply loading external assets, but I then would have about 50 or more asset SWFs that I would have been trying to manage, and for me, that just wasn’t an option. I thought next about using the “Embed” meta tag to embed the SWFs and then use the symbol attribute to grab the clip I wanted by simply marking my Movieclip symbol for export into ActionScript in my Flash library. I learned quickly though that this would not be an option as when I bring a clip in through use of the embed tag that my code in the timeline is stripped (I don’t like putting code in the timeline, but for my simple stop() and gotoAndPlay() commands I really don’t mind it).

So I was back to where I started. Luckily I came across a great tutorial online (can’t find the link, but when I do I will post it here) that mentionned using the getDefinition() function to grab symbols from library symbols in Flash. The code is actually very simple. You just load the clip using a normal loader, you then use the getDefinition() function to grab the library object as it’s own class and then create an instance of the class.

Here’s a very quick and dirry example to give the feel:

var loader:Loader = new Loader();
loader.addEventListener(Event.COMPLETE, _loaded);
loader.load("theswf.swf");

function _loaded(e:Event):void
{
var skinClass:Class = e.target.applicationDomain.getDefinition("ElememtClassExportName") as Class;
var clip:MovieClip = new skinClass() as MovieClip;
this.addChild(clip);
}

Of course, here this example assumes that the element you’re trying to load in the is being exported to ActionScript as “ElementClassExportName” which would never happen (or should never, rather).

This little bit of code though is great because it will allow you to have all of your visual assets in a single SWF file that you can load at the start of your Flex application and not have to worry about managing boat loads of SWF asset files. Hope it can help you as it helped me!

Cloning/Copying Objects in AS3

Tuesday, May 12th, 2009

I was recently working on a game that was controlled mostly by arrays (it was a puzzle game). When a user would fail a level I would have to reset the pieces to be back to how they were at the start of a level.

Setting up a function to reset the level just didn’t make sense. I wasn’t completely sure how I could get this done properly. I tried to create a second value that would remain constant in my code that mirrored the original look of the level’s unfinished puzzle and when the user would fail I would just overwrite the current state of the level with the constant version of that level. Obviously due to referencing in flash this didn’t work.

I learned about a function in Flex known as “copy” in the ObjectUtil class that would clone a data object, just as I was trying to do. Linking the Flex classes into the project didn’t make sense for me, so I needed to recreate the function for AS3. I thought it would be difficult but I was able to get some help and ended up with the following:

function clone(source:Object):* {
var copier:ByteArray = new ByteArray();
copier.writeObject(source);
copier.position = 0;
return(copier.readObject());
}

It worked perfectly. I can now copy objects extremely easy in Flash with this clone function. I hope that it will help anyone out there who may need a solution for a similar problem.