hi all
i'm trying to cut down on code by putting it into a function with
several arguements and calling it with different arguements but i
don't seem to be able to get a different result with the second version
it may be easier to understand with the code:
//import the tween class
import mx.transitions.Tween;
import mx.transitions.easing.*;
function background (section):Void {
//set up common features
var initObject:Object = new Object;
initObject._width = 0;
initObject._y = 0;
initObject._alpha = 90;
//common actions put into a function and variables passed
function thisBackground (thisName, thisX, thisColour, thisDepth) {
initObject._x = thisX;
_root.attachMovie("box_mc", thisName, thisDepth, initObject);
var boxColour:Color = new Color(_root[thisName]);
boxColour.setRGB(thisColour);
}
//logic to determine section
if (section == "home") {
thisBackground ("homeBox_mc", 150, "0x9d9789",
1000);
// creates a single tweened panel correctly
var thisTween:Object = new Tween (homeBox_mc, "_width",
Strong.easeOut, 0, 425, 2, true);
} else if (section == "designer") {
thisBackground ("designerBox_mc", 150, "0xbcb6a7",
1000);
// creates the first panel correctly
var thisTween:Object = new Tween (designerBox_mc, "_width",
Strong.easeOut, 0, 200, 2, true);
thisTween.onMotionFinished = function() {
thisBackground ("designerBox_2_mc", 350, "0xd5cfc0",
2000); // c
reates the second panel with the settings from the first panel (not
these)
var thisTween:Object = new Tween (designerBox_mc, "_width",
Strong.easeOut, 0, 225, 2, true);
};
}
}
//run the function with the incorrectly working section
background ("designer");
because the thisBackground function isn't picking up the correct
values (but keeping the older ones), it is overwriting the first
panel with the second one
hope you can help
ABE
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com