|
Posted by trippy on 03/21/06 08:11
In article <7e4o129s0i9ppbodrgop163tlto3ktm2te@4ax.com>, Onideus Mad
Hatter took the hamburger, threw it on the grill, and I said "Oh wow"...
> On Sat, 18 Mar 2006 13:55:21 GMT, Oli Filth <catch@olifilth.co.uk>
> wrote:
>
> >> DUM DUM DUM DUM...
> >>
> >> square._x = eval("dates._"+i+"._x") + 566;
What is this supposed to do?
> >>
> >> If you're trying to assign a property of a variable variable to
> >> another objects property you sure as fuck need it (well in
> >> Actionscript anyway).
>
> >Except that the eval() function in Actionscript is fundamentally
> >different to the eval() in say JavaScript or PHP
>
> Oh really? Are you sure?
Yes. Eval does different things depending on the language.
You also never have to use eval at all. You can get the same results
from using parseFloat(x) or parseInt(x), usually.
All eval does is convert things from a string.
> I mean PHP I can see, but with Javascript
> you can directly access CSS property paths and those properties
> values.
Use the DOM for that, not eval.
> I haven't tested it, but since Actionscript and Javascript
> are kind of from the same family tree so to speak it wouldn't surprise
> me if it held true.
This may or may not be true. Two seemingly similar things can do two
totally different things, again, depending on the languages involved.
Now, there *are* things that apply to all languages but they usually
don't share things involving syntax.
>
> >- it can *only* be used
> >to reference variables/objects via a string; it can't evaluate arbitrary
> >code.
>
> Are you saying this from experience or did you just read it somewhere?
>
> >And the only reason you have to do it this way is because older
> >versions of Flash didn't have proper arrays, etc.
>
> Uh, I'm using SwishMax actually, not Flash and I'm exporting as
> Flash8, Kiddo. And how would an array change anything...that doesn't
> even make sense.
Arrays eliminate a bunch of if/elses.
For instance
if (document.myForm.myRadioButton.checked[0] == true) {
// do some stuff
} else if (document.myForm.myRadioButton.checked[1] == true) {
// do the stuff using this
}
// repeat to infinity and beyond, if you want
}
Or, you can write it as a for loop
function findWhatsChecked() {
for (x=0; x<arrayName.length; x++) {
if (document.myForm.myRadioButton[x].checked == true) {
// do something using document.myForm.myRadioButton[x].value
}
}
For things requiring a lot of selection logic, it can clear and speed
things up dramatically.
You also can have multiple values in arrays. With a slight change in
your code, you can search arrays for ranges too.
> The reason for the eval function in Actionscript is
> if you need to switch from the object properties path (that's what I
> call it, it might have some other name)
What's an object properties path?
> to the object properties
> value.
Those are called 'attributes'.
Object oriented programming dictates that objects are made up of
attributes and methods.
class Person {
String[] colors = {"blue", "brown", "black"}
eyeColor = colors[0];
hairColor = colors[2];
}
every person object will have an eye color and a hair color
since every person object will have them, they're attributes.
same thing applies with methods, only actions are performed.
Person stan = new Person();
stan.eatFood()
Now, somewhere in your Person class would be a method named, you guessed
it, eatFood().
>
> >P.S.
> >As to your subject line, if you're referring to that time when you were
> >attempting to justify:
> >
> > eval(a + b)
Matty, no. Tell me you didn't.
Well, if that's how things are done in actionscript, then so be it. I'm
guessing they aren't though. VB.NET, java, and javascript don't use eval
that way. Shit, VB.NET and java don't use eval at all.
>
> I wasn't attempting to justify anything. You were the one making the
> claim that the eval function had absolutely no use.
It doesn't. None that I can see anyway.
var sum = a + b;
You're welcome.
> I was simply
> stating that I thought you were full of shit on that point and that
> there was a use for it (otherwise why would they have even bothered
> making it). I found proof that refutes your claim and now you're all
> like, "Oh wait, no wait...it's just in PHP and Javascript that it
> doesn't do anything."
Are you converting a and b from strings?
Not that I saw.
--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
NP: "The Way It Is" -- Tesla
"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."
-- Robert Redford "Spy Game"
Navigation:
[Reply to this message]
|