Dynamically assigning functions to mcs onPress

Hi all,

I am trying to work out the logistics/structure of writing general ‘action’ functions (ie, move, scale, etc) and then assigning those functions to different mcs depending on what is currently ‘in focus’.

Here is the code that illustrates my current thinking. It is general, and not specific! In kirupa style, I will highlight each line to express my thinking, so that you can better provide me with feedback.


function fadeOut(mc) {
    if ((mc).width >= 50) {
        --(mc)._width;
        --(mc)._height;
    } else {
        //DO NOTHING
    }
}

function fadeIn() {
}
function zoomIn() {
}
function zoomOut() {
}

onEnterFrame = function() {
    if (homeScreen == true) {
    btnDown.onPress = fadeOut(mc_home) = fadeIn(mc_contacts);
    } else if (contactsScreen == true) {
        btnDown.onPress = zoomIn(mc_people) = zoomOut(mc_numbers);
    }
}

This is an example of an action function that I want to work with mcs.


function fadeOut(mc) {
    if ((mc).width >= 50) {
        --(mc)._width;
        --(mc)._height;
    } else {
        //DO NOTHING
    }
}

Is this how I get it to [COLOR=Red]receive an mc?[/COLOR]


function fadeOut[COLOR=Red]**(mc)**[/COLOR] {

And how do I reference the mc afterwards, [COLOR=Red]like this?[/COLOR]


function fadeOut[COLOR=Red](mc)[/COLOR] {
     if ([COLOR=Red](mc)[/COLOR].width >= 50) {

More action functions, to be filled in later.


function fadeIn() {
}
function zoomIn() {
}
function zoomOut() {
}

Here is how I am checking for button presses. Seems pretty straight forward.


onEnterFrame = function() {

Here is how I am checking to see what is ‘in focus’.


    if (homeScreen == true) {

Here is where I am also confused, how do I get an mc to work with the action functions? Can I have two functions working on one mc at the same time? Is this even the right ‘[COLOR=Red]high level’ structure[/COLOR] that I should be using for this task, let alone [COLOR=DarkOrange]correct syntax?[/COLOR]


    [COLOR=Red]btnDown.onPress = fadeOut(mc_home)[/COLOR][COLOR=DarkOrange] = fadeIn(mc_contacts);[/COLOR]

This is the same as the above code, just working with different functions and mcs.


    } else if (contactsScreen == true) {
        btnDown.onPress = zoomIn(mc_people) = zoomOut(mc_numbers);
    }
}

I will potentially have close to 50 mcs that I will have to work with, and maybe 20 ‘action’ functions. So I wanted to make sure that I have the basics down, then I can just rinse and repeat. Anything else I am not considering?

Thanks to anyone who can lend some clarity,

Nick