Archive

Archive for July, 2008

Setting a default “selectedIndex” on an mx Control

July 30, 2008 6 comments

This is the scenario I was faced with just the other day :
Afrigator
User is presented with your stock standard image gallery, only this time I had to write it all in Flex / AS3. Simple enough really, until I got stuck on a rather silly issue. It took me quite some time to find the solution and even then, I’m not quite satisfied with it – especially seeing as I’m making use of the Mate framework in this instance.

Ok, so on your right is a TileList of thumbnails. When the user clicks on a thumbnail, the larger version of the image is promptly displayed in a VBox on the left. Pretty straightforward stuff.

Now – when the app first loads, what I needed to do was display the first thumbnail’s “larger version” in the VBox by default – otherwise it looks empty and a little unprofessional. Still easy – all we need to do is execute a function when the TileList’s “onCreationComplete” event fires. All this function needs to do is set the TileList dataProvider’s selectedIndex to 0 ( as it’s blank by default ).

But what happens when the user performs a search ( chooses another category/album ) and the dataProvider’s content is replaced with a new ArrayCollection ?  The selectedIndex gets reset to null of course and your “larger image” disappears. 

This is where I got stuck – and I tried all sorts of things after finding out that the “dataChange” event doesn’t work. The problem wasn’t finding out when the ArrayCollection was replaced – the problem was setting the TileList dataProvider’s selectedIndex from within an “outside” class. I still don’t know how to do so unfortunately – so if you’re reading this and know of a better way to solve this problem, please feel free to leave a comment – and just write my stupidity off to “Flex Noobness”.

In the end I found that the “updateCompleted” event for the TileList fires when the dataProvider’s contents gets replaced. So what I ended up with is the following code, which I hope will help someone else in a similar predicament.

<mx:VBox
	xmlns:mx="http://www.adobe.com/2006/mxml	xmlns:model="com.gallery.model.*	xmlns:viewUtils="com.asfusion.mate.viewUtils.*" xmlns:controls="qs.controls.*">

	<mx:Script>

		<![CDATA[

			import com.gallery.events.*;
			import mx.collections.ArrayCollection;

			public function setItemDefault() : void{
				if (!list.selectedItem && model.currentSet != null && model.currentSet.length > 0){
					list.selectedIndex = 0;
				}
			}

		]]>

	</mx:Script>

	<model:PhotoViewerModel id="model" />

	<mx:TileList id="list"
		direction="horizontal"
		dataProvider="{model.currentSet}"
		itemRenderer="com.gallery.ui.renderers.Thumbnail		width="100%" height="100%" updateComplete="{setItemDefault()}"/>
</mx:VBox>

Flex Resources

July 25, 2008 Leave a comment

This has been done before by others, but I’ve decided that if anything ever happened to my beloved MacBook and I lost my hard won list of resource links…..I’d be somewhat miffed.

I’ve tried to break the list up into different categories to make it easier to flip through, so here goes :

I’ll be adding to this list as I find more useful resources, but for now it’s a good place to start. So far I’ve found the flexcoders usergroup extremely helpful – the users there are always willing to help out and I certainly suggest signing up if you haven’t already done so.

Categories: Flex Tags: , , , ,

Mod Contentnav

July 24, 2008 Leave a comment

I wrote this module (mod_contentnav) for Mambo 4.5.3 back in 2004 and thought that maybe I should post it up here. Who knows, someone out there may find it useful… I certainly did back in the day 🙂

I also found an old forum post which may help you if you’re struggling with using the module.
You can find it here : Mamboserver forum.

Categories: PHP Tags: , , ,

Looking for work

July 24, 2008 1 comment

Ok so, long story short, the funding for a startup I’ve been working for has fallen through. 6 months of work down the drain.

Needless to say I’m disappointed, sorely so, but not just for myself. The guys I was working with are a really generous, friendly and supportive bunch, and I’m bummed for them as well. We all put alot of time, money and effort into this project and it really sucks. But, such is life and we all knew the risks going in.

For me, there is no such thing as failure, only feedback. That’s my motto and I’m sticking to it.

What all of this really means is that I’m now looking for either another job or some freelance projects. So if you’re looking for a freelance developer, check out my “About” page and drop me a line if interested.

On an interesting note – if you’re ever in a similar position I definitely suggest that you take a look at the Sitepoint Marketplace.  Conversly, if you’re looking to hire freelance developers, designers etc they have a section for that too.

Another good site to check out, especially if you’re a designer or looking for a designer, is 99designs. Pity I’m not one of those really creative types.

Categories: General Tags: , , ,

Taking the plunge

July 24, 2008 Leave a comment

Well, I’ve finally decided to get my act together and start a blog. My goal here is to post something interesting at least once a week so we’ll see how that goes.

My hope is that I can contribute something useful to the development world. I’ve lost count of how often I’ve been stuck with a certain problem, only to find a relevant solution on some wonderful soul’s blog – if I could kiss these people, I probably would (well…..not really).

Unfortunately for those of you reading this blog, I’m not much of a word maestro, so just bear with me.

If you’ve made it this far… thanks but… don’t you have something better to do ?

Categories: General