View Full Version : running functions
Dhryn
November 10th, 2006, 09:21 AM
I know how to write and use a function, but the problem is that it is only rn once. e.g.
function runningAllTheWay(){
//code
}
I want it to have an onEnterFrame property but with the usage of the normal function. somthing like
function somethingLike(){
onEnterFrame = function(){
//run code for 20 frames
}
}
Problem is that I dont know how to write this properly, if some one could help it would be greatly appreciated.
Joppe
November 10th, 2006, 03:01 PM
Why not have,
n=0;
somethingLike = function(){
if(n<20){
somethingLike();
}
n++;
}
Dhryn
November 10th, 2006, 04:04 PM
I tried something like that and it over loaded the computer, might have typed it badly tho, thankyou for your help.
SacrificialLamb
November 10th, 2006, 04:26 PM
could try some thing like this. i don't know if you need the this. before the onEnterFrame
function somethingLike() {
n = o;
onEnterFrame = function () {
//code here
if (20<n++) {
delete(this.onEnterFrame);
}
//or code here
};
}
Dhryn
November 10th, 2006, 04:37 PM
I have tried the following code:
var fadingDeathNum = 0;
function fadingDeath(target){
if(fadingDeathNum<10){
this[target]._alpha -= 10;
fadingDeathNum++;
fadingDeath(target);
}else{
fadingDeathNum = 0;
removeMovieClip(target);
}
}
I am running at 20 frames per second, I am trying to reduce the alpha to 0 and then remove the movie clip.
However, this seems to just remove the movie clip.
Any ideas on how I can get this to work?
SacrificialLamb
November 10th, 2006, 04:50 PM
have you tried
target._alpha -= 10;
or the twee class
import mx.transitions.Tween;
Tween(target, "_alpha", mx.transitions.easing.None.easeNone,0, 100, 50, false);
Dhryn
November 10th, 2006, 05:00 PM
could you explain them to me in a bit more detail plz, I havent seen them before.
Thankyou for your quick reply
SacrificialLamb
November 10th, 2006, 05:20 PM
import mx.transitions.Tween;
function fadingDeath(target){
removeMovieClip(target);
var ialpha:Tween = new Tween(target, "_alpha", Regular.easeIn, 100, 00, 1, true);
ialpha.onMotionFinished = function() {
removeMovieClip(target);
};
}
thing.onRelease = function () {
fadingDeath(this)
}
there is more help in... will help under "Using the Tween class" i find the best way to get to it in a search is by searching "import mx.transitions.Tween;"
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.