Short Tag – Web Development Blog

Entries for March, 2009

Flash CS4 AS3 FLVPlayBack Component indicator not moving

Flash CS4 AS3 FLVPlayBack Component indicator not moving?
FlvPlayBack Component indicator is not moving if the isLive field is set to true, it just simply stand there and the movie is playing without problems.
So you just have to:
fpb.isLive = false;
If you need to use it with isLive I don’t know what to do, if you know [...]

FLASH CS4 AS3 TextField width not returned correctly?

FLASH CS4 AS3 TextField width not returned correctly?
You have to set the textfield’s multiline property to false else the field will be considered a multiline textfield and this will result in incorrect calculations.
Example:
textField.multiline = false;
I’ve seen this problem in Flash CS4 with AS3. It may be present in other versions too.
AS3 Freaks me out [...]

Check if String is AlphaNumeric in PHP

function isAlphaNumeric($text)
{
if(ereg(‘[^A-Za-z0-9]‘, $text))
return false;
else return true;
}

We check if a String is alphanumeric, if a string contains only characters and numbers, useful for validating usernames.

Link in AS3, Link to an URL – The AS3 Method

As action script 3 is an object oriented language the button actions, links and everything changed.

link.addEventListener(MouseEvent.CLICK, gotox);
function gotox(E:Event):void
{
var url:String = "http://www.myweb.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_blank’); // second argument is target
}catch (e:Error) {
trace("Error occurred: gotox!");
}
}

We add an event listener to add ‘link’ button. Now each button need an instance name, because we have to [...]

Function To Convert Alpha-RGB to AS3 HEX

function argbtohex(a:Number, r:Number, g:Number, b:Number)
{
return (a<<24 | r<<16 | g<<8 | b)
}
This function receives 4 parameters: alpha, red, green and blue, each has it’s values between 0-255.
Usage:
color = argtohex(255,255,0,0); //red, full alpha
For 100% alpha use the value: 255 and for 0% alpha use 0.
And finally,
The usual happy coding:D

What is Tweener?

Tweener (caurina.transitions.Tweener) is a Class used to create tweenings and other transitions via ActionScript code for projects built on the Flash platform.
It saves you a lot of time when you are creating Tweens and Transitions, it is easy to use, and you Movie Structure will be less complicated.
“The general idea of a tweening Class is [...]

Using Tweener in Action Script 3 Flash CS4

First you download Tweener Class from here:
http://code.google.com/p/tweener/
Than you unzip the archive and copy it to your project folder.
Than you import it in where you need to use it:
import caurina.transitions.Tweener;
And than you use it, example:
mc.alpha = 0;
Tweener.addTween(mc, {alpha:1, time:1});
First I set the alpha of ‘mc’ MovieClip to 0, than I added a tween, a tween that [...]

[AS3] Create SimpleButton with Action Script 3

ShortTag shows you how you can create a Button with AS3:
var sb:SimpleButton = new SimpleButton();
//we create the SimpleButton object
//as you know a Button in Flash has 4 state: up, down, over and hit
//we create a MovieClip for the up, down and hit state and an other one
//for the over state
var mc:MovieClip = new MovieClip();
//we create [...]

As3 Create Movie Clip by Coding

You want to create a movieclip with Action Script 3?
ShortTag shows you how:
var mc:MovieClip = new MovieClip();
mc.x = 100;
mc.y = 100;
mc.width = 500;
mc.height = 600;
addChild(mc);
MovieClip mc = new MovieClip(); // we create a MovieClip object
mc.x = 100; mc.y = 100; // we set the x and y coordinates
mc.width = 500; mc.height = 600; // we [...]