Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable in path

Status
Not open for further replies.

bugg

Programmer
Jun 20, 2001
62
US
OK, in an effort to streamline the grossly inflated scripting within my .fla, I am trying to employ the use of some variables and functions...

I have the following list of MCs:

_root.icona
_root.iconb
_root.iconc
_root.icond
_root.icone
_root.iconf


they are all draggable MCs, upon crossing a threshold (x=700) a global variable named "homebase" reads a,b,c,d,e,or f indicating the corresponding MC is in position for a given function to be applied. something like this

function stretch () {
_xscale = 200;
gotoAndPlay (2);
}


I would like to set up something that works along these lines but can't get it to work...

onClipEvent (enterFrame) {
_root.icon + homebase +.stretch;
}


any tips on how to make it work? I think the key lies somewhere in getting the variable within the path (I am tracing homebase and it seems to work properly), but I am losing any semblance of patience with it all. Any help would be greatly appreciated.

TIA
bugg
 
If I understand what you're trying to get at (and I'm not certain I do ;-) ) you need a function call more like this...

_root.stretch(homebase);

...which will pass the parameter you're dealing with into the function body for processing. This will also require a bit of alteration to your function itself...

function stretch(homebase){
_root["icon"+homebase]._xscale=200;
gotoAndPlay(2);// or _root["icon"+homebase].gotoAndPlay(2)?
}
 
Wang- it seems to me like you get it ( i like to be as vague as possible...) however let me see if I understand you, so I pass the function stretch variable homebase and then it uses it within the function which was called by the root movie (but if stretch is called by the _root MC, is it necessary to put _root in the function definition? Would it then look for _root._root.["icon"+homebase]?)

thanks
bugg
 
If stretch is already on the _root then you don't have to worry about it in the fuction call - I wasn't sure where your clips were so _root is the safest way to go for generic code (it shouldn't matter if it's in twice though, it's redundant but it's not a code breaker).
 
okay, I am back
wang thanks for your help earlier, I tried practice functions and got them to work, but I still can't get it to work in my main one here... this is what I have:

a button that does
on (press) {
_root.icons.rbicons.away(res,sclocho,tall,photo,ocho);
}

which should (i think) trigger the following functions:
proj = "none";
//ie res,dbd,etc
genre = "none";
//ie pho,drw,etc
thumb = "none";
//ie one,dos,etc
img = "none";
//ie scluno,scld1,etc
shape = "none";
//ie tall, wide, square

function imgshape (shape) {
if (shape == "wide") {
one._width=150;
one._height=120;
}
else if (shape == "tall") {
one._width=120;
one._height=150;
}
else if (shape == "square") {
one._width=120;
one._height=120;
}
}
function btnplace (shape) {
if (shape == "wide") {
btn._x=135;
btn._y=102.5;
}
else if (shape == "tall") {
btn._x=105;
btn._y=132.5;
}
else if (shape == "square") {
btn._x=105;
btn._y=102.5;
}
}
function kllplace (shape) {
if (shape == "wide") {
unokill._x=140;
unokill._y= -490;
}
else if (shape == "tall") {
unokill._x=110;
unokill._y= -490;
}
else if (shape == "square") {
unokill._x=110;
unokill._y= -490;
}
}
function thmb (thumb){
thumb.gotoAndStop (1);
}
function awa(img,shape,genre,thumb) {
//put image away
img._x=250;
img._y=-500;
img._visible=0;
//call shape function
img.imgshape (shape);
//call button function
img.btnplace (shape);
//call kill function
img.kllplace (shape);
//restore thumbnail image
genre.thmb (thumb);
}
function away(proj,img,shape,genre,thumb) {
//put image away
proj.awa (img,shape,genre,thumb);
}


all of this is done in an effort to achieve the following:
on(press) {
_root.icons.rbicons.res.sclocho._visible = 0;
_root.icons.rbicons.res.photo.ocho.gotoAndStop (1);
_root.icons.rbicons.res.sclocho.one._width = 120;
_root.icons.rbicons.res.sclocho.one._height = 150;
_root.icons.rbicons.res.sclocho.btn._x = _root.icons.rbicons.res.sclocho.one._width-15;
_root.icons.rbicons.res.sclocho.btn._y = _root.icons.rbicons.res.sclocho.one._height-17.5;
_root.icons.rbicons.res.sclocho.unokll._x = _root.icons.rbicons.res.sclocho.one._width-10;
_root.icons.rbicons.res.sclocho.unokll._y = _root.icons.rbicons.res.sclocho.one._y+10;
}

which I don't want to hard code for what will eventually be 50 or so images... Does the problem lie in my trying to nest functions? am I able to pass variables to one function then on to a nested one in the manner which I have written this? Any help would be GREATLY appreciated, as if I can figure this out, the rest of the site would go quite quickly, if not, it could be a real headache hardcoding it all...TIA
bugg
 
My thought is that perhaps when I pass the series of variables to the top function (away) it then passes the variable "titles" instead of the intended "strings" on to the nested functions. any thoughts? any suggestions (aside from the obvious not trying such convoluted mechanisms...)

thanks
bugg
 
WOW!!!

sorry for taking up so much room with that nasty post that I don't even know if anyone could (or dared try to) understand. I figured it out, it wasn't hard, I was just making it so. Wang- thanks for your help in the beginning, it helped me understand what the @$%!@# was going on with all this...

out

bugg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top