LinkBar tied to component states

August 16, 2006

I just did a quick extension of the LinkBar so you can tie it to the states of a component. I haven't tested it throughly yet, so if you find anything weird in there, let me know...

usage:


<components:StateLinkBar dataProvider="{states}"/>

you can download the code here, or just cut and paste from below:


package view.components
{
import flash.display.DisplayObject;
import flash.events.MouseEvent;

import mx.controls.LinkBar;
import mx.core.UIComponent;
import mx.events.StateChangeEvent;

public class StateLinkBar extends LinkBar
{
private var measurementHasBeenCalled:Boolean = false;
private var __pendingStates:Array;
private var __states:Array;

public function StateLinkBar()
{
super();
labelField = "name";
}
override public function set dataProvider(value:Object):void{
super.dataProvider = value;
if(value==parentDocument.states){
setStateListeners(value as Array);
}
}
override protected function commitProperties():void{
super.commitProperties();
if(!measurementHasBeenCalled && __pendingStates){
measurementHasBeenCalled = true
setStateListeners(__pendingStates);
}
}
override protected function clickHandler(event:MouseEvent):void{
if(__states){
var index:int = getChildIndex(DisplayObject(event.currentTarget));
var uic:UIComponent = parentDocument as UIComponent;
uic.currentState = __states[index].name;
hiliteSelectedNavItem(index);
}
super.clickHandler(event);
}
private function setStateListeners(arr:Array):void{
if(!measurementHasBeenCalled){
__pendingStates = arr;
invalidateProperties();
return;
}
var p:UIComponent = parentDocument as UIComponent;
if(p !=null){
__states = arr;
//setup listeners
p.addEventListener(StateChangeEvent.CURRENT_STATE_CHANGE,onParentStateChange);
}
}
private function onParentStateChange(event:StateChangeEvent):void{
var newState:String = event.newState;
if(__states){
var max:Number = __states.length;
for (var i:Number=0;i if(__states[i].name==newState){
selectedIndex = i
hiliteSelectedNavItem(i);
}
}
}
}

}
}

How I built those firefox plugins to google search a site

August 10, 2006

Ok, so Mathias just asked how I managed to get the plugins to just search one site. I started to write a comment explaining it, but got a little long, so here's Paul's quick n dirty ghetto way of getting a firefox plugin to search just one site...

So basically, I got started by looking at the mycroft quickstart guide to building your first search plugin. That helped me to understand the basics of what I wanted to do, but really all I needed was a google search restricted to one site, just like typing site:livedocs.macromedia.com/flex/2 [myterm] into google.

The search plugin format is pretty simple. Basically, you tell it what url to use, and then you can append querystring values on to the end of it using the following syntax:

<input name="parameterName" value="parameterValue/>

Then for the user input, you simple use the value 'user' instead of writing value='blah'. So, if you take a look at the google search plugin source (should be found somewhere like 'C:\Program Files\Mozilla Firefox\searchplugins\google.src') you will see a node that looks like this:

<input name="q" user>

So, what I actually wanted to do is append 'site:livedocs.macromedia.com/flex/2' to my 'q' querystring value that the user enters. After a bit of digging, I found that you can repeat input nodes of the same 'name' and firefox simply joins these values together. so, in order to search just in the livedocs site, my input nodes looked like this:

<input name="q" value="site:livedocs.macromedia.com/flex/2 "/>
<input name="q" user>

You should be able to find my flex plugin source files in a location similar to this: C:\Documents and Settings\[USERNAME]\Application Data\Mozilla\Firefox\Profiles\ytb1w5n7.default\searchplugins. If you can't be arsed to go digging, you can download them here and here

Finding Flex Facts Faster

August 09, 2006

so today, firefox decided to die a death on me. I choked it doing some Flex debugging and as a result I lost the functionality in my search bar. This got me thinking about what would really be useful for me is a way to search the places I usually go for flex info - the livedocs and the flexcoders mailing list. What I've ended up with is a quick way to search both these resources at the same time...

So, the first thing I did was to create a couple of specialised search bar engines using google. My first thought was to try and get google to search two site: locations in the same query, but it just wont let you... as it turned out, the solution I came up with I think is more usable.

The first thing you will want to do is install the search plugins. You can get the flexcoders one here, and the livedocs one here. When you have installed them, restart firefox and your search engines should now appear in the searchbar at the top right of your window

The next thing I wanted to do is combine the functionality of these two together. After a few minutes digging, I found that the advanced search sidebar plugin for firefox does exactly what I need it to do. If you dont have it, you can get it here. When you have the search sidebar installed, open it up and in the 'within' dropdown, select 'Edit Categories...' Under the category dropdown, click New... create a category called 'Flex' and add the two flex search engines.

Hey presto, you can now search across livedocs and flexcoders in one action...

« July 2006 | Main | June 2007 »

Syndicate

Add to Technorati Favorites Powered by
Movable Type 3.2

Holiday Fund