PDA

View Full Version : functions??


tinyk
04-02-2004, 12:26 PM
Hi everyone,
I am wanting to learn about functions and variables, etc., but am a little confused. Does anyone have any sites or examples that would be good for me to learn from?

marinesko
04-02-2004, 12:35 PM
Hi this link was posted previously by someone:
http://www.purephotoshop.com/article/86
Looks like a good place to start (I need to learn it myself too!)

Ruben
04-02-2004, 07:14 PM
Well, things aren't that difficult I guess...

When you'd want to store the alpha-value of some movieclip in a variable you'd do something like this:

alphaVar = 50;
somemovieclip._alpha = alphaVar;


If you'd want to create a function that would execute a sequence of actions:

// creating the function:
function doStuff (alphaVar,xVar,yVar){
somemovieclip._alpha = alphaVar;
somemovieclip._x = xVar;
somemovieclip._y = yVar;
}
// assigning the function to, for instance, a button when it's pressed [of course with the parameters filled in, _alpha=50 / _x=20 / _y=100]:
somebutton.onPress = doStuff (50,20,100);


Clear? - Ruben

Billy T
04-02-2004, 07:21 PM
// assigning the function to, for instance, a button when it's pressed [of course with the parameters filled in, _alpha=50 / _x=20 / _y=100]:
somebutton.onPress = doStuff (50,20,100);



are you sure you can do that?

Ruben
04-02-2004, 07:29 PM
Dude, I COMPLETELY SUCK!!

It wouldn't ****in work....:confused:

WHY-OH-WHY? - Ruben

Billy T
04-02-2004, 08:00 PM
it should work I know...

I usually do something like this

// creating the function:
function doStuff (){
somemovieclip._alpha = this.a;
somemovieclip._x = this.x;
somemovieclip._y = this.y;
}
somebutton.a=50;
somebutton.x=20;
somebutton.y=100;
somebutton.onPress = doStuff;

or

somebutton.onPress=function(){
doStuff(1,2,3);
}

why your way doesnt work I dont know but it would certainly make life a lot easier