Archive for the 'Flex' Category

16
Feb
10

Flex 4/Air Unit and Currency Converter

This is my first foray into using Flex 4, and it takes off from where I was at with my Converter application (as mentioned here, here and here) back in September of 2006 (shizzer time flies!).

I’ve changed the currency conversion to use Google’s Finance site, which means far more accurate conversions are occurring now.

I’d like to make it so you can select multiple currencies and convert to them all at one time. Also with the ability to remember the settings that you’ve used.

If anyone else has got any ideas about features they’d like to see just leave me a comment.

You can view the web version of the converter here www.wrench.com.au/converter

Please upgrade your Flash Player This is the content that would be shown if the user does not have Flash Player 9.0.115 or higher installed.

Or you can install the Air app by clicking on the install badge if you’d prefer to have it on your desktop.

I’m using Flash Builder 4 Beta 2 to create this app. I’ve had to setup 2 projects to export both the web and Air version of the converter. If anyone’s got any tips on doing this from a single project then that would be appreciated. I suppose if it was a more complex piece of code, then there’d be some benefit in splitting the codebase, as it is this just adds a hurdle in the way of a smooth development process.

I’ve also given up on trying to fix the security issues I was having with accessing an external link on a 3rd party server for the currency conversions (as detailed back in the first three posts I made on the converter). I’ve got a php proxy page on my server instead which calls the google site and then returns the results to the swf. This only occurs for the web version though, the Air one connects directly to Google so is about 250ms quicker on each currency conversion.

01
Jun
09

Flash Catalyst or Catastrophe?

I’ve been watching the large number of blog links regarding the news from Adobe labs that Flash Catalyst is now in public Beta; naturally I had to download and have a go myself.

My first impressions are not good.

It seems like they’ve decided to invent their own usability best practices for the tool shortcuts. Where the hell is the pan tool? Why doesn’t holding the space bar and then using the mouse to scroll perform a pan? Keyboard shortcuts for delete don’t seem to work in the layers panel. Where is the align panel? Do I really have to right click an asset and select an align option from a dropdown? It’s a real mouseathon in the program at the moment. These aren’t really things I see as Beta related, they should just be in the app - which they are in any other CS4 product, so I’m mystified how these issues got through QA to this stage.

Probably the biggest issue is the speed (or lack thereof) of the program. Trying to edit a button’s state is painfully slow. I’m not sure whether this is to do with my system (dual core 2.4Ghz with 4Gb RAM on Vista) but I’d like to know if I’m the only one who thinks the program runs painfully slowly.

Aside from the usability and productivity issues I’m still at a loss as to why the CS4 core wasn’t used for this (or was it?) and even why we need a further dilution of the Flash product base. Surely Flash CS could be re badged as Flash Designer and the Catalyst toolset integrated (I realise I made that sound easier than it would be, but as it stands the introduction of this third tool looks like more of a money grab than anything else). This would go nicely alongside the newly re badged Flash Builder (which incidentally looks very good, so kudos to the Flex team).

I haven’t upgraded to CS4 as yet, and it’s for some of the reasons above that I haven’t. I just don’t know where the Flash products are headed, and quite frankly if this is where they’re going I may jump ship completely onto HMS Flex and let the “designers” out there handle getting the assets I’m after into a state in which I can use them. Though the right side of my brain may have something to say about that statement…

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!

15
Dec
08

Flex and my state/binding epiphany!

I’ve been trouble shooting an issue that I was experiencing in Flex for close to 20 hours now. Yup I know, what could possibly take 20 hours to work out!!?

What I’ve been trying to do is set up binding between a textfield in a state of my view, and a private variable set in that same view. I’ll post some code to better illustrate in a minute. The reason I was trying to setup this binding is because of the runtime errors I was receiving when trying to change the textfields text property from within a function of the same component. I was getting plenty of TypeError: Error #1009’s and was aware that trying to set the textfield’s text propery before the state was initialised and the textfield was actually created was what was causing the issues. I just didn’t know how to get around them.

I just now had a look at the properties you can set on a tag within the tag and lo and behold there it was! creationPolicy!!! I’m sure I thought of this at some stage during the process but was tied up trying to get bindings to work the way I thought they should to actually try it (more on this in sec). Setting the creationPolicy to be “All” does the trick for the textfields I know I need to reference.

Here’s the example showing how I fixed my problem. Right click for view source

Now I’ve still got a bone to pick with states and bindings. It seems like binding variables within a components script tags to components (ie. textfields) within state tags is nigh on impossible. That or I don’t understand how to do it.

Here’s a few links that touch on what I’m trying to do:

http://www.mail-archive.com/flexcoders@yahoogroups.com/msg59439.html
http://bugs.adobe.com/jira/browse/SDK-16131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

http://www.mail-archive.com/flexcoders@yahoogroups.com/msg26126.html

It seems like the bindings fire once, but then go dead and nothing entered into the textfields ends up in the getter/setter variables that I’m binding them to. I’ve tried using custome events (ie [Bindable(event="myEventChanged")]) with no luck, the mx:Bindings tag, change events in the textfields themselves (but then that defeates the purpose of using bindings right?). You name it I think I’ve used it, so I guess I just don’t understand how to bind to things properly in state based components.

Does anyone have any good information and or an example of how to get this working?

(I think I may have just stumbled across the reason why my initial efforts weren’t working. Pretty sure it’s to do with the Mate framework and the way it’s scoping method calls in my view. Will post some more info when I have it)

