|
alpha decrease and remove object
MovieClip.prototype.znikaj = function(spid) {
this.spid = spid;
this.onEnterFrame = function() {
this._alpha -= spid;
if (this._alpha<0) {
this._visible = 0;
delete (this.onEnterFrame);
}
};
};
//call:
my_clip.onRelease = function() {
this.znikaj(5);
};
Posted by: skydance | website http://www.skydance.pl |
// you can do a few variations with this one ie.
//changing MC properties,IE. scale,position etc...
//Its a simple one.. maybe useful.
onClipEvent (load) {
this._alpha = 100;
end_alpha = 0;
}
onClipEvent (enterFrame) {
current_alpha = this._alpha;
diff__alpha = end_alpha-current_alpha;
movex = diff__alpha/2;
this._alpha = this._alpha+movex;
}
Posted by: mako | website http://www.cyberzoo.co.za/mako |
/* ...place this analog preloader script on a movieClip on frame 1, your main movie should start on frame 2 (_root), have fun...
Please note, I have written two slightly different turn functions for you to chose from. */
onClipEvent (load) {
//in the beginning, stop the _root movie until the preloader is done
_root.stop();
deg = 180;
//180 degree analogue gage, try out 360
for (i=0; i<=100; i++) {
//draw 101 lines of the face. Using modulo to draw the different sized lines. 1 line for each percent.
this.createEmptyMovieClip("lin_"+i, 100+i);
//create a new movie Clip for each line
this["lin_"+i]._rotation = i*deg/100;
//turn, rotate each movie/line depending on degree
if (i%5) {
//If the percent value is dividable by 5 than modulo (the rest of the division) returns 0=false, no rest.
//Otherwise (if there is a rest) draw the short 1 percent lines.
with (this["lin_"+i]) {
lineStyle(1, "0x666666", 100);
moveTo(-220, 0);
lineTo(-210, 0);
}
} else if (i%10) {
//if not dividable by 10 than draw the 5 percent line
with (this["lin_"+i]) {
lineStyle(2, "0x666666", 100);
moveTo(-220, 0);
lineTo(-205, 0);
}
} else if (i%50) {
//if not dividable by 50 than draw the 10 percent line
with (this["lin_"+i]) {
lineStyle(3, "0x666666", 100);
moveTo(-220, 0);
lineTo(-200, 0);
}
} else {
//else draw the thick 0,50,100 percent marking lines, one could add static text fields displaying these digits ...
with (this["lin_"+i]) {
lineStyle(4, "0x666666", 100);
moveTo(-220, 0);
lineTo(-190, 0);
}
}
}
//drawing the pointer of the gauge. Of course you could go ahead and insert a new movie instance, with the instance name "pointer" to draw a fancy pointer.
this.createEmptyMovieClip("pointer", 666);
with (this.pointer) {
lineStyle(5, "0x666666", 100);
lineTo(-250, 0);
}
// turn the percentage pointer depending on the bytes loaded / bytes total of the movie
b_total = _root.getBytesTotal();
// Two versions of the turn function:
// the first version turns the pointer smoothly no matter how many bytes are actually loaded.
// good in case you got a small pre movie animation which you want to make sure that it is showing no matter if you got a fast cable/dsl or a slow dial up connection
// if lets say the frame rate of the document is set to 20 frames per second than this preloader is going to run at least for the duration of 18 seconds or 360 frames because the pointer is advancing 0.5 degree each frame
// also the pointer always starts at 0 degree no matter how many bytes, percentage of the movie it takes for the preloader gage to shows up.
function turn() {
b_loaded = _root.getBytesLoaded();
if (advance == deg) {
this.pointer._rotation = advance;
//preloader done, play the main movie starting on frame 2 _root
_root.gotoAndPlay(2);
} else {
ratio = (b_loaded/b_total)*deg;
this.pointer._rotation = advance;
if (advance<ratio) {
//advance the pointer only if more bytes are loaded
advance += .5;
}
}
}
// in the second version of the turn function the pointer shows the actual loaded percentage
// the main movie plays immediately whenever 100% loaded
// here you might want to display the variable named "percent" in a dynamic text field showing the actually loaded percentage digitally next to the analog gage
/*
function turn() {
b_loaded = _root.getBytesLoaded();
if (ratio == deg) {
_root.gotoAndPlay(2);
} else {
_root.percent = parseInt((b_loaded/b_total)*100);
ratio = (b_loaded/b_total)*deg;
this.pointer._rotation = ratio;
}
}
*/
}
onClipEvent (enterFrame) {
// turn, pulsed by the document frame rate, 2004 by www.advance-media.com
turn();
}
Posted by: Folko Langner | website http://www.advance-media.com |
/*Often ennough I'm asked how a user can make some sort of transitional animation
before jumping to a new scene. Today someone asked how they can make a little clip
animate off the screen before their SWF jumps to a new frame, following a button click.
I came up with the following code responce. Hope it's useful to someone out there.
There are hack ways but the best way (for reuse) is probably to do it in an
entirely scripted manner. Something like:*/
stop();
function slideOutThenJump(targ_mc, targ_x, seconds, label) {
trace("Called slideOut");
// How far away is the target X position?
var diff = targ_x-targ_mc._x;
// How many pixels per second to animate for 'seconds' seconds?
// Assumes a setInterval of 66ms
pxPerInt = Math.ceil((diff/seconds)/15);
_global.animInterval = setInterval(anim, 66, targ_mc, targ_x, pxPerInt, label);
}
function anim(targ_mc, targ_x, pxPerInt, label) {
targ_mc._x += pxPerInt;
if (targ_mc._x>=targ_x) {
clearInterval(_global.animInterval);
_root.gotoAndStop(label);
}
}
slideOutThenJump(_root.test_mc, 200, 1, "myLab");
/*The last line in an example of how to use this script. You provide a reference to the clip you
want to slide, the final _x position you desire, the number of seconds over which the slide
should take place and the label to jump to when the animation is done.*/
Posted by: Jesse Stratford | website http://www.actionscript.org |
//This will generate a coluorful and random colour of text below
text="Hello there my name is Pakcik Kantin"
//First frame
n = 1;
myString = text;
myArray = [];
myArray = new Array();
// myArray = myString.split(",");
// dd=myString.charAt(5);
d = myString.length;
for (i=0; i<=d; i++) {
myArray[i] = "#" add myString.charAt(i);
}
dd = myString.charAt(n);
//Second Frame
myString=text;
myArray =[];
myArray = new Array();
myArray2 =[];
myArray2 = new Array();
transformText="";
transformTextShadow="";
d=myString.length;
for(i=0;i<=d;i++)
{ color=setHEXColor();
myArray[i]= "<font color='#" add color add "'>" add myString.charAt(i) add "</font>";
myArray2[i]= "" add myString.charAt(i) ;
}
for(i=0;i<=d;i++)
{
transformText +=myArray[i];
transformTextShadow +=myArray2[i];
}
function setHEXColor()
{
a=random(99);
b=random(99);
c=random(99);
return a add b add c;
}
Posted by: Pakcik_Kantin | website http://www.sronic.i-p.com |

