Groups | Blog | Home
all groups > flash actionscript > august 2005 >

flash actionscript : Reseting function parameters


jmh722
8/23/2005 8:51:04 PM
:disgust;

I need to figure out how to reset the function below on the fly so that it has
either one or two parameters based on whether or not the object 'selected'
contains 'mc' and 'fr' ('Movieclip' and 'Frame') or just 'fr'.

'Frame' calls a frame in a loaded swf
'Movieclip' calls an MC in a loaded .swf

In the code below, everything with just 'fr' works fine until a clip that
needs both 'mc' and 'fr' is called. After that, any object using only 'fr' will
stop loading the .swf.

Help please.






//In Main Time Line:

var items = {
b1_mc:{swf:'swf1.swf', fr:1, mc:'SM2118', id:'boot1'},
b2_mc:{swf:'swf2.swf', fr:1, id:'boot2'}
}

var selection:Object = null;


///****Code here would load the swf specified in the object above***

getFrame = function () {

if(this.content_mc || !(selection.mc)){
this.content_mc.myframe(selection.fr)
this.content_mc.gotoAndStop(fr);
}
if(this.content_mc && (selection.mc)){
this.content_mc.myframe(selection.fr, selection.mc);
this.content_mc.gotoAndStop(fr);
}
clearInterval(delay2);
}


//Inside of swf1.swf WITH an 'mc':

function myframe(fr, mc)
{
trace('my frame is ' + fr);
trace('my MC is ' + mc);
this.gotoAndStop(fr);
this[mc].gotoAndStop(2);
}
mandingo
8/23/2005 10:51:25 PM
write your function and test for the number of incoming arguments...


myFunction = function(arg1,arg2){
switch(arguments.length){
case 1:
// do what you need if only frame is received
break;
case 2:
// do what you need to do if you receive both mc and frame
break;
}
}

that is one way...

cheers,
AddThis Social Bookmark Button