Archive for December, 2008

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

05
Dec
08

Come together, right now… over Groups

I’m a bit late on this one I know (had it in my todo’s to blog about it back when Max US was on) but Adobe have created a very cool Groups website to promote and manage the hundreds of different user groups around the world that deal with Adobe technology.

Here’s my beloved South Oz group (G’day Steven ;-)

The number of groups in London is still a bit thin on the ground, or am I not searching for the right keywords…?

And I love the welcome message, should just about cover everyone I reckon!

Will be interesting to see what comes of the community over the next few months and just how useful the site will be for networking purposes. Hopefully everyone that attends User Group meetings will be encouraged to go onto the Groups site and register as a member of their group (and any other ones they might be interested in). As a bit of a working nomad at the moment that should make it easier to network with your next port of call before even arriving there.




Categories

Recent Comments

Posts this month

December 2008
M T W T F S S
« Nov   Jan »
1234567
891011121314
15161718192021
22232425262728
293031  

Archives