Hi Rothrock,
[quoted text, click to view] > I don't think you can do this in ActionScript. You are trying to mix runtime
> things like variable concatenation with author time things like defining your
> functions and the two won't mix. I'm unaware of any way to dynamically generate
> AS code.
That would be really a pitty
[quoted text, click to view] > This also seems like a really bad strategy to me ? perhaps there is something
> I'm missing? But if you insert a new variation, then all subsequent variations
> change their names. Meaning that all references to them in the rest of your
> code will be off by one.
well, I don't think will be the case...
I can show you simplified what I have now. I am using 4 test - functions
like this (shortened list just to demonstrate;
effectstotal = 3;
function variation0() {
variationname = "Default";
_root.xch.starttype = 0;
_root.xch.aligntype = 0;
_root.xch.duration = 20;
_root.xch.startXscale = 100;
_root.xch.startYscale = 100;
_root.xch.endXscale = 25;
_root.xch.endYscale = 25;
}
function variation1() {
variationnr = 1;
variationname = "Bypasser";
_root.xch.starttype = 2;
_root.xch.duration = 16;
_root.xch.startXscale = 400;
_root.xch.startYscale = 0;
_root.xch.endXscale = 0;
_root.xch.endYscale = 400;
}
function variation2() {
variationnr = 2;
variationname = "Final countdown";
_root.xch.starttype = 4;
_root.xch.startXscale = 0;
_root.xch.startYscale = 0;
_root.xch.endXscale = 800;
_root.xch.endYscale = 100;
}
function variation3() {
variationnr = 3;
variationname = "Waterfall";
_root.xch.startYscale = 0;
_root.xch.endYscale = 800;
_root.xch.startalpha = 100;
}
according to the total (4 in example) 4 MC's are duplicated and given
numerically named instance names, all containing a button... the button
then have
on (release) {
// reset all variables to default
_parent.variation0.call();
// now do the variation variables from list
_parent.butnr = this._name;
_parent.fx = _parent.butnr.charAt(3);
eval("_parent.variation" add _parent.fx).call();
}
What these buttons basically do is calling function variation0 ()
resetting a base list of variables to default ones and then variation1
() or variation2 () or variation3 () (depending on instance name) to set
a new set of variables/parameters.
This works fine.
But when I need to insert a new set (a new function) inbetween, because
the list is alphabetically then it gets workintensive updating
everything manually
By using a counter n++ I can simply insert a new function anywhere
inbetween but this will need a common
n++;
varfun = "variation" add n;
function varfun() {
..... etc
}
n++;
varfun = "variation" add n;
function varfun() {
..... etc
}
n++;
varfun = "variation" add n;
function varfun() {
..... etc
}
routine since in a for() loop it can't be done... the above way also
facilitates naming of buttons by e.g. using
n++;
"variationname" add n = "Bypasser";
The list of variables comes from a .txt already made and I use a batch
to simply convert the list from .txt to a flash-actionscript text as the
one described above.
Any suggestion?
Kleus