July 23, 2009

Enable and Disable ContextMenu in Flex with AS3

Hi,
We can enable and disable the context menu option from the context menu. In below example is very easy way to enable and disable the context menu option based on the context menu selection. Lets see the below example and enjoy

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.managers.FocusManager;
import mx.core.UIComponent;
private var _spr:Sprite;
private var _contextMenu:ContextMenu;
private function onInit():void
{
var ui:UIComponent = new UIComponent();
_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000,0.8);
_spr.graphics.drawRect(0,0,200,200);
_spr.graphics.endFill();
ui.addChild(_spr);
_spr.x = 20;
_spr.y = 20;
addChild(ui);
loadContextMenu();
}
private function loadContextMenu():void
{
_contextMenu = new ContextMenu();
_contextMenu.hideBuiltInItems();
var _selAll:ContextMenuItem = new ContextMenuItem("Select All Hotspot");
var _deSelAll:ContextMenuItem = new ContextMenuItem("Deselect All Hotspot");
var _delAll:ContextMenuItem = new ContextMenuItem("Delete All Hotspot");
_contextMenu.customItems.push(_selAll);
_contextMenu.customItems.push(_deSelAll);
_contextMenu.customItems.push(_delAll);
_contextMenu.customItems[1].enabled = false;
_contextMenu.customItems[2].enabled = false;
_selAll.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menuItemSelect);
_delAll.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menuItemSelect);
_deSelAll.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menuItemSelect);
_spr.contextMenu = _contextMenu;
}
private function menuItemSelect(evt:ContextMenuEvent):void
{
var _custMenu:ContextMenuItem = evt.target as ContextMenuItem;
if(_custMenu.caption == "Select All Hotspot")
{
_contextMenu.customItems[0].enabled = false;
_contextMenu.customItems[1].enabled = true;
_contextMenu.customItems[2].enabled = true;
}
else
{
_contextMenu.customItems[0].enabled = true;
_contextMenu.customItems[1].enabled = false;
_contextMenu.customItems[2].enabled = false;
}
}
]]>
</mx:Script>
</mx:Application>

Navigate same or new window from Flex application

Hi,
In some Flex application need to navigate into flex application into other application. Those navigation can performs into the same window or new window by using the navigateToURL function from flash.net.navigateToURL. The below example contains two button for navigate to same as well as new window.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
private function onNavigateNew():void
{
navigateToURL(new URLRequest("http://www.google.com"),"POST");
}
private function onNavigateSame():void
{
navigateToURL(new URLRequest("http://ww.yahoo.com"),"_self");
}
]]>
</mx:Script>
<mx:VBox width="200" height="200" paddingLeft="20" paddingTop="20">
<mx:Button label="New Window" click="onNavigateNew()"/>
<mx:Button label="Same Window" click="onNavigateSame()"/>
</mx:VBox>
</mx:Application>

July 20, 2009

Set the content at center position when browser resize in Flex with AS3

Hi,
In the below example i used the document class in Flex. i.e script class access from the external actionscript file. The content in the flex application can be set at center position dynamically when the browser resized. Document class the .mxml and .as file for the main application at the same location under the src folder. It can be placed in other location too. The stage will be accessed after the function call applicationCompleted. So you can set the stage related functionality after the applicationCompleted function then only it can be set the stage releated functions otherwise it should be null and its relevant functionality cannot be set. Just see the below example

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%"
creationComplete="onInit()" applicationComplete="onAppComplete()">
<mx:Script source="TextWorks.as"/>
</mx:Application>

In above example the script tag refer the actionscript class. The actionscript class contains the entire main application scripts. TextWorks actionscript class coding as follows

import flash.display.Sprite;
import flash.events.Event;
import mx.core.UIComponent;

private var _spr:Sprite;
private var _ui:UIComponent;

