# Functions: Parameters

**URL:** <https://forum.kirupa.com/t/functions-parameters/183570>\
**Category:** flash\
**Created:** [March 28, 2006, 12:19pm UTC](https://forum.kirupa.com/t/functions-parameters/183570 "2006-03-28T12:19:18Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 28, 2006, 12:19pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/1 "2006-03-28T12:19:18Z")

</div>

[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

---

<div class="post-metadata">

**Author:** ![kookaburra](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@kookaburra](https://forum.kirupa.com/u/kookaburra)\
**Post date:** [March 28, 2006, 12:35pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/2 "2006-03-28T12:35:49Z")

</div>

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;

}

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 28, 2006, 1:25pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/3 "2006-03-28T13:25:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [March 28, 2006, 5:20pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/4 "2006-03-28T17:20:27Z")

</div>

[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. 🙂

---

<div class="post-metadata">

**Author:** ![Thinker2501](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thinker2501](https://forum.kirupa.com/u/Thinker2501)\
**Post date:** [March 28, 2006, 6:16pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/5 "2006-03-28T18:16:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 30, 2006, 8:16am UTC](https://forum.kirupa.com/t/functions-parameters/183570/6 "2006-03-30T08:16:25Z")

</div>

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!?

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.kirupa.com/u/Dhiraj)\
**Post date:** [March 30, 2006, 8:58am UTC](https://forum.kirupa.com/t/functions-parameters/183570/7 "2006-03-30T08:58:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 30, 2006, 11:23am UTC](https://forum.kirupa.com/t/functions-parameters/183570/8 "2006-03-30T11:23:01Z")

</div>

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;  
}

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://forum.kirupa.com/u/Dhiraj)\
**Post date:** [March 30, 2006, 2:25pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/9 "2006-03-30T14:25:56Z")

</div>

Here it goes …  
arrNames = [“steve\_biog.swf”, “danny\_biog.swf”, “tanny.swf”];

function scrollItBackBiog(refName) {  
//…  
\_root.biog\_cntr.loadMovie(refName);  
//…  
}

scrollItBackBiog(arrNames[0]);

Dhiraj

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 30, 2006, 3:30pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/10 "2006-03-30T15:30:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [March 30, 2006, 5:25pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/11 "2006-03-30T17:25:37Z")

</div>

> [@Claire\_murphy](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [March 31, 2006, 9:50am UTC](https://forum.kirupa.com/t/functions-parameters/183570/12 "2006-03-31T09:50:45Z")

</div>

> [@Dhiraj](#):
>
> Here it goes …  
> arrNames = [“steve\_biog.swf”, “danny\_biog.swf”, “tanny.swf”];
> 
> function scrollItBackBiog(refName) {  
> //…  
> \_root.biog\_cntr.loadMovie(refName);  
> //…  
> }
> 
> scrollItBackBiog(arrNames[0]);
> 
> Dhiraj

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.

---

<div class="post-metadata">

**Author:** ![Claire\_murphy](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Claire\_murphy](https://forum.kirupa.com/u/Claire_murphy)\
**Post date:** [April 3, 2006, 1:06pm UTC](https://forum.kirupa.com/t/functions-parameters/183570/13 "2006-04-03T13:06:11Z")

</div>

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

Thanks for all your help!
