admin

About this author:

Contact:

kormanak@gmail.com

My Articles:

November 3rd, 2009

Numeric sorting of Flex DataGridColumn

Numeric sorting of Flex DataGridColumn

Table of contents for flex-tips

  1. Problem with XML attributes in AS3.0
  2. Unable to export SWC oem
  3. Numeric sorting of Flex DataGridColumn

This is quick example for Numeric sorting of Flex DataGrid columns. If you want to sort column in DataGrid, default sorting is sorted by String and not by Number. If you have just one numeric column, you may create custom sort function and set sortCompareFunction for given DataGridColumn. If you have more such columns and your dataProvider is ArrayCollection, which consists of many objects, better solution is override DataGridColumn and implement compare function inside this class. Here is class

package com.flexets.components.dataGridClasses
{
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.utils.ObjectUtil;
 
	public class NumericDataGridColumn extends DataGridColumn
	{
		public static const NUMERIC:String = "N";
		public function NumericDataGridColumn(columnName:String=null)
		{
			super(columnName);
			initCompare(NUMERIC);
		}
 
		function initCompare(numeric:Object):void
		{
			if (numeric == NUMERIC) {
				sortCompareFunction = numericCompare;
			}
		}
 
		/**
		* Pull the numbers from the objects and call the implementation. TAKEN FROM mx.collections.SortField
		*/
		private function numericCompare(a:Object, b:Object):int
		{
			var fa:Number;
			try
			{
				fa = dataField == null ? Number(a) : Number(a[dataField]);
			}
			catch(error:Error)
			{
			}
 
			var fb:Number;
			try
			{
				fb = dataField == null ? Number(b) : Number(b[dataField]);
			}
			catch(error:Error)
			{
			}
 
			return ObjectUtil.numericCompare(fa, fb);
		}
	}
}

and then just use NumericDataGridColumn in your mxml in DataGrid like this

<mx:DataGrid id="myDG" width="100%" height="100%" dataProvider="{myDataProvider}">
    <mx:columns>
	<mx:DataGridColumn dataField="id"/>
	<dataGridClasses:NumericDataGridColumn dataField="order"/>
	<mx:DataGridColumn dataField="title"/>
	<dataGridClasses:NumericDataGridColumn dataField="price"/>
    </mx:columns>
</mx:DataGrid>

Enjoy this little Flex tip.


read more
Október 29th, 2009

More Google Wave invitations

More Google Wave invitations

I get more Google Wave invitations today and as I have already invited my friends I have now free Google Wave invitations. So if you want to try Google Wave and play with it, but do not know anyone with Google Wave account, ask in comments. I will send 10 invitation for first 10 people which will ask for Google Wave invitation in comments.


read more
Október 27th, 2009

$1000 for WordPress plugin

$1000 for WordPress plugin

If you are WordPress plugin developer you have nice chance to earn $1000. It’s for GetClicky Web Analytics site. It is site similar to Google Analytics, but their data are realtime, so you can really see who is on your site and which content is seen by your visitors currently. It’s very useful web analytics site and I’m using it for tracking my sites. But get back to GetClicky WordPress Plugin.

They need to help with development and they are willing to pay you $1000. Here is quotation form their site:

Our WordPress plugin seems to have serious compatibility issues with 2.7 and beyond. It’s also lacking a couple of features we wish that it had. We find the WP API very difficult to work with and wish to never lay eyes on it again. Therefore, we are offering $1,000 to a qualified WP plugin developer to make the plugin of our dreams.

You need to be very experienced with the WP API, and must have developed at least one major (semi-popular) plugin, or several more minor ones. You also must be the type of person who believes code is a beautiful piece of art, because if there’s one thing that gets my goat, it’s messy code.”

Read more about it: $1000 for WordPress plugin. And if you are not WordPress plugin developer you may be interested in tracking you site with realtime web analytics by GetClicky. It’s completly free for one site and it’s very affordable if you want to track more sites in realtime.


read more
Komentáre sú deaktivované
Október 22nd, 2009

Kseniya Simonova – Sand Animation

Kseniya Simonova – Sand Animation

Off Topic: This is really amazing sand animation by Ksenyia (winner of Ukraine’s Got Talent). She is painting and animating German occupation of Ukraine in WW2.


read more
Komentáre sú deaktivované
Október 19th, 2009

Goodbye FlashDen, hello ActiveDen

Goodbye FlashDen, hello ActiveDen

