Pages

Saturday, April 28, 2012

How to get MovieClip X and Y position from child MovieClip to parent main MovieClip in AS3


Step 1: Change Movie clip to Object.
example:- Here have c_mc is child of b_mc and b_mc is a child of a_mc.

now we will find c_mc x and y postion in main stage

var obj:Object=new Object();
obj=a_mc.b_mc.c_mc;

Step 2: Get x and y position using with localToGlobal method.
var poi:Point=new Point(obj.x,obj.y);
poi=obj.parent.localToGlobal(poi);

poi.x and poi.y are c_mc movieclip x,y positions.
Thank you Friends 
...CHeeRS...

Friday, November 5, 2010

String Convert to MovieClip in ActionScript3.0

Do you want source file...

Click here...

StringToMC.zip

Card Flip in Action Script3.0




Example:


card_mc.addEventListener(MouseEvent.CLICK,cli);
function cli(event:MouseEvent)
{
if(card_mc.currentFrame==1)
startFlip(2) 
else
startFlip(1)
}


var flipStep:uint;
var isFlipping:Boolean = false;
var flipToFrame:uint;
/** begin the flip, remember which frame to jump to **/
function startFlip(flipToWhichFrame:uint) 
{
isFlipping = true;
flipStep = 10;
flipToFrame = flipToWhichFrame;
card_mc.addEventListener(Event.ENTER_FRAME, flip);
}
/** take 10 steps to flip **/
function flip(event:Event)
{
flipStep--; // next step
if (flipStep > 5)
{ // first half of flip
card_mc.scaleX = .2*(flipStep-6);

else 
{ /** second half of flip **/
card_mc.scaleX = .2*(5-flipStep);
}
/** when it is the middle of the flip, go to new frame **/
if (flipStep == 5)
{
card_mc.gotoAndStop(flipToFrame);
}
/** at the end of the flip, stop the animation **/
if (flipStep == 0)
{
card_mc.removeEventListener(Event.ENTER_FRAME, flip);
}
}


...CHeeRS...






SourceFile

Monday, September 13, 2010

Fetch XML data using AS3

Example source file for fetch xml data using as3....

XML:
XML:



<
Question
>
<
Answer
>
<
Question_Data heading= "what is your Name" ans= "kumaresh"
/
>
<
Question_Data heading= "what is you father Name" ans= "rengan"
/
>
<
Question_Data heading= "What are you doing" ans= "playing"
/
>
<
/
Answer
>
<
/
Question
>



As3:


var externalXML:XML=new XML;
var loader:URLLoader=new URLLoader();
var urlrequest:URLRequest=new URLRequest("question.xml");
loader.load(urlrequest);
loader.addEventListener(Event.COMPLETE,one);
var rows:Number;
var headingArray:Array=new Array();
var ansArray:Array=new Array();
var changeQue:Number=0;

function one(e1:Event):void
{
externalXML=new XML(loader.data);
rows=externalXML.Answer.Question_Data.length();
trace(rows);

for(var i:uint;i
<
rows;i++)
{
headingArray.push(externalXML.Answer.Question_Data[i].@heading); ansArray.push(externalXML.Answer.Question_Data[i].@ans);
}
display();
}
function display():void
{
heading.text=headingArray[changeQue]; ans.text=ansArray[changeQue];
}
arr1_btn.addEventListener(MouseEvent.CLICK,nextQue); arr2_btn.addEventListener(MouseEvent.CLICK,prevQue);
function nextQue(e2:MouseEvent):void
{
if(changeQue
<
(headingArray.length-1))
{
changeQue++;
display();
}
}
function prevQue(e3:MouseEvent):void
{
if(changeQue
<
headingArray.length&&changeQue
>
0)
{
changeQue--;
display();
}

}





Do you want down load this source file...


xmlFetch.zip