private function onInit():void
{
_ui = new UIComponent();
_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000,0.8);
_spr.graphics.drawRect(0,0,200,200);
_spr.graphics.endFill();
_ui.addChild(_spr);
addChild(_ui);
}
private function onAppComplete():void
{
stage.addEventListener(Event.RESIZE,onResize);
_spr.x = (stage.stageWidth - _spr.width)/2;
_spr.y = (stage.stageHeight - _spr.height)/2;
_ui.width = stage.stageWidth;
_ui.height = stage.stageHeight;
}
private function onResize(evt:Event):void
{
_spr.x = (stage.stageWidth - _spr.width)/2;
_spr.y = (stage.stageHeight - _spr.height)/2;
_ui.width = stage.stageWidth;
_ui.height = stage.stageHeight;
}

Run this application and see the sprite content will be placed at center position dynamically when the browser resize.

Call Javascript function from Flex application

Hi,
We can call the javascript function from Flex application to perform any specific activity that can be perfromed by the server. You can call the javascript function with parameters or without any parameter when function call. The parameters for the javascript function was separated by commas. The ExternalInterface class was used to call the javascript function from the flex application. The syntax for calling the javascript function as follows

ExternalInterface.call("Function Name","[parameters]");

July 13, 2009

Save text file and jpeg image in Adobe Air

Hi,
In below example for save the text files and image files in Adobe Air. Adobe Air was easily interact with the system local files. In this example i saved the text file as well as image files and it has the format as .jpg. When need to save the text file first it check whether the file are exit or not. If the file cannot be found means then the text file content saved as a new file. This below example save the files using the File Stream class. Try the below example was very nice and intresting one.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.graphics.codec.PNGEncoder;
import flash.filesystem.*;
private var _stream:FileStream;
private function saveFile():void
{
var file:File = File.desktopDirectory.resolvePath("Test.txt");
_stream = new FileStream();
_stream.open(file,FileMode.WRITE);
_stream.writeUTFBytes(txt_area.text);
_stream.close();
}
private function saveImage():void
{
var file:File = File.desktopDirectory.resolvePath("test.jpg");
_stream = new FileStream();
_stream.open(file,FileMode.WRITE);
var _enc:PNGEncoder = new PNGEncoder();
var _bitmap:BitmapData = new BitmapData(img.width,img.height,true);
_bitmap.draw(img,new Matrix());
var bytes:ByteArray = _enc.encode(_bitmap);
_stream.writeBytes(bytes);
_stream.close();
}
]]>
</mx:Script>
<mx:VBox paddingTop="15" paddingLeft="15" paddingRight="15" paddingBottom="15">
<mx:HBox>
<mx:Label text="About Yourself:"/>
<mx:TextArea id="txt_area" width="250" height="125"/>
</mx:HBox>
<mx:HBox width="100%" horizontalAlign="center">
<mx:Image id="img" source="Test.jpg" width="200" height="150" horizontalAlign="center"/>
</mx:HBox>
<mx:HBox>
<mx:Button label="Save" click="saveFile()"/>
<mx:Button label="Save Image" click="saveImage()"/>
</mx:HBox>
</mx:VBox>
</mx:WindowedApplication>

July 08, 2009

Resize Sprite using the bottom resize tab in Flex

Hi,
The below example for resize the sprite using the resize tab at the bottomright position. By using the tab button to resize the sprite as width and height and it cannot be allow to change the postion of x and y.Try the below example it very nice one for resize the sprite based on resize tab move position and updates its width and height.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var _spr:Sprite;
private var _rect:Rectangle;
private var _resizeTab:Sprite;

private function onInit():void
{
var ui:UIComponent = new UIComponent();
_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000,0.5);
_spr.graphics.drawRect(0,0,200,200);
_spr.graphics.endFill();
ui.addChild(_spr);
addChild(ui);
ui.x = 50;
ui.y = 20;

_spr.addEventListener(MouseEvent.MOUSE_DOWN,onStartResize);
}

