Tuesday, January 8, 2008

Effects Blur Filter

Blur Filter:

Now, we see the blur Filter Examples...

Now we have create a movie clip and give instance name as reflec...

Main screen

1: Movie Clip
2: 2 input textfiled for Blur x and Blur y
3: Update button

Let, before open

import the filters

import mx.transitions.Tween;
import flash.filters.BlurFilter;
import mx.transitions.easing.*;

After, apply the effect to the movie
on Enterframe event


Here, the complete Code...


import mx.transitions.Tween;
import flash.filters.BlurFilter;
import flash.filters.*;
import mx.transitions.easing.*;

function update()
{
updatebtn.onPress = function()
{
applyfilter()
var s = new Tween(_root.reflec,"_x",null,0,350,5,true)
s.onMotionFinished = function()
{
s.yoyo()
}
}

}
update()


function applyfilter()
{
var blur_X = Number(_root.blurx.text)
var blur_Y = Number(_root.blury.text)
var quality = 3

var filter = new BlurFilter(blur_X,blur_Y,quality)
var filterarr = new Array()
filterarr[0] = filter
reflec.filter = filterarr

_root.onEnterFrame = function()
{
if(reflec.hitTest(_xmouse,_ymouse,true))
{
if(reflec.filters[0].blurX != 0)
{
blur_X -= 1;
blur_Y -= 1;

filter = new BlurFilter(blur_X, blur_Y, quality);
filterarr = new Array();
filterarr[0] = filter
reflec.filters = filterarr;
}
}
else
{
if(reflec.filters[0].blurX != 10)
{
blur_X += 1;
blur_Y += 1;

filter = new BlurFilter(blur_X, blur_Y, quality);
filterarr = new Array();
filterarr[0] = filter
reflec.filters = filterarr;
}
}
}
}

Have!, a gr8 effect...
Thanks....

Dropshadow Filter

First ,
we have to import the flash filter
import flash.filters.DropShadowFilter;

Now create a runtime Movieclip as

let we create a box make a sixe of x and y as 50

here the code:

this.createEmptyMovieClip('Box',2)
with (Box)
{
beginFill(0x000000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 100);
lineTo(0, 100);
lineTo(0, 0);
endFill();
}
Box._x = 50
Box._y = 100


and then

in that EnterFrame we have to give the value.. and call the variable
and make values as Dynamic text
Here the code as,

Box.onEnterFrame = function()
{

ds.quality++
Box.filters = [ds]
_root.reson.text = ' For Box : The Drop Shadow option Distance = 2, Angle = 45 degree , Color = 0x66FF33, Alpha = 1, Blur X = 5 Blur Y = 5 Strength = 2 , Qulaity = 3 Inner = false, Knock-out = false, HideObject = false';

}

var ds = new DropShadowFilter (2,45,0x66FF33,0.8,5,5,2,3,false,false,false);

Have a joy with Filter....

Thanxs!....

Wednesday, January 2, 2008

Runtime Circle

Creating a method that can be used by all movieclips in a movie



As of Flash MX, the prototype property of the MovieClip class can be used to assign additional functions to the class, which makes them available to all movieclips. Here's an example of creating and using a draw circle method:

