Friday, February 17, 2012

Facebook Actionscript API calling

Steps to follow:

1) Get the lattest code package from this link http://code.google.com/p/facebook-actionscript-api/

2) Code to follow

import com.facebook.graph.*;

// uid is the variable coming from the page parameters.
var uid:String ;

function getUserName():void
{

Facebook.api("/"+uid, callBackUserInfo);

function callBackUserInfo(user:Object, fault:Object):void
{
trace(user.name);
}

}

Wednesday, April 14, 2010

Monday, January 4, 2010

setProperty function

Example

The following ActionScript creates a new movie clip and loads an image into it. The _xand _y coordinates are set for the clip using setProperty(). When you click the button called right_btn, the _xcoordinate of a movie clip named params_mc is incremented by 20 pixels.


this.createEmptyMovieClip("params_mc", 999);
params_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
setProperty(this.params_mc, _y, 20);
setProperty(this.params_mc, _x, 20);
this.right_btn.onRelease = function() {
setProperty(params_mc, _x, getProperty(params_mc, _x)+20);
};

Monday, December 21, 2009

Dynamically create and loop through MovieClip instances

Task: You need to dynamically create and then loop through MovieClips.
Solution: Use DisplayList and DisplayListContainer container methods.

var container:MovieClip = new MovieClip();
addChild(container);
var numItems:Number = 250;
var stageWidth:Number = stage.stageWidth;
var stageHeight:Number = stage.stageHeight;
function initClips():void
{
var c:MovieClip;
for(var i:Number = 0; i <>
{
c = new circle_mc();
randomizeClip(c);
container.addChild(c);
}
}
function randomizeClip(clip:MovieClip):void
{
clip.x = Math.random() * stageWidth;
clip.y = Math.random() * stageHeight;
clip.scaleX = Math.random() * 2;
clip.scaleY = Math.random() * 2;
var c:ColorTransform = new ColorTransform();
c.color = (Math.random() * 0xFFFFFF);
clip.transform.colorTransform = c;
clip.alpha = Math.random();
}
function onEnterFrame(event:Event):void
{
var c:MovieClip;
for(var i:Number = 0; i <>)
{
c = MovieClip(container.getChildAt(i));
randomizeClip(c);
}
}
initClips();
addEventListener(Event.ENTER_FRAME, onEnterFrame);


Play an embedded sound in AS3

Task: You need to play a sound contained within your content and set its volume.
Solution: Use the Sound, SoundChannel, and SoundTransform classes to play and
manipulate sounds.

function onSoundComplete(event:Event):void
{
trace("sound is completed");
}
var my_sound:Sound = new beep_id();
var sTransform:SoundTransform = new SoundTransform();
sTransform.volume = .5;
var channel:SoundChannel = my_sound.play();
channel.soundTransform = sTransform;
channel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
Setting the class name for an embedded
sound for ActionScript 3