private function onStartResize(evt:MouseEvent):void
{
var _rect:Rectangle = _spr.getBounds(_spr.parent);
if(!_resizeTab)
{
_resizeTab = new Sprite();
_resizeTab.graphics.clear();
_resizeTab.graphics.beginFill(0x0000FF,0.8);
_resizeTab.graphics.drawRect(0,0,20,20);
_resizeTab.graphics.endFill();

_resizeTab.x = _rect.width - 10;
_resizeTab.y = _rect.height - 10;

_spr.addChild(_resizeTab);
_resizeTab.cacheAsBitmap = false;
_resizeTab.addEventListener(MouseEvent.MOUSE_DOWN,onResizeDown);
_resizeTab.addEventListener(MouseEvent.MOUSE_UP,onResizeUp);
}
else
return;
}

private function onResizeDown(evt:MouseEvent):void
{
var _sp:Sprite = evt.target.parent as Sprite;
_rect = _sp.getBounds(_sp.parent);
_resizeTab.startDrag();
addEventListener(MouseEvent.MOUSE_MOVE,onMove);
}

private function onMove(evt:MouseEvent):void
{
var _sp:Sprite = _resizeTab.parent as Sprite;
_rect.bottomRight = new Point(_sp.mouseX,_sp.mouseY);
_sp.graphics.clear();
_sp.graphics.beginFill(0xFF0000,0.4);
_sp.graphics.drawRect(0,0,_rect.width,_rect.height);
_sp.graphics.endFill();

var summa:Rectangle = _resizeTab.getBounds(_resizeTab.parent);
_resizeTab.x = _rect.width - (summa.width/2);
_resizeTab.y = _rect.height - (summa.height/2);
evt.updateAfterEvent();
}

private function onResizeUp(evt:MouseEvent):void
{
removeEventListener(MouseEvent.MOUSE_MOVE,onMove);
_resizeTab.stopDrag();
}

]]>
</mx:Script>
</mx:Application>

Load swf content into the Sprite in AS3

Hi,
In some of the post has mention as cannot possible to load the swf content inside the Sprite using the Loader class in AS3. But i try to load the swf content into the sprite using the Loader class. In this below example to load the loader directly instead of adding the child as loader.content. If you are try to load the child as loader.content means it throws an error as AVM1 object voliation for load the AVM2 oject into AVM1 Object. So you can add the child of sprite as loader it can possible to load the swf content and you can work over that.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import flash.events.KeyboardEvent;
import mx.controls.SWFLoader;

private var ui:UIComponent;
private var _spr:Sprite;
private var loader:Loader;

private function onInit():void
{
ui = new UIComponent();
_spr = new Sprite();
ui.addChild(_spr);
addChild(ui);

loader = new Loader();
loader.load(new URLRequest("test.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
}

private function onLoadComplete(e:Event):void
{
_spr.addChild(loader);
}

]]>
</mx:Script>
</mx:Application>

Simple Slideshow with Fade Effect

Hi,
In some of the slide show applications slide transition will be performed before the second image loaded. So the slide show application has blank screen without any images on screen after loading the second image then it start showing the image with effect. In below example avoid the blank screen and it will check whether the second image was loaded or not. If loaded the image it start the transition otherwise it remains on the first image to avoid the blank screen. In below example has avoid the blank screen and apply smooth fade effect when transistions.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.effects.Fade;
import mx.controls.Button;
import mx.containers.HBox;
import mx.controls.ProgressBar;
import mx.core.UIComponent;

private var image_container:UIComponent;
private var first_mc:Sprite;
private var second_mc:Sprite;
private var load_mc:Sprite;
private var _selectedIndex:Number=0;
private var timer:Timer;
private var _imgArray:Array = ["http://www.digitalphotoartistry.com/rose1.jpg","http://blogs.warwick.ac.uk/images/spjyoung/2006/02/20/rose.jpg","http://www.mccullagh.org/db9/1ds2-2/rose-side-view.jpg"];

private function onInit():void
{
image_container = new UIComponent();
first_mc = new Sprite();
image_container.addChild(first_mc);
second_mc = new Sprite();
image_container.addChild(second_mc);
addChild(image_container);

image_container.width = 400;
image_container.height = 400;
image_container.x = 20;
image_container.y = 20;

load_mc = first_mc;
loadImage();
startTimer();
}

