Daily Flash Q.
- Started
- Last post
- 16 Responses
- JamesEngage
Hello all...
the problem...
I have six variables that i need filling they are news1preview, news2preview, news3preview etc...
Now rather than do
news1preview=news[1]i want to do the equivalent of
news+n+preview = news[n]
in a loop but it won't left me do the left hand side like that, or use eval or eval( ) or anything like that...
any help would be greatly received.
- enobrev0
_root.['news' + n + 'preview'] = news[n];
- enobrev0
sorry.. sans the . after _root (or holding clip):
_root['news' + n + 'preview'] = news[n];
- mirola0
as enobrev says but without the dot before the first square bracket.
_root['news' + n + 'preview'] = news[n];
- mirola0
doh!
- JamesEngage0
brilliant...cheers...found it, apparently eval works for flash 5 but not six...
Macromedia recommend using 'this' instead... but I guess root is good enough too... thansk for your help :)
- vespa0
i didn't know that - tearing my hair out over the difference between
_root[]
this[]
eval()what's the difference and when do you use one and not the other?
- vespa0
eval seems to work when you have a property after it whereas this seems to work best if you don't have a property... but other than that... confused!
- mirola0
you cant actually set a variable with eval() it's quite handy when you want to use a with statement in a loop;
for(i=1;i<=10;i++)
with(eval("this.poo"+i))
_x = 99;'this' and '_root' generally refer to locations.
- JamesEngage0
apparently eval used to work on the left, but doesn't anymore because macromedia were not following a EU directive or something, so they'vew bought it back in line.
anyone know of any sure fire ways of removing widows from dynamic html text in flash...
in normal html you can put a nbsp between the last two letters to solve it... but what can you do with flash?
- JamesEngage0
_root is okay if you're referring to something directly, whereas I think they are saying use 'this' as you can then set your variables to whatever on whatever level... not sure what happens if you jsut use square brackets on their own though
- JamesEngage0
ah... if you just use square brackets it doesn't work :)
- vespa0
cheers guys
- vespa0
... and I wasn't using square brackets on their own! but cheers anyway
- unfittoprint0
avoid using _root in actionscript. If you want to make a certain piece of code modular, use a realitve path like
this._parent["image"+i]._x = 10;
- JamesEngage0
bumping this for my own reference
- lostnation0
this should work, no?
for(i=6;i>0;i--){
this['news'+i+'preview']=news[i...
}