Archive for the 'flex' Category

Continuous scrolling image thumbnail and slideshow component for Flex.

[kml_flashembed movie="http://joelhooks.com/examples/slideShow/VESlideShow.swf" height="530" width="500" /]

I've been working on improvements for this thumbnail/slideshow component. The way the continuous scroll flows is very nice. It provides a very fluid feel. I have it reading XML from SlideShowPro director. SSPD simply gives a structure of albums and images, so the component should work from essentially any XML source as long as it follows the same schema:

<gallery>
     <album id="0" description="DESCRIPTION" title="TITLE" tn="PATH" lgpath="PATH" tnpath="PATH">
          <img src="FILENAME" />
          ...
     </album>
</gallery>

There is still a good bit of work to do. Right now the slideshow is coupled with the thumbnail container. I think that should be seperated, because I can see various uses for thumbnails outside of a slideshow. It needs style and event metadata so that it will function as a proper Flex component. I am also going to roll it into mediated PureMVC components for inclusion in VE:Session.

The source is here.

Continuous scrolling image thumbnail component for Flex.

Here is the beginnings of a full featured open-source continuous scroll thumbnail component for Flex. It is rough right now, but I plan to polish it and make it something useful. This format is really appealing, as it gives the user a seamless view of a gallery, without any jumps or aggravating scroll bars. Up until now I have been using H and V Lists in flex for my thumbnailing, but they are ugly and don't provide as rich of an experience.

The Scroll Panel from AFComponents was my first choice. It is a very nice component, well priced, and would be just what I need, if not for the fact that my project is open-source and using a commercial component sorta kills the whole thing. After scouring the internet I finally stumbled upon the work Peter Wright has put in on a perpetual scrolling list.

I've modified it to accept an XML list of image objects, as well as perform horizontally. It is also functioning as a slideshow, and I want to allow it to go either H or V depending on the need. It should shape up to be a nice reusable component. Much thanks to Peter for supplying the code to get me started.

[kml_flashembed movie="http://joelhooks.com/examples/slideScroll/ImageScroll.swf" height="165" width="490" /]

Source Enabled

Using the Senocular AS3 TransformTool in Flex

Hey,I am so interested about that you had ever used the ‘TransformTool’ library in your Flex project. But there is little examples showing how to use it in flex, Would you please share some example about how to use ‘TransformTool’ in Flex? I have tried as such a way:

but it failed at line
canvas.addChild(defaultTool);
Can you give any hints? Thanks.

Like most pure AS3 display classes, the TransformTool needs to be added to a UIComponent wrapper to function properly in Flex.

[kml_flashembed movie="http://joelhooks.com/examples/transformTool/TransformToolFlexExample.swf" height="500" width="490" /]

Source.

Flex component transformation with ObjectHandles

Rogue Development's ObjectHandles is a great component. It is simple to use and provides all of the functionality that I was looking for in a transformation modifier. Prior to implementing this, I was using the TransformTool from senocular.com's library. This is also a great utility, but it wants to scale my content, and that was a deal breaker in my current project. ObjectHandles does NOT resize the child components. There are use cases for both approaches, but ObjectHandles allows me to decide when to scale.

[kml_flashembed movie="/ObjectHandles.swf" height="300" width="490" /]

<?xml version="1.0" encoding="utf-8"?>
<ObjectHandles
	xmlns="com.roguedevelopment.objecthandles.*"
	xmlns:mx="http://www.adobe.com/2006/mxml"
	allowRotate="false"
	objectMovedEvent="objectUpdatedHandler( event )"
	width="{image.width}"
	height="{image.height}" >
<mx:Script>
	<![CDATA[
		import com.roguedevelopment.objecthandles.ObjectHandlesMouseCursors;
		public static const CHANGE:String = "imageBoxChanged";
 
		private function objectUpdatedHandler( event:Event ):void
		{
			dispatchEvent( new Event( CHANGE, true ) );
		}
	]]>
</mx:Script>
	<mx:Image id="image" source="@Embed(source='/assets/cower.png')" />
</ObjectHandles>

Accessing a List from its itemRenderer

This was really throwing me off tonight. I could not figure out how to get at the List from its itemRenderer. this.parent... no this.owner... no

So I started The Search™, trying to hunt down The Answer™. This is one of those things that doesn't just jump out of the manual at you. Luckily, Peter Ent is running an extremely informative series on itemRenders. He says to get at the List, we need to simply access the listData property. But there's a catch:

Most controls such as Text, Label, Button, CheckBox, and so forth, implement IDropInListItemRenderer. Most containers, such as HBox, Canvas, etc. do not implement that interface. If you want to use listData in an itemRenderer that extends a Container you will have to implement IDropInListItemRenderer yourself - I'll cover that in the next article.

Luckily for us, it is a simple process:

<mx:hbox xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.controls.listClasses.IDropInListItemRenderer"></mx:hbox>

We will need to implement the appropriate methods in the itemRenderer's Script tag also:

import mx.controls.listClasses.BaseListData;
 
private var _listData:BaseListData;
private var list:List;
 
public function get listData() : BaseListData
{
	return _listData;
}
public function set listData( value:BaseListData ) : void
{
	_listData = value;
	list = listData.owner as List
	list.addEventListener( ListEvent.CHANGE, onListChange, false, 0, true )
}

In my case, I wanted to listen for changes so that I could set one of the itemRenderer sub-component's properties whenever the list had changed. Now to access the List:

if ( list.selectedItem == data ) doSomeStuff();

Easy as that.