Tag Archive for 'as3'

09
Feb
10

My babies alive!

http://www.wrench.com.au/

Initially built using AS2 but never launched in 2006 (due to time constraints i.e. doing real work), the domain that was supposed to showcase my wares remained as a coming soon page for nigh on 4 years. Finally the bullet was bitten in the latter part of 2009 and the decision to port the entire site to AS3 and utilise the Gaia framework was made. Within 4 weeks, a fully functional, SEO compliant, user accessible site was finished and launched. Kudos to Steven for the framework, rock on Gaia!

Feel free to leave any comments you’ve got about the site; be they good, bad or otherwise…

Wrench screen grab

15
Jan
09

as3 casting issue

Either I’m going slightly mad or casting using the “as” keyword works differently to the old way of casting.

Here’s some code to illustrate:

showFormItem = (((e.target as CheckBox).selected as String) == _local.displayTriggerValue[i]) ? true : false
Now this gives a different result to:
showFormItem = (String((e.target as CheckBox).selected) == _local.displayTriggerValue[i]) ? true : false

WTF?!

I’m pretty sure I’ve got my brackets in the correct spot.

Yhelp!

09
Jan
09

Passing parameters to a Flex eventListener - use a Dictionary!

Firstly, Happy New Year! Hope your ‘09 is off to a flyer!

Secondly, sorry about the rather mundane heading - couldn’t really think of what to call this post. I’ve been typing all sorts of things into Google trying to find a solution to what I’ll describe below.

I’m continuing the project I started in early December and having some very interesting battles with AS3 and the Flex framework. I’d like to document one of those battles today.

What I wanted to do was send parameters along with an event so that the event listener had access to them. Now I’m fully aware of how to do that when I’m in charge of dispatching the event, but was (and still am) at a loss as to how to add them in the following instance:

myComboBox.addEventListener(Event.CHANGE, eventListener);

This call to addEventListener occurs where the variables I want to pass get defined.

Here’s the code that I attempted to use (without luck) to get the parameters passed along with the event:

myComboBox.addEventListener(PodEvent.CHANGE, eventListener);
var myEvent:PodEvent = new PodEvent(PodEvent.CHANGE);
myEvent.displayTriggerValue = displayTriggerValue;
myEvent.formItem = triggerDisplay;
myComboBox.dispatchEvent(myEvent);

I could get the displayTriggerListener to run when the combobox changed, but the variables that I added to myEvent wouldn’t make it in there (further to that I was having type coercion difficulties, but that’s another story I think). The initial dispatchEvent was also allowing the eventListener to get the parameters, but obviously the idea is to have them passed along with every PodEvent.CHANGE event.

Now initially I got around this using closures (a new term to me). I understand the issues of using anonymous functions (ie. garbage collection issues) so searched some more for answers. I found nada.

So after a nights rest and a few more hours wrestling with it today, I’ve come up with the following solution that I’m rather chuffed about. I use a Dictionary to store a reference to the component and in turn create an object associated with that Dictionary element to store the parameters I want to pass into the eventListener function. Perhaps some code will illustrate what the hell I just typed (for me and you both ;-)

myParamDictionary[myComboBox] = {param1: value1, param2: value2};

The myParamDictionary is a private var in the class so is accessible within the eventListener

private function eventListener(e:Event):void {
	var _local:* = myParamDictionary[e.target]
	// rest of the implementation here. You can access the previously set parameters by _local.param1, _local.param2...
}

And to my utter delight (and surprise) it works!

The only downside is there’s no type checking on the parameters, which is what I originally wanted to use a custom event for.

If you’ve got a suggestion for my initial problem or a critique for my end solution please don’t be shy and post them!

08
Dec
08

M-V-SEE

MVC is on my mind at the moment. I’ve read more about this and other design patterns and frameworks in the last few weeks than I care to recount (though I do hope it’s starting to sink in).

This is all in preparation for the biggest project I’ve ever tackled.

Now unlike other projects, I’ve stopped myself from just delving in and getting amongst the code.

I’m not sure I like this new approach though. It’s making me feel very stressed after not really having made a “proper” (read: there’s not much code sitting in classes) start on something I thought was going to be a lot easier than it’s turning out to be.

However, during my research (and after a few hands in head moments) I came across a great article that talks about MVC - Removing The Model-View-Controller Straitjacket In particular it discusses the difficulty in defining something which can mean many things to many people in many situations. Malcolm Tredinnick suggests to, “stop saying ‘thing X is (or is not) MVC’. You’re almost certainly fudging at the edges and certainly not making things any clearer.”

He also links to an original document from 1979 that sets out what MVC is. It’s pretty cool to think that the geeks back then were solving the same thing the geeks of today are.

In his summary he also offers some sage advice - “Solve problems and understand solutions in context. Don’t pigeon-hole.” I find that the problem with that advice is until you’ve tried to fit the pidgeons into their holes a few times (which seasoned OOP advocates have), it’s kinda nice to think (possibly foolishly) that they might just fit.

