Flash actionscript 3.0

how to display the external "XML" file in flash AS 3.0

0

Posted by Sankar.G | Posted in | Posted on 11:29 PM

var externalXML:XML=new XML;
var loader:URLLoader=new URLLoader();
var urlrequest:URLRequest=new URLRequest("Data.xml");
loader.load(urlrequest);
loader.addEventListener(Event.COMPLETE,one);
var rows:Number;
var array:Array=new Array();
function one(e1:Event):void
{
externalXML=new XML(loader.data);
rows=externalXML.Employee.Employee_Data.length();
for(var i:uint;i< rows;i++) { array.push({name_arr:externalXML.Employee.Employee_Data[i].@ Names,age_arr:externalXML.Employee.Employee_Data[i].@ Age,id_arr:externalXML.Employee.Employee_Data[i].@Id}); } display(); } function display():void { names.text=ages.text=ids.text=" "; for each(var arr in array) { names.appendText(arr.name_arr+"\n"); ages.appendText(arr.age_arr+"\n"); ids.appendText(arr.id_arr+"\n"); } } arr1_btn.addEventListener(MouseEvent.CLICK,two); arr2_btn.addEventListener(MouseEvent.CLICK,three); function two(e2:MouseEvent):void { array.sortOn("name_arr",array.DESCENDING); display(); } function three(e3:MouseEvent):void { array.sortOn("age_arr",array.DESCENDING|array.NUMERIC); display(); } create 3 text box and name it as names,ages,ids and create 2 buttons and name it as arr1 & arr2 to arrange the values in decending order below we have XML file store the XML file near to the flash file and Name it as Data.xml < Datas>
< Employee>
< Employee_Data Names="a" Age= "10" Id= "13" />
< Employee_Data Names="g" Age= "12" Id= "523" />
< Employee_Data Names="e" Age= "55" Id= "63" />
< Employee_Data Names="w" Age= "22" Id= "403" />
< Employee_Data Names="y" Age= "24" Id= "293" />
< Employee_Data Names="q" Age= "66" Id= "883" />
< Employee_Data Names="o" Age= "97" Id= "813" />
< Employee_Data Names="z" Age= "13" Id= "723" />
< /Employee>
< /Datas>

How to get Next Highest Depth in AS 3.0

0

Posted by Sankar.G | Posted in | Posted on 11:49 AM

In AS2.0 we use getNextHighest depth but in AS3.0 we dont have that function for that we have
swapChildren()
swapChildrenAt()
getChildIndex()
setChildIndex()

by using this kind of function we want to create that

Below File is used to you

highestDepth.zip

next.swf

Timer Event in AS3.0

0

Posted by Sankar.G | Posted in | Posted on 3:59 PM

var min:Number=0;
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, myFunction);
min_txt.text=String(min);
function myFunction(event:TimerEvent):void
{
sec_txt.text=String(myTimer.currentCount);
if(myTimer.currentCount==10)
{
myTimer.stop();
myTimer.reset();
myTimer.start();
min=min+1;
min_txt.text=String(min);
}
}
myTimer.start();

Create 2 text box and Name it as sec_txt & min_txt and put this script

how to store the object X&Y values in Array using AS3.0

0

Posted by Sankar.G | Posted in | Posted on 3:51 PM

var objectArray:Array = new Array();
for (var i:uint = 0;i<
Objects.numChildren;i++)
{
var point:Point = new Point(Objects.getChildAt(i).x , Objects.getChildAt(i).y);
objectArray.push(point);
Objects.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN, process);
}




reset_btn.addEventListener(MouseEvent.CLICK, resetAll);
function resetAll(event:MouseEvent):void
{
for(i = 0; i<
Objects.numChildren;i++)
{
Objects.getChildAt(i).x = objectArray[i].x;
Objects.getChildAt(i).y = objectArray[i].y;
}
}
put all the objects in one Movie clip and name it as Objects and write this script

getting XML Datas from XML file in AS3.0

0

Posted by Sankar.G | Posted in | Posted on 3:49 PM

var url:URLLoader=new URLLoader();
var xml:XML=new XML();
url.addEventListener(Event.COMPLETE,one);
url.load(new URLRequest("one.xml"));

function one(e:Event):void
{
xml=new XML(e.target.data);
two(xml);
}
function two(xml2:XML)
{
var list:XMLList=xml2.Book.children();
for each (var xml3:XML in list)
{
trace(xml3);
}
}

one.xml is a xml file save the xml file in same folder with this file