I’ve found out today, that there is no longer FlashDen.net, but instead there is new site in Envato network called ActiveDen. It’s same site, but Adobe has asked Envato to change the name because “Flash” is registered trademark of Adobe. And there are also Flex files on ActiveDen, so there are no more just pure Flash files, so it’s maybe better name now.

Goodbye FlashDen, hello ActiveDen


read more
Komentáre sú deaktivované
Október 18th, 2009

Major update of Goalscape AIR application

Major update of Goalscape AIR application

This friday we have released major update for Goalscape AIR application. It is project we (me with Tomas as Flexets company) have been working on for more than year. If you are not aware of Goalscape application please look at intro video. But in one sentence it’s Goal Management Software.

Here is list of main features in this update:

  • Search function
  • Adding and naming goals
  • Icons for common functions
  • Language support
  • Notes text
  • Attachments

If you are interested in details go and read about them here: Major update for Goalscape AIR application and download Goalscape (AIR application). You have 1 month free trial and then it’s just 45€ one time payment which include all future updates.

If you have any questions about Goalscape ask in comments, I can answer them in comments. Even if you install Goalscape and want to see there some features, let me know and we will consider to add them to Goalscape.


read more
Október 18th, 2009

Why my sites were not indexed by Google?

Why my sites were not indexed by Google?

Few months ago I’ve created site http://filmcomposers.info about Movie Soundtracks Composers, because I like movie soundtracks and music composing (orchestral) (I really love Hans Zimmer work). But site is still not indexed by google. I was thinking, that’s because almost all content is done by WordPress plugin Pods and there are no posts or pages and just this site is linking to the site http://filmcomposers.info. So I’ve submitted site to Google Webmasters tools, still nothing, I have check if there is no robots.txt file or if inside of that file are search spiders disalloved. I didn’t find anything. Buuut, yes, I’m such a fool :) It’s WordPress privacy setting: I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers or I would like to block search engines, but allow normal visitors. Yes, that’s why google can’t indexed my site :) This option adds meta tag into page header:

<meta name="robots" content="noindex, nofollow">

So if you have same problems and you have site based on WordPress, check in your Admin section Settings > Privacy or check html source code for robots meta tag in header.

After this discovery yesterday I’ve found out that even franto.com has same settings and it’s not indexed by google from time I’ve changed hosting provider few months ago. So I have rather changed all my other sites and they are all ok :) I think I need to create some AIR app for checking such SEO problems…


read more
Komentáre sú deaktivované
Október 14th, 2009

Text Layout Engine: TruncationOptions

Text Layout Engine: TruncationOptions

Table of contents for Text Layout Engine

  1. Text Layout Engine in Flex 3
  2. Text Layout Engine: Fit text into rectangle
  3. Text Layout Engine: TruncationOptions

This is same example as yesterday (Fit text in rectangle with Text Layout Engine), but I’ve added one more switch. You can decide if you want use TruncationOptions or not. Reason why I want to show this to you is that it works differently. I do not know if this is feature or bug, but try to tell me your opinion in comments. When I use TruncationOptions in this way:

var truncationOptions:TruncationOptions = new TruncationOptions('...',3);
factory.truncationOptions = truncationOptions;

all works nice and text is fitted into rectangle. But when I do not include truncation last line of text is out of the rectangle if any pixel line of text line is inside rectangle. Maybe there is some other property which can handle this situation, but I’m not really aware of it. Do you know about such property?

Try it in this example:

id="TextLayoutEngineExamples" width="100%" height="400"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> width="100%" height="400" name="TextLayoutEngineExamples" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">