private function startTimer():void
{
timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER,loadImges);
timer.start();
}

private function loadImges(evt:TimerEvent):void
{
if(_selectedIndex >= _imgArray.length-1)
{
_selectedIndex = -1;
}
else
{
_selectedIndex++;
loadImage();
}
}

private function loadImage():void
{
var urlLoader:Loader = new Loader();
var urlRequest:URLRequest =new URLRequest(_imgArray[_selectedIndex]);
urlLoader.contentLoaderInfo.addEventListener(Event.OPEN,onImageOpen);
urlLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageLoaded);

try
{
urlLoader.load(urlRequest);
}
catch(err:Error)
{
trace("Error");
}
}

private function onImageOpen(evt:Event):void
{
if(first_mc.numChildren > 0)
first_mc.removeChildAt(0);
if(second_mc.numChildren > 0)
second_mc.removeChildAt(0);

var num:Number = switchNumber(_selectedIndex);
if(num == 1)
{
load_mc = first_mc;
fadeOutImage(second_mc);
fadeInImage(first_mc);
}
else
{
load_mc = second_mc;
fadeOutImage(first_mc);
fadeInImage(second_mc);
}
}

private function onImageLoaded(evt:Event):void
{
load_mc.addChild(evt.target.content);
load_mc.width = 380;
load_mc.height = 300;
}

private function switchNumber(num:Number):Number
{
var ind:Number = num%2;
return (ind == 0)?1:2;
}

private function fadeInImage(target:Sprite):void
{
var _fadeIn:Fade = new Fade(target);
_fadeIn.alphaFrom = 0;
_fadeIn.alphaTo = 1;
_fadeIn.duration = 400;
_fadeIn.play();
}

private function fadeOutImage(target:Sprite):void
{
var _fadeOut:Fade = new Fade(target);
_fadeOut.alphaFrom = 1;
_fadeOut.alphaTo = 0;
_fadeOut.duration = 400;
_fadeOut.play();
}

]]>
</mx:Script>
</mx:Application>

Working with local system files in Flex3.2 SDK and FlashPlayer10

Hi,
In below example for accessing the local system xml files and read the xml content and set the input to the List control. The seelcted xml content as shown in Textarea control also. Whenever click the image from the List control its relevant image is shown. It must need the Flex sdk3.2 and Flash player10 then only access the function of the Flash player10 as load() and save() otherwise in the below example cannot be work.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import flash.net.FileReference;
import flash.utils.ByteArray;

private var _fileBrowse:FileReference;
private var _imgStr:String;
private var _listProvider:Array;

private function onClick():void
{
_fileBrowse = new FileReference();
_fileBrowse.addEventListener(Event.CANCEL,onCancel);
_fileBrowse.addEventListener(Event.SELECT,onFileSelect);
_fileBrowse.browse();
}

private function onCancel(evt:Event):void
{
_fileBrowse = null;
}

private function onFileSelect(evt:Event):void
{
_fileBrowse.addEventListener(Event.COMPLETE,onComplete);
_fileBrowse.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
_fileBrowse.load();
}

private function onComplete(evt:Event):void
{
var _data:ByteArray = _fileBrowse.data;
txt_area.text = _data.readUTFBytes(_data.bytesAvailable);
_imgStr = txt_area.text;
_fileBrowse = null;
loadXML();
}

private function ioErrorHandler(evt:IOErrorEvent):void
{
trace("Io Error");
}

private function loadXML():void
{
var _xml:XML;
_listProvider = new Array();

if(_imgStr != "")
{
_xml = new XML(_imgStr);
var _xmlList:XMLList = XMLList(_xml.image);
for(var i:int=0;i<_xmlList.length();i++)
{
_listProvider.push({label:_xmlList[i].@name,path:_xmlList[i].@path});
}
lst.dataProvider = _listProvider;
}
}

