Flash CS4 TextElement TextBlock FontDescription TextBlock TextLine

Posted by druva | AIR, Flash, Flex, as3, utils | Thursday 11 February 2010 12:48 pm

This code show how to use TextElement, TextBlock, FontDescription, TextBlock, TextLine

package druva{
import flash.display.Sprite;
import flash.text.engine.*;

public class TextTest extends Sprite {

public function TextTest() {

for (var j:int=0; j<=10; j++) {
var myString:String="Druva";
var myFormat:ElementFormat = new ElementFormat();

var myFontDesc:FontDescription=new FontDescription('Georgia','normal','italic','device');
myFormat.fontSize=2+2*j;
myFormat.fontDescription=myFontDesc;
myFormat.color = Math.random() * 0xFFFFEE;

var textElement:TextElement=new TextElement(myString, myFormat);
var textBlock:TextBlock = new TextBlock();
textBlock.content=textElement;

var myTextLine:TextLine=textBlock.createTextLine(null,300);

myTextLine.x = 30+(3*(j*(j+1)/2));
myTextLine.y = 150;

addChild(myTextLine);
myTextLine.addEventListener(Event.ENTER_FRAME, onLoop);
}

}
import flash.events.*;
private function onLoop(e:Event) {
e.currentTarget.rotationY += 3;
e.currentTarget.rotation = mouseX;
}
}
}

This movie requires Flash Player 9

 

Flash CS4 PerspectiveProjection projectionCenter with action script

Posted by druva | Flash, Uncategorized, as2, as3 | Wednesday 10 February 2010 1:13 pm

This code show how to use PerspectiveProjection, projectionCenter tranform, point

var img:Bitmap=new Bitmap(new heart(158, 58));
img.x=-158/2;
img.y=-58/2;
var holder:Sprite=new Sprite();
addChild(holder);
holder.x=stage.stageWidth/2;
holder.y=stage.stageHeight/2;
holder.addChild(img);

var pp:PerspectiveProjection=new PerspectiveProjection();
pp.fieldOfView = 120
pp.projectionCenter=new Point(holder.x,holder.y);
holder.transform.perspectiveProjection=pp;

function swingImage(e:Event):void {
	holder.rotationY+=3;
}
this.addEventListener(Event.ENTER_FRAME, swingImage);

This movie requires Flash Player 9

 

Image rotating in Y direction with tweener using flash actionscript

Posted by Vineela | Flash, as3, utils | Friday 6 November 2009 6:01 am

To see the effect please click on the below image


import caurina.transitions.Tweener;

var values:int=0;

heart.addEventListener(MouseEvent.MOUSE_DOWN,rotate);

function rotate(evt:MouseEvent):void
{
	values = values - 1;
	Tweener.addTween(heart,{rotationX:values*0,rotationY:values*180,time:1,transition:"easeInCubic"});
}

This movie requires Flash Player 9

 

Image rotating in X direction with tweener using flash actionscript

Posted by Vineela | Flash, as3, utils | Thursday 5 November 2009 5:58 am

To see the effect please click on the below image


import caurina.transitions.Tweener;

var values:int=0;

heart.addEventListener(MouseEvent.MOUSE_DOWN,rotate);

function rotate(evt:MouseEvent):void
{
	values = values - 1;
	Tweener.addTween(heart,{rotationX:values*180,rotationY:values*0,time:1,transition:"easeInCubic"});
}

This movie requires Flash Player 9

 

Image rotating in Y direction using flash actionscript

Posted by Vineela | Flash, as3, utils | Wednesday 4 November 2009 5:26 am

heart.addEventListener(Event.ENTER_FRAME,rotateY);

function rotateY(evt:Event):void
{
	evt.target.rotationY = evt.target.rotationY + 2;
}

This movie requires Flash Player 9