// r = radius of circle
// x, y = center of circle
MovieClip.prototype.drawCircle = function (r, x, y) {
var TO_RADIANS:Number = Math.PI/180;
// begin circle at 0, 0 (its registration point) -- move it when done
this.moveTo(0, 0);
this.lineTo(r, 0);

// draw 12 30-degree segments
// (could do more efficiently with 8 45-degree segments)
var a:Number = 0.268; // tan(15)
for (var i=0; i < endx =" r*Math.cos((i+1)*30*TO_RADIANS);" endy =" r*Math.sin((i+1)*30*TO_RADIANS);" ax =" endx+r*a*Math.cos(((i+1)*30-90)*TO_RADIANS);" ay =" endy+r*a*Math.sin(((i+1)*30-90)*TO_RADIANS);" _x =" x;" _y =" y;" x="100," y="100">
To draw a shape with a part of it cut out, like a donut eg, simply put all the commands to draw both the initial object (big circle) and the cutout (smaller circle) between the beginFill and endFill statements. Here's how the donut on the left (ok, more like a bagel but still delicious) was created:

// r1 = radius of outer circle
// r2 = radius of inner circle (cutout)
// x, y = center of donut
// This creates a donut shape (circle with a cutout circle)
MovieClip.prototype.drawDonut1 = function (r1, r2, x, y) {
var TO_RADIANS:Number = Math.PI/180;
this.moveTo(0, 0);
this.lineTo(r1, 0);

// draw the 30-degree segments
var a:Number = 0.268; // tan(15)
for (var i=0; i < endx =" r1*Math.cos((i+1)*30*TO_RADIANS);" endy =" r1*Math.sin((i+1)*30*TO_RADIANS);" ax =" endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS);" ay =" endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS);" i="0;" endx =" r2*Math.cos((i+1)*30*TO_RADIANS);" endy =" r2*Math.sin((i+1)*30*TO_RADIANS);" ax =" endx+r2*a*Math.cos(((i+1)*30-90)*TO_RADIANS);" ay =" endy+r2*a*Math.sin(((i+1)*30-90)*TO_RADIANS);" _x =" x;" _y =" y;" array =" [0," array =" [100," array =" [0," object =" {a:300,">

Using a shape with a cutout as a mask

If a shape containing a cutout is to be used as a mask, as the donut on the right above, care must be taken to draw the cutout in the opposite direction from that in which the original shape was drawn. (If you don't, there will be no cutout in the mask). Here's the code for the donut mask on the right, in which a big circle is drawn in a clockwise direction and a smaller circle drawn in the opposite direction (all before the endFill is applied). pic is a movieclip containing the flower graphic.

// r1 = radius of outer circle
// r2 = radius of inner circle (cutout)
// x, y = center of donut
// This creates a donut shape that can be used as a mask
MovieClip.prototype.drawDonut2 = function (r1, r2, x, y) {
var TO_RADIANS:Number = Math.PI/180;
this.moveTo(0, 0);
this.lineTo(r1, 0);

// draw the 30-degree segments
var a:Number = 0.268; // tan(15)
for (var i=0; i < endx =" r1*Math.cos((i+1)*30*TO_RADIANS);" endy =" r1*Math.sin((i+1)*30*TO_RADIANS);" ax =" endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS);" ay =" endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS);" i="12;"> 0; i--) {
var endx = r2*Math.cos((i-1)*30*TO_RADIANS);
var endy = r2*Math.sin((i-1)*30*TO_RADIANS);
var ax = endx+r2*(0-a)*Math.cos(((i-1)*30-90)*TO_RADIANS);
var ay = endy+r2*(0-a)*Math.sin(((i-1)*30-90)*TO_RADIANS);
this.curveTo(ax, ay, endx, endy);
}

this._x = x;
this._y = y;
}
createEmptyMovieClip("d2", 2);
d2.beginFill(0xaa0000, 60);
d2.drawDonut2(86, 36, 300, 94);
d2.endFill();
pic.setMask(d2);


courtesy : Flash-Creation

Monday, December 31, 2007

REFLECTION TEXT EFFECT

Reflection Text Effect
************************

In action script, This is Reflection [mirror] effect

how to do this effect?

Wat are the Propery to need ......

Blur x
Blur Y
Distance X
Distance Y
StartingPosition X
EndingPosition X


create a EmptyMovie clip and store into the arrayHolder
and for current movie to create a TExtField
and assign the value to given user text

after that split the text and put into ArrayHolder...

collect the load text movieclip
so that we use for .. loop to to get movieclip to Holder.

and make the text as embed Text


Here,.. the code....

function clipone ()
{
RefHolder = new Array ();
var RefArrTxt:Array = new Array ();
RefArrTxt = EffectContent.split ('');
_root.Effect_mc.createEmptyMovieClip ('Reflect',1);

var Refclips:MovieClip = _root.Effect_mc.Reflect;
for (var i = 0; i < RefArrTxt.length - 1; i++)
{
Refclips.createEmptyMovieClip ('refmc' + i,i);

var reflec = Refclips.createEmptyMovieClip ('refmc' + (RefArrTxt.length + i), RefArrTxt.length + i);
var reffmt:TextFormat = new TextFormat ();
reffmt.font = 'Style1';
reffmt.bold = true;
Refclips['refmc' + i].createTextField ('txt',1,0,0,10,10);
Refclips['refmc' + i].txt.autoSize = true;
Refclips['refmc' + i].txt.text = RefArrTxt[i];
Refclips['refmc' + i].count = i;
Refclips['refmc' + i].txt.embedFonts = true;
Refclips['refmc' + i].txt.setTextFormat (reffmt);


reflec.createTextField ('txt',1,0,0,10,10);
reflec.txt.autoSize = true;
reflec.txt.text = RefArrTxt[i];
reflec.count = i;
reflec.txt.embedFonts = true;
reflec.txt.setTextFormat (reffmt);

if (i == 0)
{
Refclips['refmc' + i]._x = _root.Ref.sp_x.text
Refclips['refmc' + i]._y = _root.Ref.sp_y.text;
reflec._x = Refclips['refmc' + i]._x+Number(_root.Ref.distx.text);
reflec._y = Refclips['refmc' + i]._y + Number(_root.Ref.disty.text);
}
else
{
Refclips['refmc' + i]._x = Refclips['refmc' + (i - 1)]._x + 10;
Refclips['refmc' + i]._y = _root.Ref.sp_y.text ;
reflec._x = Refclips['refmc' + i]._x + Number(_root.Ref.distx.text);;
reflec._y = Refclips['refmc' + i]._y + Number(_root.Ref.disty.text)
trace(_root.Ref.sp_y.text + _root.Ref.disty.text+' :: '+_root.Ref.sp_y.text+' : '+_root.Ref.sp_y.text)
}
reflec._yscale = -100;
reflec._alpha = 30;

RefHolder.push (Refclips['refmc' + i]);
// Reflec._x = _root.Ref.distx.text



_root.Ref.blurx.enabled = true
var blurText = new Tween (reflec, "blur", null, 0, _root.Ref.blury.text, 3, true);
blurText.onMotionChanged = function (ev:Object)
{
ev.obj.filters = [new BlurFilter (ev.obj.blur, ev.obj.blur, 3)];
};
blurText.onMotionFinished = function ()
{
trace ('s! ompleted the Motion');
};
}
pos = 100;

var pos:Number = 0;

}

function reflect ()
{
_root.Effect_mc.createEmptyMovieClip ('Ref',1);
_root.Effect_mc.Ref.createTextField ('Reftxt',1,_root.Ref.sp_x.text,_root.Ref.spy.text,_root.Ref.ep_x.text,_root.Ref.ep_y.text);
_root.Effect_mc.Ref.Reftxt.autoSize = true;
var textFmt:TextFormat = new TextFormat ();
textFmt.font = "style1";
textFmt.bold = true;
_root.Effect_mc.Ref.Reftxt.text = _root.gettxt.text;
trace (_root.Effect_mc.Ref.Reftxt.text + ' : input value');
_root.Effect_mc.Ref.Reftxt.embedFonts = true;
_root.Effect_mc.Ref.Reftxt.setTextFormat (textFmt);

}

call this function to the button click

clipone ()

have a gr8ful to u

Drop Shadow Text Effect

In ActionScript DropShadow Text Effect

using this u have to import the Filter

import flash.filters.DropShadowFilter;

and then,
some property item to be given here..

Distance
Angle
Color
Alpha
Blur X
Blur Y
Strength
Quality
Inner
KnockOut
Hide Object

here code...


var myDropShadowFilter = new DropShadowFilter (5,65,0xff3333,1,5,10,2,3,false,true,false);

after that assign this effect to the movie clip

Es.filters = [myDropShadowFilter];


Now, the DropShadow effect is applied to ur Movie Clip


here, the complete code..


import flash.filters.DropShadowFilter;
var myDropShadowFilter = new DropShadowFilter (5,65,0xff3333,1,5,10,2,3,false,true,false);
Es.filters = [myDropShadowFilter];


Have a gr8ful to u...

Tuesday, December 25, 2007

Dynamic Remove Image

Dynamic Remove Image

Load the image via XML file

Make the action script enable the first Child

Then, load the images to the movie

Get the loops statement count the no. of image and place holder to the

Movie clip Container.

After the make all movie clip to link as button and perform the operation

to remove the images from the container.

Here the code….

var myxml:XML = new XML();

myxml.ignoreWhite = true;

myxml.load('list.xml');

myxml.onLoad = function(success) {

////trace(this+newline+'successful loaded the Xml file');

loadimage();

};

// Create a function loadimage

function loadimage()

{

var pic_array:Array = new Array();

//pic_array.sort()

for (var x in myxml.idMap)

{

var xmlnode = myxml.idMap[x];

pic_array.push({id:x,link:xmlnode.attributes.link,captiontext:xmlnode.attributes.captiontext});

}

////trace(newline+pic_array + newline+ '** Array vlaue ' );

////trace(newline+' Array length : ' + pic_array.length )

for(var i=0;i

{

this.createEmptyMovieClip('s'+i,i);

this['s'+i].createEmptyMovieClip('s1',1)

this['s'+i].createTextField('txt',2,8,55,50,25)

this['s'+i].txt.text=pic_array[i].id;

temp.push(this['s'+i])

//this['s'+i].x = i*60

//this['s'+i].y = i*i

var stgwid = this._width

////trace(newline + ' stage width : '+ stgwid)

var imagewid = 50

var gap = 5

var locate = (stgwid /(imagewid + gap))

this['s'+i].pos= (i%25)

////trace(this['s'+i].pos + ' position value')

////trace(locate + ' : locate value of position ' )

this.mc0 = 10

this.mc1 = 10

this.mc2 = 10

this.mc3 = 10

this.mc4 = 10

this.mc5 = 10

this.mc6 = 10

this.mc7 = 10

this.mc8 = 10

this.mc9 = 10

this.mc10 = 10

this.mc11 = 10

this.mc12 = 10

this.mc13 = 10

this.mc14 = 10

this.mc15 = 10

this.mc16 = 10

this.mc17 = 10

this.mc18 = 10

this.mc19 = 10

this.mc20 = 10

this.mc21 = 10

this.mc22 = 10

this.mc23 = 10

this.mc24 = 10

var mcloader:MovieClipLoader = new MovieClipLoader()

var listner:Object = new Object()

listner.onLoadInit =function(target:MovieClip)

{

////trace(target + newline + ' Target listed ' )

target._width = 50

target._height = 50

target._x = 5

target._y = 5

//locate = target._parent.pos

switch(target._parent.pos)

{

case 0:

target._parent._x=370;

target._parent._y=80;

target._parent._y+=60

break;

case 1:

target._parent._x = 310;

target._parent._y = 80

target._parent._y+=60

break;

case 2:

target._parent._x = 250

target._parent._y = 80

target._parent._y+=60

break;

case 3:

target._parent._x =190

target._parent._y = 80

target._parent._y+=60

break

case 4:

target._parent._x = 130

target._parent._y = 140

_parent._parent._y+=60

break

case 5:

target._parent._x = 70

target._parent._y = 80

target._parent._y+=60

break

case 6:

target._parent._x = 10

target._parent._y = 80

target._parent._y+=60

break

case 7:

target._parent._x = 490

target._parent._y = 15

target._parent._y+=60

break

case 8:

target._parent._x = 430

target._parent._y = 15

target._parent._y+=60

break

case 9:

target._parent._x = 370

target._parent._y = 15

target._parent._y+=60

break

case 10:

target._parent._x = 310

target._parent._y = 15

target._parent._y+=60

break

case 11:

target._parent._x =250

target._parent._y =15

target._parent._y+=60

break

case 12:

target._parent._x =190

target._parent._y =15

target._parent._y+=60

break

case 13:

target._parent._x = 130

target._parent._y = 15

target._parent._y+=60

break

case 14:

target._parent._x =70

target._parent._y =15

target._parent._y+=60

break

case 15:

target._parent._x = 10

target._parent._y = 15

target._parent._y+=60

break

case 16:

target._parent._x = 490

target._parent._y = target._parent._parent.mc16

target._parent._parent.mc16+=60

break

case 17:

target._parent._x = 430

target._parent._y = target._parent._parent.mc17

target._parent._parent.mc17+=60

break

case 18:

target._parent._x = 370

target._parent._y = target._parent._parent.mc18

target._parent._parent.mc18+=60

break

case 19:

target._parent._x = 310

target._parent._y = target._parent._parent.mc19

_parent._parent.mc19+=60

break

case 20:

target._parent._x = 250

target._parent._y = target._parent._parent.mc20

_parent._parent.mc20+=60

break

case 21:

target._parent._x = 190

target._parent._y = target._parent._parent.mc21

target._parent._parent.mc21+=60

break

case 22:

target._parent._x = 130

target._parent._y = target._parent._parent.mc22

target._parent._parent.mc22+=60

break

case 23:

target._parent._x = 70

target._parent._y = target._parent._parent.mc23

target._parent._parent.mc23+=60

break

case 24:

//trace(' Enter the 1st Image'+ newline )

target._parent._x = 10

target._parent._y = target._parent._parent.mc24

target._parent._parent.mc24+=60

break;

}

target._parent.onPress=function(){

this.removeMovieClip();

_root.position_clips(this._parent)

}

}

//trace('id : ' +pic_array[i].id );

mcloader.addListener(listner)

//trace(pic_array[i]+newline + 'image loaded ')

mcloader.loadClip(pic_array[i].link.toString(),this['s'+i].s1)

}

}

function position_clips(_mov:MovieClip){

var posx=0

var posy=0

var count:Number=0;

for(var i in _root){

if(_root[i] instanceof MovieClip){

if(count!=0){

posx+=_root[i]._width+10

}

count++

if((Stage.width-50)-posx<0){

posy+=60

posx=0

}

_root[i]._x=posx;

_root[i]._y=posy;

}

}

}

function deleteImage(mc:MovieClip,wid:Number,hei:Number,posx:Number,poxy:Number)

{

mc._width = wid

mc._height = hei

mc.onRelease = function()

{

var pos = this._width - this.wid

}

}

Here the o/p:






Dynamic Rotate

Load Image from Xml and Make Rotate

Screen View:

Code View

output View
Here the Code:

Here the code:

import mx.transitions.Tween;

var xml:XML=new XML()

xml.ignoreWhite=true

xml.onLoad=function(s){

if(s){

_root.bg.createEmptyMovieClip('image',1)

_root.bg.image.createEmptyMovieClip('rose',2)

var mcLoader:MovieClipLoader=new MovieClipLoader()

var listener:Object=new Object()

listener.onLoadInit=function(target:MovieClip){

target._width=150

target._height=150

target._x=-75

target._y=-75

target._parent._x=150

target._parent._y=150

}

mcLoader.addListener(listener)

mcLoader.loadClip(xml.firstChild.firstChild.firstChild.firstChild.toString(),_root.bg.image.rose)

}

}

xml.load('load.xml')

clicker_fw.onPress=function(){

var twe=new Tween(_root.bg.image,'_rotation',null,0,360,10,true)

_root.bg.image._rotation=90

}

clicker_rw.onPress=function(){

var twe=new Tween(_root.bg.image,'_rotation',null,360,0,10,true)

_root.bg.image._rotation=90

}




Wahat is the package animate object smooth for Tween class ?