BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Archive for September, 2009

Spelling checking feature in flex by Using ‘squiggly.

Posted by Shardul Singh Bartwal on September 23, 2009

Spelling checking feature in flex by Using ‘squiggly.

Today I explore the spell checking feature in flex using ‘squiggly’.Now we can easily get the spell checking feature in our Application which are more concerned about Text Entries. Its really really nice. Its an spelling checking engine for flash Player and Adobe AIR.

Please explore the link below for details about ‘squiggly’.
http://labs.adobe.com/technologies/squiggly/

You can download ‘squiggly’ from here.
http://labs.adobe.com/downloads/squiggly.html

You can easily use it in your flex application. And live demo is here at adobe’s site.
http://labs.adobe.com/technologies/squiggly/demo/

Enjoy Flexing………….

Shardul Singh Bartwal

Posted in Uncategorized | Leave a Comment »

Play and Stop Swf in Flex

Posted by Shardul Singh Bartwal on September 21, 2009

Play and Stop Swf in Flex
Many of times I have seen people to looking for requirement when they want to stop and play the swf out side the swf. This becomes more important when you  want  to  play or stop the swf’s which are not created by you.Below is the code  for  the  same  requirement.  In  this  demo  Application ,  I   am  using a Loader for playing the swf. Hope it will be helpful for you if you require.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute" creationComplete="OnCreationComplete()">
<mx:Script>
<![CDATA[
		import mx.core.UIComponent;
		private var loader:Loader; 
		
		private function OnCreationComplete():void
		{
			var url : String ="assets/MyanimatedSwf.swf";
			loader = new Loader();
			var request:URLRequest = new URLRequest(url);
			loader.load(request);
			loaderHolder.rawChildren.addChild(loader as DisplayObject);
		}

		private function onStop():void
		{
		var mc : MovieClip = loader.content as MovieClip;
		mc.stop();
		}
		
		private function onPlay():void
		{
		var mc : MovieClip = loader.content as MovieClip;
		mc.play();
		}
]]>
</mx:Script>
<mx:VBox width="100%" height="100%" horizontalAlign="center"
	verticalAlign="middle">
		<mx:Canvas id="loaderHolder" width="500" height="500"/>
		<mx:Button label="Stop" click="onStop()"/>
		<mx:Button label="Play" click="onPlay()"/>
</mx:VBox>
</mx:Application>

Enjoy Flexing………….

Posted in Uncategorized | 4 Comments »

Using Image Inside the Sprite in Flex

Posted by Shardul Singh Bartwal on September 18, 2009

Using Image Inside the Sprite in Flex

If we want to add any Image inside the Sprite class in flex,then It is not possible to add image inside the sprite. But if your requirement is as such in that case you can achieve this by adding the Loader inside the sprite. Below is the code for the same.

MainApplication.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute" creationComplete="createSpriteWithBitmap()">
	<mx:Script>
	<![CDATA[
	import mx.controls.Image;
	private function createSpriteWithBitmap():void
	{
	var sp : SpriteWithBitmap = new SpriteWithBitmap();
	can.rawChildren.addChild( sp );
	}
	]]>
	</mx:Script>
	<mx:Canvas id="can" x="200" y="200"/>
</mx:Application>

SpriteWithBitmap

package 
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;

import mx.controls.Alert;

public class SpriteWithBitmap extends Sprite
{
	//Pass the source path or url here. 
	private var url:String = "https://shardulbartwal.files.wordpress.com/2009/09/ssbrose.jpg";

	public function SpriteWithBitmap() 
	{
		loadImg();
	}
	private function loadImg():void 
	{
		var loader:Loader = new Loader();
		loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadFailure);
		var request:URLRequest = new URLRequest(url);
		loader.load(request);
		this.addChild(loader);
	}

	private function loadFailure(event:IOErrorEvent):void
	{
		Alert.show("Can't load :" + url);
	}
}

}

Enjoy Flexing………….

Posted in ActionScript 3.0, Flex, Flex 3.0 | Tagged: , , , | 4 Comments »

Zoom Any container with children In Flex 3.0

Posted by Shardul Singh Bartwal on September 15, 2009

Zooming in Flex

I saw many people searching for the finding solution for zooming functionality. They are normally trying it with the zoom effect or scaling which is very true. But the case is bit sensitive when you have to zoom all the components inside a component and so on. So surly this will be achieved through a recursive function which will zoom each and every control inside a container unto the nth level where a container will not have any more child. Below is the demo application for achieving this. Hope this will be useful for all those who are having such requirement.

For code click on the link below.
ZoomDemo Source Code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute">
<mx:Script>
<!&#91;CDATA&#91;
import mx.core.Container;
import mx.core.UIComponent;
private function doZoom(component:UIComponent,val:Number):void
{
component.scaleX = val;
component.scaleY = val; 
if(component is Container)
{
var children:Array = Container(component).getChildren();
for(var i:int = 0; i < children.length; i++)
{
doZoom(children&#91;i&#93;, val);
}
}
} 
public function applyZoom():void
{
if(pnl == null)
{
return;
}
doZoom(pnl,zoomSlider.value);
}
&#93;&#93;>
</mx:Script>
<mx:HBox horizontalAlign="right">
<mx:VBox width="700" height="100%">
<mx:Panel id="pnl" width="400" height="400" title="Panel">
<mx:HBox width="100%" height="100%">
<mx:Button label="B1"/>
<mx:Button label="B2"/> 
<mx:Button label="B3"/>
</mx:HBox>
<mx:HBox width="100%" height="100%">
<mx:Button label="B11"/>
<mx:Button label="B21"/> 
<mx:Button label="B31"/>
</mx:HBox>
</mx:Panel> 
</mx:VBox>
<mx:VBox>
<mx:HSlider id="zoomSlider" minimum=".1" value="1"
maximum="2" change="applyZoom()" width="180"/>
<mx:Label text="Apply Zoom"/>
</mx:VBox>
</mx:HBox>
</mx:Application>

Hope you will like this………Enjoy Flexing…

Posted in ActionScript 3.0, Flex 3.0 | Tagged: , , , | 5 Comments »