private function onItemClick():void
{
img.source = lst.selectedItem.path;
}

]]>
</mx:Script>
<mx:HBox paddingLeft="20" paddingTop="20">
<mx:VBox>
<mx:TextArea id="txt_area" width="400" height="200"/>
<mx:List id="lst" width="400" height="120" itemClick="onItemClick()"/>
<mx:Button label="open" click="onClick()"/>
</mx:VBox>
<mx:HBox>
<mx:Image id="img" width="400" height="400"/>
</mx:HBox>
</mx:HBox>
</mx:Application>

The example xml as follows

<?xml version="1.0" encoding="UTF-8"?>
<images>
<image name="image1" path="http://www.digitalphotoartistry.com/rose1.jpg"/>
<image name="image2" path="http://blogs.warwick.ac.uk/images/spjyoung/2006/02/20/rose.jpg"/>
<image name="image3" path="http://www.mccullagh.org/db9/1ds2-2/rose-side-view.jpg"/>
</images>

Hightlight the selection of Sprite in Flex

Hi,
In Sprite highlighted by using the graphics for change the color selection. The getBounds() function was used to get the boundary area of the sprite based on that we can draw the graphics again with different selection color. After complete the graphics draw then placed the sprite by its position of x and y. Whenever need to change the color selection we must need redraw the sprite using the graphics. In the folowing example very nice one for selecting or highlighted the sprite based on mouse down event.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;

private var _spr:Sprite;
private var _curSpr:Sprite;
private var _prevSpr:Sprite;

private function onInit():void
{
var ui:UIComponent = new UIComponent();
_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000);
_spr.graphics.drawRect(0,0,200,200);
_spr.graphics.endFill();
_spr.addEventListener(MouseEvent.MOUSE_DOWN,onSelect);
_spr.x = 20;
_spr.y = 30;
ui.addChild(_spr);

_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000);
_spr.graphics.drawRect(0,0,200,200);
_spr.graphics.endFill();
_spr.addEventListener(MouseEvent.MOUSE_DOWN,onSelect);
ui.addChild(_spr);
_spr.x = 230;
_spr.y = 25;

addChild(ui);
}

private function onSelect(evt:MouseEvent):void
{
_prevSpr = _curSpr;
if(_prevSpr != null)
setSelect(_prevSpr,0xFF0000);
_curSpr = evt.target as Sprite;
setSelect(_curSpr,0x00FF00);
}

private function setSelect(spr:Sprite,color:uint):void
{
var rect:Rectangle = spr.getBounds(spr.parent);

spr.graphics.clear();
spr.graphics.beginFill(color);
spr.graphics.drawRect(0,0,rect.width,rect.height);
spr.graphics.endFill();

spr.x = rect.x;
spr.y = rect.y;
}

]]>
</mx:Script>
</mx:Application>

Refresh Flex page using Javascript function in AS3

Hi,
In Flex once the values get updated we need to refresh the felx content dynamically. Here i did one example for refresh the flex page by calling the javascript function when click the button in flex application. Its very simple way to refresh the flex page whenever you wants by using the following javascript function calls.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
private function onRefresh():void
{
var ref:URLRequest = new URLRequest("javascript:location.reload(true)");
navigateToURL(ref,"_self");
}
]]>
</mx:Script>
<mx:Button label="Refresh" click="onRefresh()"/>
</mx:Application>

Drag the Sprite using the Shift Key and Mouse Down event in AS3

Hi,
This following example for drag the sprite when holding the shift key in the Keyboard. The Shify key was released then the sprite cannot be moved furtur and it stop drag into the selected dragged area. The selected sprite should be focus then only it can work the functionality of the keyboard and check whether pressed the shift key or not. The Display object cannot be focus use the code as stage.focus property as currently selected Display object. This property helps to focus the current Display object selection and then drag the sprite based on Shift Key was pressed.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="onKeySet()" creationComplete="onInit()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var _spr:Sprite;

private function onInit():void
{
var ui:UIComponent = new UIComponent();
_spr = new Sprite();
_spr.graphics.clear();
_spr.graphics.beginFill(0xFF0000,0.7);
_spr.graphics.drawRect(0,0,500,500);
_spr.graphics.endFill();
ui.addChild(_spr);
addChild(ui);
}