and here is source code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="fit()"
	backgroundColor="0x333333" color="0xffffff">
 
	<mx:Style source="styles/fonts.css"/>
 
	<mx:RadioButtonGroup id="radioGroup" />
 
	<mx:VBox width="100%" height="100%">
		<mx:HBox>
			<mx:RadioButton id="radioButton1" label="Don't truncate" value="false" group="{radioGroup}"	selected="true" />
			<mx:RadioButton id="radioButton2" label="Truncate" value="true" group="{radioGroup}" />
		</mx:HBox>
		<mx:HBox width="100%">
			<mx:Label text="Text:"/>
			<mx:TextInput id="txtInput" color="0x000000" width="100%" change="fit()" text="Text Layout Engine: Fit Text into Rectangle"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Font Size:"/>
			<mx:HSlider id="fsSlider" liveDragging="true" minimum="6" maximum="50" snapInterval="1" value="14"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Text Width:"/>
			<mx:HSlider id="wSlider" liveDragging="true" minimum="0" maximum="500" snapInterval="1" value="100"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Text Height:"/>
			<mx:HSlider id="hSlider" liveDragging="true" minimum="0" maximum="500" snapInterval="1" value="100"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Fit font to do not truncate text:"/>
			<mx:CheckBox id="chbTruncate" selected="false" change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="isTruncated?"/>
			<mx:Canvas width="20" height="20" backgroundColor="0xff0000" 
				visible="{!isTruncated}" includeInLayout="{!isTruncated}"/>
			<mx:Canvas width="20" height="20" backgroundColor="0x00aa00" 
				visible="{isTruncated}" includeInLayout="{isTruncated}"/>
		</mx:HBox>
		<mx:UIComponent id="ui" width="100%" height="100%">
 
		</mx:UIComponent>
	</mx:VBox>
 
	<mx:Script>
		<![CDATA[
			import assets.TLEAssets;
			import flashx.textLayout.factory.TruncationOptions;
			import flash.text.engine.Kerning;
			import flash.text.engine.FontLookup;
			import flash.text.engine.RenderingMode;
			import flashx.textLayout.formats.TextLayoutFormat;
			import flashx.textLayout.factory.StringTextLineFactory;
 
			private var sprite:Sprite;
 
			[Bindable] public var isTruncated:Boolean;
 
			public function fit(fs:int = -1, cnt:int = -1):void
	        {
	        	if (sprite == null)
	        	{
	        		sprite = new Sprite();
	        		ui.addChild(sprite);
	        	}
	        	while (sprite.numChildren > 0)
	        	{
	        		sprite.removeChildAt(0);
	        	}
	            var factory:StringTextLineFactory = new StringTextLineFactory();
 
	            factory.compositionBounds = new Rectangle( 10, 10, wSlider.value, hSlider.value );
 
	           	if (fs == -1)
	           		fs = fsSlider.value;
 
	            var format:TextLayoutFormat = new TextLayoutFormat();
	            format.fontFamily = "Verdana, _sans";
	            format.fontSize = fs;
	            format.color = 0x000000;
	            format.textAlpha = .9;
	            format.kerning = Kerning.ON;
	            format.renderingMode = RenderingMode.CFF;
				format.fontLookup = FontLookup.EMBEDDED_CFF;
	            factory.spanFormat = format;
 
				if (radioGroup.selectedValue == true)
				{
					var truncationOptions:TruncationOptions = new TruncationOptions('...',3);
					factory.truncationOptions = truncationOptions;
				}				
 
	            factory.text = txtInput.text;
	            factory.createTextLines( useTextLines );
 
	            isTruncated = factory.isTruncated;
 
	            if (chbTruncate.selected && isTruncated && fs > 10 && cnt < 50)
	            {
	            	fs--;
	            	cnt++;
	            	fit(fs, cnt);
	            }
 
	            sprite.graphics.clear();
	            sprite.graphics.beginFill(0x555555,.5);
	            sprite.graphics.drawRect( 10,10, wSlider.value, hSlider.value );
	            sprite.graphics.endFill();
	        }
 
	        private function useTextLines( line:DisplayObject ):void
	        {
	            var displayObject:DisplayObject = sprite.addChild( line );
	        }
 
		]]>
	</mx:Script>
</mx:Application>

Let me know, what you think about it…

P.S. I have other example with use TextFlow component with TextFlowTextLineFactory (graphics included within the text) instead of using StringTextLineFactory. I will post it later today or tommorow. Stay tuned


read more
Október 14th, 2009

blog2

blog2

Hey Visitor. Thank you for visiting my site. I want to say you, that this blog has different URL structure in past years and I have changed it, because it was not nice, that each post on franto.com blog had 2 different URLs. I could just redirect this URL to http://franto.com, but I want to tell you reason, why this URL does not longer exist. If you are looking for something specific on my site and can not find, please let me know in comments and I will get back to you as fast as I can and point you to correct URL. Also if you have anything else you want me say, just write your comment below this post.

Thank you,
Franto


read more
Komentáre sú deaktivované
Október 13th, 2009

Text Layout Engine: Fit text into rectangle

Text Layout Engine: Fit text into rectangle

Table of contents for Text Layout Engine

  1. Text Layout Engine in Flex 3
  2. Text Layout Engine: Fit text into rectangle
  3. Text Layout Engine: TruncationOptions

This is first example in serie of examples of showcase how to use Text Layout Engine (mainly for Flex 3).

