So much for modern "strict data typing" programming theory. I waste so much time debugging problems with scripts that are usually related to extracting data from XML, which is a string, then trying to turn it into a number using a pre-typed variable - only to find I end up with NaN.
Rubbish. Older programming languages, such as Atari Basic in my childhood had no such issues - they would throw an occasional "type mismatch" error if it went wrong or the data was unexpectedly a string instead of a numeric value. Of course that used to be fixed by using int(variable).
This modern approach fools the app and compiler into thinking everything is fine, but simply refuses to convert the variable properly, and populates it with the useless NaN value, which of course you can't do anything with!
This means a lot of value tracing in functions needs to be done to diagnose these problems - then finally you can spot ity, and attempt various ways of converting the original values again until you get something sensible out of Actionscript.
Screw ECMA script conventions - more trouble than its worth.
About Me
- derekcfoley
- Derek lives in Wall Street, Lee-Over-Sands, St Osyth. A mobile and event software/product designer by trade - and is keen to improve things for all the local residents - and has lived in this idyllic location since 2009.
Friday, 14 May 2010
Tuesday, 4 May 2010
dot and bracket scope notation
Every time I try and follow programming "best practice", which of course states that you shouldn't use the old fashioned eval statement (which supposedly is inefficient), I end up looking dumbfounded by someone's decision of how they implement syntax and code... specifically Flash Actionscript 2.0 bracket notation - which for a beginner or a seasoned experienced programmer trying it out for the first time, just doesn't make a lot of sense.
Ok lets say you have 10 identical items, placed on the stage using the Flash IDE and values in each "pre-populated" and you want to do something to all instances - say read off the values - obviously you use a loop and do this - so this is supposedly bad (eval) method....
In bracket notation it would be:
it works, but is it only me who finds the fact that there is no dot after the root command a bit odd?
common sense would make you thing it should be
but no - another Actionscript oddity! I remember struggling with this years ago when I had problems using an eval statement inside a dynamic element - thankfully examples on the web rescued me at the time - so today after revisiting the technique again - I thought it was worth pointing out!
Ok lets say you have 10 identical items, placed on the stage using the Flash IDE and values in each "pre-populated" and you want to do something to all instances - say read off the values - obviously you use a loop and do this - so this is supposedly bad (eval) method....
items=10;
for (item=1;item
theObject=eval("_root.field"+item);
trace("item "+theObject._name+" has a value of "+theObject.text);
}
In bracket notation it would be:
items=10;
for (item=1;item
theText=_root["field"+item].text;
trace("item "+theObject._name+" has a value of "+theObject.text);
}
it works, but is it only me who finds the fact that there is no dot after the root command a bit odd?
common sense would make you thing it should be
theText=_root.["field"+item].text;
but no - another Actionscript oddity! I remember struggling with this years ago when I had problems using an eval statement inside a dynamic element - thankfully examples on the web rescued me at the time - so today after revisiting the technique again - I thought it was worth pointing out!
Subscribe to:
Comments (Atom)