UPDATE: Ok I’ve looked at the Mate stuff and I ended up doing things in a slightly different way. Not sure if it was user error or I’ve got a legitimate qualm, no doubt the boffins at mate.asfusion.com will put me on the straight and narrow.

15
Dec
08

Flex Builder trace() issues

I’m having a few issues with Flex Builder and Sephiroth’s FlashTracer Firefox extension at the moment. The first issue is that the Design view in Flex actually traces things like:

-> Begin call to AS: getGlobalPoint(Canvas1,-1,-1)
<- End call to AS: getGlobalPoint, Result = 494,409
-> Begin call to AS: showConstraints(false)
<- End call to AS: showConstraints, Result = null
-> Begin call to AS: getGlobalPoint(Canvas1,-1,-1)

Which can clutter up the FlashTracer console. Not only that, it also causes the FlashTracer to choke on the number of lines it is displaying which in turn causes Firefox to crash. Not an ideal way to debug an application.

I set out to remedy my problem this morning. And I managed to stumble across a Java version offering the same functionality as FlashTracer. Flash Tracer (imaginatively named ;-) can be found at it’s Google Code home. As I’m running the Firefox extension in it’s own window, this fits well with my work flow at the moment. So the fact that it’s not integrated into Firefox doesn’t matter for me so much.

Does anyone have any tips for getting Flex Builder to stop its incessant chitter chatter of trace outputs?

Still related to the flashlog.txt file, I’m completely baffled as to why running an Air application locks the log file and stops any other process from writing to it. So when debugging, be sure to close down all your Air apps. Very handy, certainly aids with my workflow when I’m trying to create things in Flash. Thanks Adobe. And I’ve logged a wishlist request and asked a few questions using the usual channels so will hopefully receive a good reason for the file being locked (I’m assuming it’s not just for kicks).

I just realised that the latest version of the Firefox plugin is only 2.2.0 yet on Sephiroth’s page there’s a 2.3.1 version. I’ll install that and see if it resolves the crashing issues).

UPDATE: I just came across SOS Max via Wezside’s blog Ahhh, you’ve gotta love Google! The SOS Max debugger looks very good and I think it probably trumps both FlashTracer and Flash Tracer.

13
Dec
08

Google Maps geo-location by IP Flex example

Following on from my earlier post regarding Google Maps and Flex, I’ve put together a new example which I reckon’s pretty nifty.

Somehow my idea was spawned by Andrew Shorten’s post which discussed using Google Maps and the new Adobe Cocomo service to create a collaborative mapping application. And I say somehow, as I’m not really sure how I went off on the tangent of geo-locating IP addresses when the original post was about two users drawing stuff on a shared map! Maybe they can see where each other is on the map and start drawing a line until they meet somewhere in the middle…

Anyway, (il)logic aside here’s the example I whipped up:

View source is enabled in the following example.

The “Geo-locate IP address” text field should auto populate with your current IP address. The initial map will load and center on London.

When coding up the infowindow that displays, I found this reference on the Google site very useful - http://code.google.com/apis/maps/documentation/flash/reference.html

The actual information is coming from a whopping great big file that I’ve uploaded to my server which was supplied by Maxmind. There’s a few other databases that they supply, so I might add some more features to this example down the track. And they have pay for use and free versions of all their data, which is great!

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!)

20
Nov
08

Flex Builder is having an identity crisis

Not one to start rumours, but this comment from Lee Brimolow over at Keith Peters blog seems to suggest (or my reading between the lines is shocking) that there will be a revised naming strategy for the upcoming release of Flex Builder (currently code named Gumbo).

Anyone want to have a stab at what it could be?

We have Flash CS4 and Flash Catalyst - what’s going to be the third arm of the axis of fevil?

If it was to change, there’s going to be a lot of rebranding to do that’s for sure!

(obviously Lee’s comments are completely unsubstantiated at this time - though the post he commented on did have a few contributions regarding the inconsistency of the Flex name and how it relates to the Flash Universe Platform.)

Edit: Looks like Ryan Stewart has poo poo’d the idea of any Flex name changes.

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 ;-)

30
Oct
08

Flex 3 and Form container layout issues

Kinda taking off from where I was at in this old post of mine, I’m now having some issues with how Flex does it’s calculations for the vertical scrollbar. Specifically when using a TabNavigator component that has Form components as it’s children. Here’s some of the code:

<mx:TabNavigator id="tabbar" right="340" left="10" top="95" bottom="10">
	<mx:Form indicatorGap="5" verticalGap="10" label="1. Personal Details">
		<mx:FormItem label="First Name:">
			<mx:TextInput id="firstName" />
		<mx:FormItem>
		.
		.
		.
		<mx:FormItem label="Phone Number:">
			<mx:TextInput id="phoneNumber" />
		<mx:FormItem>
	</mx:Form>
</mx:TabNavigator>

The problem is no matter what I tell the TabNavigator to be height wise (either with a height percentage or a constraint based amount) the Form when it has too much content in it will create an application wide vertical scrollbar. I’m trying to make it so that the scrollbar is relative to the actual TabNavigator, so it appears alongside that content. I’ve read through the Adobe documentation about containers and layouts but that didn’t really shed any light on the subject (or my issue at least).

Placing the Form inside a Canvas tag solves the issue, but I’d like to think I can get the Form working as I think it should be.

Has anyone got any pearls of wisdom regarding the issue I’m experiencing?




Categories

Recent Comments

Posts this month

March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  

Archives