Functions: Parameters

[COLOR=black]At the moment I have this function:[/COLOR]

this.biog_photos.[COLOR=blue]onRelease[/COLOR] = [COLOR=blue]function/COLOR {
[COLOR=red]scrollItBackBiog/COLOR;
}
[COLOR=blue][/COLOR]
[COLOR=blue]function[/COLOR] [COLOR=red]scrollItBackBiog/COLOR {
_root.container3._alpha = 100;
_root.container3.alphaTo(0, .4, “easeOutCubic”);
_root.container2.PAGE.SUB.tween("_x", 362, 1, “easeOutCubic”, 0.5);
_root.container2.PAGE.tween ("_x", 307, 1, “easeOutCubic”, 0.5);
_root.btns_container.alphaTo(100, 1, “easeOutCubic”, 1);
_root.biog_cntr._alpha = 0;
**_root.biog_cntr.loadMovie([COLOR=blue]“steve_biog.swf”[/COLOR]);
** _root.biog_cntr.alphaTo(100,2,“easeOutCubic”,1);
_root.container2.btns_mc.alphaTo(100,1,“easeOutCubic”, 1);
_root.container2.back_btn._alpha = 0;
_root.container2.caption._alpha = 0;
}

It all works great but I need this function written about 18 times, each time loading a different SWF file (SEE BOLD). Instead of writing this code that many times I gather by using parameters I can reference each file then call it when needed!?
[COLOR=black][/COLOR]
[COLOR=black]Is it as simple as defining each SWF as A = steve_biog.swf, B = danny_biog.swf, C, D etc? Not sure what goes where in order to call it correctly! Any help please[/COLOR]

Claire

define an array like

swfArray = [“steve_biog.swf”, “danny_biog.swf”, “tanny.swf” … and so on]

and call the function with the parameter. e.g. if you want to call this function for 12 times for 12 swfs,

write

for(i=0;i<12;i++){
scrollItBackBiog(swfArray
);
}
*

Also, define the function as …

function scrollItBackBiog(swfName:String){
_root.container3._alpha = 100;
_root.container3.alphaTo(0, .4, “easeOutCubic”);
_root.container2.PAGE.SUB.tween("_x", 362, 1, “easeOutCubic”, 0.5);
_root.container2.PAGE.tween ("_x", 307, 1, “easeOutCubic”, 0.5);
_root.btns_container.alphaTo(100, 1, “easeOutCubic”, 1);
_root.biog_cntr._alpha = 0;
_root.biog_cntr.loadMovie(swfName);
_root.biog_cntr.alphaTo(100,2,“easeOutCubic”,1);
_root.container2.btns_mc.alphaTo(100,1,“easeOutCub ic”, 1);
_root.container2.back_btn._alpha = 0;
_root.container2.caption._alpha = 0;

}

eeeekkkk. Over my head. Any simpler way of describing whats going on with that code?

[AS]swfArray = [“steve_biog.swf”, “danny_biog.swf”, “tanny.swf”][/AS]Defines all of the movieclip names.

[AS]
for(i=0;i<12;i++){
scrollItBackBiog(swfArray*);
}[/AS]calls the function, passing each string in swfArray. It would recieve steve_biog.swf, danny_bio.swf, etc.
[AS]
function scrollItBackBiog(swfName:String){[/AS]variable swfName is recieved as a String.[AS]
_root.container3._alpha = 100;
_root.container3.alphaTo(0, .4, “easeOutCubic”);
_root.container2.PAGE.SUB.tween("_x", 362, 1, “easeOutCubic”, 0.5);
_root.container2.PAGE.tween ("_x", 307, 1, “easeOutCubic”, 0.5);
_root.btns_container.alphaTo(100, 1, “easeOutCubic”, 1);
_root.biog_cntr._alpha = 0;
_root.biog_cntr.loadMovie(swfName);
_root.biog_cntr.alphaTo(100,2,“easeOutCubic”,1);
_root.container2.btns_mc.alphaTo(100,1,“easeOutCub ic”, 1);
_root.container2.back_btn._alpha = 0;
_root.container2.caption._alpha = 0;
}[AS]Everything remains the same except for [AS]_root.biog_cntr.loadMovie(swfName);[/AS]which loads the mc passed to the function.

Hope it makes sense. :slight_smile:

Do you want to call it 18 times in a row, or have 18 buttons and each button calls that function once? The above comments are assuming you want to call it 18 consecutive times before the SWF does ANYTHING else. Please advice and we can give further advice.

Ahhh I C. Basically I have a page on my site that contains 18 staff members and when the user clicks on a picture the page slides in with their biography on it. So I dont want it called consecutively…just want the code to be written once and depending on whose clicked the code brings in the relevant swf.

Does that make more sense!?

From above conversation, what I see is u r solution is pretty simple …
Create an array

arrNames = [“steve_biog.swf”, “danny_biog.swf”, “tanny.swf” … and so on]

Now each element(Person’s Name) in the array is associated to person and the Index with it.

Then on click of a person’s image call function with parameter arrNames[x]
where x is Index associated with a Person.

for instance if u want to load steve_biog.swf then call
scrollItBackBiog(arrNames[0]) ;

for danny_biog.swf call
scrollItBackBiog(arrNames[1]) ;

and so on…

Dhiraj

I’m almost understanding it. What I dont follow is where the code goes!
e.g. what goes in place of the bold text here?!

function scrollItBackBiog() {
_root.container3._alpha = 100;
_root.container3.alphaTo(0, .4, “easeOutCubic”);
_root.container2.PAGE.SUB.tween("_x", 362, 1, “easeOutCubic”, 0.5);
_root.container2.PAGE.tween ("_x", 307, 1, “easeOutCubic”, 0.5);
_root.btns_container.alphaTo(100, 1, “easeOutCubic”, 1);
_root.biog_cntr._alpha = 0;
[COLOR=“Red”]_root.biog_cntr.loadMovie(“steve_biog.swf”);[/COLOR]
_root.biog_cntr.alphaTo(100,2,“easeOutCubic”,1);
_root.container2.btns_mc.alphaTo(100,1,“easeOutCub ic”, 1);
_root.container2.back_btn._alpha = 0;
_root.container2.caption._alpha = 0;
}

Here it goes …
arrNames = [“steve_biog.swf”, “danny_biog.swf”, “tanny.swf”];

function scrollItBackBiog(refName) {
//…
_root.biog_cntr.loadMovie(refName);
//…
}

scrollItBackBiog(arrNames[0]);

Dhiraj

Forgive me for being dense, but thank you so far, however…does this not still require me to have the function written 18 times each time referencing each person? Thats what I make of it! But as i’m new to Flash I could be misunderstanding what you are saying.

No you do not have to write it 18 times, only once. The function is performing the same task but with different parameters each time.

By (refName) am I meant to actually put ‘refName’ or reference the name of the file i’m calling? Perhaps that sounds stupid but i want to understand the code fully.

A fresh look after the weekend and I finaly got it! =)

Thanks for all your help!