Here is quick description: I need to fit text in rectangle (need it for our Goalscape project). I want to be able to change width, height, font size and text of course. In Text Layout Engine this can be done very easily. All you need to do is create correct format for your text, and set compositionBounds for text line factory. I will use StringTextLineFactory class, which provides a simple way to create TextLines from a string. Even I add also TruncationOptions, which specifies options for limiting the number of lines of text created by a text line factory and for indicating when lines have been left out. I’m using TruncationOptions, because I want use maximum of 3 lines and if text is too long I want add … at the end. This is done automatically in Text Layout Engine and I do not need to implement by myself.

Only problem I see, that result .swf file size is over 500kB even builded as Release version (Debug version has 692kB). It’s because of Text Layout Engine and Flex framework are included in .swf. But because I will use it in AIR application, it’s ok for me.

I have created Flash demo for you, but it works just in Flash Player 10, because of Text Layout Engine. Just play with sliders and write your custom text to see effect. In case text will be truncating you will see green square, otherwise there will be red square (not truncated).

id="TextLayoutEngineExamples" width="100%" height="350"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> width="100%" height="350" name="TextLayoutEngineExamples" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">

And this is source code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="fit()">
 
	<mx:Style source="styles/fonts.css"/>
 
	<mx:VBox width="100%" height="100%">
		<mx:HBox width="100%">
			<mx:Label text="Text:"/>
			<mx:TextInput id="txtInput" width="100%" change="fit()" text="Text Layout Engine: Fit Text into Rectangle"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Font Size:"/>
			<mx:HSlider id="fsSlider" liveDragging="true" minimum="6" maximum="50" snapInterval="1" value="14"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Text Width:"/>
			<mx:HSlider id="wSlider" liveDragging="true" minimum="0" maximum="500" snapInterval="1" value="100"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="Text Height:"/>
			<mx:HSlider id="hSlider" liveDragging="true" minimum="0" maximum="500" snapInterval="1" value="100"
				change="fit()"/>
		</mx:HBox>
		<mx:HBox>
			<mx:Label text="isTruncated?"/>
			<mx:Canvas width="20" height="20" backgroundColor="0xff0000" 
				visible="{!isTruncated}" includeInLayout="{!isTruncated}"/>
			<mx:Canvas width="20" height="20" backgroundColor="0x00aa00" 
				visible="{isTruncated}" includeInLayout="{isTruncated}"/>
		</mx:HBox>
		<mx:UIComponent id="ui" width="100%" height="100%">
 
		</mx:UIComponent>
	</mx:VBox>
 
	<mx:Script>
		<![CDATA[
			import flashx.textLayout.factory.TruncationOptions;
			import flash.text.engine.Kerning;
			import flash.text.engine.FontLookup;
			import flash.text.engine.RenderingMode;
			import flashx.textLayout.formats.TextLayoutFormat;
			import flashx.textLayout.factory.StringTextLineFactory;
 
			private var sprite:Sprite;
 
			[Bindable] public var isTruncated:Boolean;
 
			public function fit():void
	        {
	        	if (sprite == null)
	        	{
	        		sprite = new Sprite();
	        		ui.addChild(sprite);
	        	}
	        	while (sprite.numChildren > 0)
	        	{
	        		sprite.removeChildAt(0);
	        	}
	            var factory:StringTextLineFactory = new StringTextLineFactory();
 
	            factory.compositionBounds = new Rectangle( 10, 10, wSlider.value, hSlider.value );
 
	            var format:TextLayoutFormat = new TextLayoutFormat();
	            format.fontFamily = "Verdana, _sans";
	            format.fontSize = fsSlider.value;
	            format.color = 0x000000;
	            format.textAlpha = .9;
	            format.kerning = Kerning.ON;
	            format.renderingMode = RenderingMode.CFF;
				format.fontLookup = FontLookup.EMBEDDED_CFF;
	            factory.spanFormat = format;
 
				var truncationOptions:TruncationOptions = new TruncationOptions('...',3);
				factory.truncationOptions = truncationOptions;				
 
 
 
	            factory.text = txtInput.text;
	            factory.createTextLines( useTextLines );
 
	            isTruncated = factory.isTruncated;
 
	            sprite.graphics.clear();
	            sprite.graphics.beginFill(0x555555,.5);
	            sprite.graphics.drawRect( 10,10, wSlider.value, hSlider.value );
	            sprite.graphics.endFill();
	        }
 
	        private function useTextLines( line:DisplayObject ):void
	        {
	            var displayObject:DisplayObject = sprite.addChild( line );
	        }
 
		]]>
	</mx:Script>
</mx:Application>

read more


Subscribe to my RSS feed to your email:

Images is enhanced with WordPress Lightbox JS by Zeo