private function onKeySet():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUp);
}

private function onKeyDown(evt:KeyboardEvent):void
{
stage.focus = _spr;
_spr.focusRect = false;
if(evt.keyCode == 16)
{
_spr.addEventListener(MouseEvent.MOUSE_DOWN,onDownSprite);
_spr.addEventListener(MouseEvent.MOUSE_UP,onUpSprite);
}
}

private function onKeyUp(evt:KeyboardEvent):void
{
if(evt.keyCode == 16)
{
_spr.removeEventListener(MouseEvent.MOUSE_DOWN,onDownSprite);
_spr.removeEventListener(MouseEvent.MOUSE_UP,onUpSprite);
}
}

private function onDownSprite(evt:MouseEvent):void
{
_spr.addEventListener(MouseEvent.MOUSE_MOVE,onMoveSprite);
}

private function onMoveSprite(evt:MouseEvent):void
{
_spr.startDrag();
evt.updateAfterEvent();
}

private function onUpSprite(evt:MouseEvent):void
{
_spr.stopDrag();
_spr.removeEventListener(MouseEvent.MOUSE_MOVE,onMoveSprite);
}

]]>
</mx:Script>
</mx:Application>

Swap two xml nodes in XML

Hi,
The following example explain about the swapping two nodes based on the node index value.The newly updated the swap xml is maintained in the main XML. The swap XML was considered as a new xml then only it should be swap properly in XML otherwise it cannot perfefectly swap and reflect the changes to the XML.

<?xml version="1.0" encoding="utf-8"?>
<mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="onInit()">
<mx:script>
<![CDATA[
private var _initXML:XML;
private var _xmlList:XMLList;

private function onInit():void
{
_initXML = XML("");
_xmlList = XMLList(_initXML.Fruits.fruit);
txt_area.text = _initXML.toXMLString();
}

private function onButtonClick():void
{
txt_area.text = swapXML(int(txt_old.text),int(txt_new.text));
}

private function swapXML(ind1:int,ind2:int):XML
{
var xml1:XML = new XML(_xmlList[ind1]);
var xml2:XML = new XML(_xmlList[ind2]);
_xmlList[ind1] = xml2;
_xmlList[ind2] = xml1;
return _initXML;
}
]]>
</mx:Script>
<mx:vbox paddingtop="10" paddingleft="10">
<mx:textarea id="txt_area" width="450" height="300">
<mx:hbox>
<mx:text text="Old Depth:" width="100">
<mx:textinput id="txt_old" width="100">
</mx:HBox>
<mx:hbox>
<mx:text text="New Depth:" width="100">
<mx:textinput id="txt_new" width="100">
</mx:HBox>
<mx:hbox paddingleft="30">
<mx:button label="Change" click="onButtonClick()">
</mx:HBox>
</mx:VBox>
</mx:Application>

MouseMove problem in AS3

Hi,
In Actionscript3 Mousemove events assigned to the display objects it can be fired gradually when the mouse will be focused on the display object assigned to which it was assigned. When mouse goes off or outside of the display objects it stop firing the mousemove event. If you drag a display object using the mousemove event to stop functioning the mousemove event if you move the mouse too fast preventing the display object being dragged until the mouse is back over the display object.

Problem in accessing Webservice when send xml as input to Webservice class in AS3

Hi,
I faced the problem when send the xml value as the input to the webservice class. I use e4x format for access the webservice. When xml as send as the input to the webservice class it cannot call the webservice class and report as warning message. Then i set the xmlSpecialCharsFilter function for the web service class and its change the value of object type to string value type and then send the value. After it call the webservice class successfully and return the result from the webservice class. The following way i can use to solve the problem for not accessing the webservice

var webService:WebService = new WebService();
webService.xmlSpecialCharsFilter = filterVal;

The xmlSpecialCharsFilter as function it will filter the special characters and change the object type values to string values. The filterVal function definition as follows

private function filterVal(val:Object):String
{
return val.toString();
}