Reputation: 45
i try to make a function like this:
function splashlafadz(obj:MovieClip):void{
var varsplash1 = new TimelineMax({delay:3});
varsplash1.to(obj, 1, {alpha:100, x:427.85, y:208.90, ease:Back.easeOut, delay:1});
varsplash1.to(obj, 1,{visible:false, delay:3});
}
then, i have a movieclip named splash1..how can i apply that function to splash1? i try to use
splashlafadz.call(splash1);
but it getting error.. how can i use the function to be used with a different movieclip?
Can I make a sound a parameter??so each of movieclip have a different sound?
Upvotes: 0
Views: 87
Reputation: 6751
You can just add another parameter to pass the sound you'd like to use :
function splashlafadz(obj:MovieClip, sound:Sound):void{
var varsplash1 = new TimelineMax({delay:3});
varsplash1.to(obj, 1, {alpha:100, x:427.85, y:208.90, ease:Back.easeOut, delay:1});
varsplash1.to(obj, 1,{visible:false, delay:3});
sound.play();
}
Then you just call it like so :
splashlafadz(yourObject, yourSound);
Upvotes: 1
Reputation: 6621
To call a function you can just use the function name directly, like this: splashlafadz(splash1)
.
The call
function is required when you want to change the this
object, it's quite likely you won't ever need it. There's some thorough documentation on MDN right here: Function.prototype.call
. (This reference is for JavaScript, but it works the same way as Action Script).
Upvotes: 0