This is pretty much where I’m at at the moment - trying to squeeze whopping great big birds into comparably small holes. Fortunately I’ve got a big rubber MVC-Mallet to bang them in with! And some reassuring words that you shouldn’t feel too worried if things can’t be categorised exactly.

I’ll post more about what I’m doing in the coming weeks, but wanted to mention that I’m using the Mate framework (pronounced Mah-teh). It seems to offer some pretty cool features and some great help and examples on the website. There’s a few caveats with using it though. One of which (and this seems to be a bit of a recurring theme with these types of frameworks) is that certain parts of the application aren’t eligible for compile time type checking. I stumbled upon this today, and was quick to realise where the problem lay - but I’m only a few 100 lines of code in at the moment. I’ll post back when I’ve hit 10,000 lines of code and let you know if I’m still mate’s with Mate.

(I also just found this great article on similar subject matter over at as3dp.com - No Time for OOP and Design Patterns. Check it out, it’s a ripper!)

14
Nov
08

Google Maps meet AS3, AS3 meet Google Maps

A few years back I worked on a project that used the Google Maps API and at the time I was charged with recommending to the client whether to use Flash or Javascript/HTML to get the job done. At the time there was no readily accessible Flash API for Google maps, and I wasn’t that keen to go with the Yahoo or Microsoft offerings (though Yahoo now has a very robust Flash API, the Microsoft (surprise surprise) one doesn’t… though I found this Silverlight version). FYI the Kaurna Place Names site was developed to identify and map places with Kaurna (Aboriginal) names and to encourage the use and increase knowledge of these names. It begins with names in southern Kaurna country (which is the region of Australia where I’m from).

So there’s the back story. I recently came across a post which talked about the Google Maps API now being available for Flash AS3. With my current push to learn about Flex I was also pleased to see that there were components available that you could just drop into your MXML and whamo, insta-map!

Here’s what I pieced together, hopefully it illustrates what can be done with a few Flex components and the Maps code provided from the Google Maps developer site.

View source is enabled in the following example.

Obviously it’s not a scratch on Paul Neave’s venerable Flash Earth, but then this example only took 15 minutes to knock together ;-)

22
Jul
08

Gaia Flash Framework - My Experience

I’ve been a bit busy over the last few months. Here’s what I’ve been up to…

I’ve moved to the UK
I’ve travelled home again for a family reunion
I’ve read a good portion of Moock’s Essential ActionScript 3.0
I’ve drunk more Guinness than I care to (or can) remember in Ireland
I’ve sold a car
I’ve worked on my first AS3 site
I’ve used the Gaia Flash Framework

The last point is obviously what I’d like to delve in to a bit more.

For those of you that aren’t aware (like myself about 3 months ago) what the Gaia Flash Framework is, you can find out more at Steven Sacks comprehensive website - http://www.gaiaflashframework.com. I only stumbled upon the Framework as a result of someone else (can’t remember who it was now, but thanks!) posting about it on their blog.

In essence it’s a Framework that takes a lot of the leg work out of creating page based Flash sites. By Page based I mean sites that have a fairly standard navigation hierarchy. It can be used for more complex projects, though I found I struggled against the Framework more than it helped me some of the time.

The project I decided to use it on was for the SBS Australia Documentary website - mY Generation

The main issues I came up against in using the Framework for this site were the following:

  • I couldn’t have two pages loaded on the screen from separate branches at the same time. So If I wanted a video from one section to remain visible on screen while the user navigated to the “TELL A FRIEND” section I couldn’t do this due to the way pages have to unload if there not part of the parent page node
  • Using the transition engine, although powerful, quickly became very convoluted and confusing when testing the preloading of pages and assets. Though I suspect I found this as the Framework wasn’t quite suited to this type of project
  • The file size of the entire project was larger than I would’ve preferred as each page had to have it’s own swf associated with it. This meant not easily being able to share assets like fonts amongst pages. This was partially addressed in later versions of the Framework, so I will have to see if I can utilise this functionality next time around.
  • Later on in the project new releases of the Framework became available that significantly changed the implementation of some of the Frameworks features. This made it very difficult for me to upgrade and get the benefit of the bug fixes that were made

On the up side, it’s author Steven Sacks mustn’t spend a great deal of time sleeping as he seems to hold down a full time job whilst at the same time rapidly releasing new versions of the Framework and responding with very lengthy and informative posts on the forum. The documentation is also very good, though there were a few things missing which threw me for a loop (though most users probably wouldn’t have experienced the same issues as I was pushing the boundary’s of what the Framework was capable of). The documentation also gets updated very frequently with issues that users are experiencing in the forums.

I didn’t get to use the SEO capabilities of the Framework, but am finishing up my “new” (it’s been 2 years in the making) website now and am contemplating porting it all across to Gaia just for this 1 feature.

So check out the Framework, check out the SBS site, and let us know if you’ve had any experience with Gaia.




Categories

Recent Comments

Posts this month

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  

Archives