Passing instance name to function as a variable

hello friends

the idea is that the site keeps tracks of whatever page is current and passes this variable to the alpha function which will target that movie instance to fade when moving to another page - then that page’s name will be assigned to current.

this is the code that i have now…

#include “alpha.as”
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};

evolution and solo exist in the same timeline…

the hierachy is like this there is a movie called pictures on the root timeline - this contains all the buttons and all the scripts that you see (except the external script for the alpha function) - plus the variable current is declared in it too.

it’s a one frame movie which contains another movie solo which is what i am trying to target when a button is clicked.

any help very much appreciated…

Si

:thumb2:

This would be my best guess but it would help if you posted some more code or even an FLA :cowboy:

#include "alpha.as"
evolution.onRelease = function() {
 this._parent[current].gotoAndPlay(2);
 this._parent[current].alpha(5, 0);
};

wow that seems to have done it - jesus you wouldn’t believe how many friggin combinations of brackets and dots i have tried.

i even tried the target path thing - why the hell didn’t that come up with what you posted?

hmmmm.

another dumb question if my var is declared in the same frame as all this stuff is happening why doesn’t it keep reseting itself? or does it only run once - but not keep looping?

thanks for your help though - that was 2 days of buggering around…

Si

:lol: Glad to help :hoser:

If you declare a variable with the var statement in a function, it is local to that function and is deleted after the function has executed - or is that not what you are asking?

not quite what i asked but still helpful…i think what i am asking is so blindingly obvious you missed it…

now i’ve put it into words i think my question is obsolete…

Si

Oooh after re-reading I think I got it. They aren’t reset because you only enter the frame once so the code is only executeD once. Unless you use a repetative action such as an onEnterFrame event, the code will only execute once :slight_smile: