Tuesday, April 19, 2011

Welcome my Friends, I am Raghunath and here is my Flash Stuff.


Hi Friends, I am working in Flash Animation, ActionScript 2.0 & 3.0, Photoshop, Flex and FlashDevelop, GreenSock.

I am Seeking a challenging career in the field of Multimedia-Programming and also Designing to apply my knowledge, skill sets and innovative abilities towards the goal of an organization. I want to become well Flash professional to shape my career in flash, where my creativity is valuable.
My Great Web page
I also take freelance projects. If you want to make flash animation or programming and website. contact me.
Please see the website here. : raghunathsontakke@biz.ly or add me as friend on facebook-name is https://www.facebook.com/raghunathdsontakke
My Google Profile My Personal Website is here. raghunathsontakke.biz.ly

Tuesday, April 12, 2011

Create a Dynamic Bar Graph Generator Using XML + AS3


package
{

import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.transitions.Tween
import fl.transitions.easing.Strong

public class Graph extends Sprite
{

private var container:Sprite;
private var tf:TextFormat = new TextFormat();
private var totalBars:int;
private var urlLoader:URLLoader = new URLLoader();
private var xmlFile:XML;
private var tween:Tween;



public function Graph()
{
trace("constructor code");

tf.size = 12;
tf.color = 0x366666;
tf.font = "Helvetica"

createContainer();
loadXML();
}

private function createContainer():void
{
container = new Sprite();
container.graphics.lineStyle(1);
container.graphics.moveTo(30,30);
container.graphics.lineTo(30,360);
container.graphics.lineTo(480,360);
addChild(container);
}

private function loadXML(file:String="graph.xml"):void
{
//trace("loadXML()")
urlLoader.load(new URLRequest(file));
urlLoader.addEventListener(Event.COMPLETE, parseXML);
}
private function parseXML(e:Event)
{
xmlFile = new XML(e.target.data);
totalBars = xmlFile.children().length();
//trace(xmlFile +"\n"+totalBars);
createBars();
createNames()
}
private function createBars():void
{
for (var i:int=0; i<totalBars; i++)
{
var bar:Sprite = new Sprite();
bar.graphics.beginFill(xmlFile.children()[i].@color);
bar.graphics.drawRect(0,0,xmlFile.@width, xmlFile.children()[i].@value);
bar.graphics.endFill();
addChild(bar);

bar.x = 60 + (xmlFile.@width * i) + (10 * i);
bar.y = 340 - bar.height

tween  = new Tween(bar,"height",Strong.easeOut,0,bar.height,1,true)

var val:TextField = new TextField()
val.defaultTextFormat = tf;
addChild(val)
//val.defaultTextFormat(tf)
//val.defaultTextFormat(tf)
val.text = xmlFile.children()[i].@value
val.x = 60 + (xmlFile.@width * i) + (10 * i);
val.y = 190 - bar.height


}

}

private function createNames():void{
for(var i:int = 0 ; i<totalBars; i++){
var color:Sprite = new Sprite()
color.graphics.beginFill(xmlFile.children()[i].@color)
color.graphics.drawRect(0,0,10,10)
color.graphics.endFill()
addChild(color)
color.x = 400
color.y = 60 + (30* i)

var names:TextField = new TextField()
names.defaultTextFormat = tf
names.text = xmlFile.children()[i].@name
names.x = 420
names.y = 60 + (30 * i)
addChild(names)


}
}

}

}
//graph.xml file content
/*
<graphs width="50">
<graph name="Red" value="30" color="0xFF0000"/>
<graph name="Green" value="80" color="0x00FF00"/>
<graph name="Blue" value="50" color="0x0000FF"/>
</graphs>
*/