Yeah, that explains everything!



  • Looking into Flash and ActionScript just to see what kind of stuff is it, and every tutorial out of several I googled up and found in Macromedia's documentation was literally like this:

    1 Open document
    2 Create this (click this, that and this)
    3 Drag it here
    4 Drag it there
    5 Right click this, select that
    6 Tip: Don't forget to save you project (yeah, every official one has this tip)

    Come on! Just a word of what I am doing and why am I doing it, damn it!

    Anyway, I dropped mindless clicking around soon enough and went on to ActionScript documentation. 

    Local variables are declared like that:
    var myStr:String = "local";
    And globals like that:
    _global.str = "global"

    Which by itself is ok.

    But here is an extract from a page about global variables, read carefully, I highlighted the best part:


    [...]
    To declare (or create) a variable with global scope, use the _global identifier before the variable name and do not use the var = syntax. For example, the following code creates the global variable myName:

    var _global.myName = "George"; // Incorrect syntax for global variable
    _global.myName = "George"; // Correct syntax for global variable

    [...]

    You cannot assign strict data types to variables that you create in the _global scope, because you have to use the var keyword when you assign a data type. For example, you couldn't do:

    _global.foo:String = "foo"; //syntax error
    var _global.foo:String = "foo"; //syntax error

    [...]


    That's on one page just two screens long!!





  • Isn't ActionScript just JavaScript/ECMAscript/whateveryouwantocallitScript?

     I don't know if you're criticizing the design decisions behind Java/ActionScript, because the page is at least consistent in itself and makes sense to me (i.e. I understand what they're talking about).

    To be honest, I'm a bit shocked that the language has any concept of typing at all. But anyway, the part that you highlighted in bold just says,

    "Typing is done with the 'var' keyword. You can't use the var keyword on object properties (i.e. someObject.someProperty.) Hence you can't assign a property of _global a type." 



  • [quote user="Nandurius"]Isn't ActionScript just JavaScript/ECMAscript/whateveryouwantocallitScript?

    ...

    To be honest, I'm a bit shocked that the language has any concept of typing at all.[/quote]

    Back in the day, Netscape submitted their JavaScript specification to ECMA and it became ECMAScript. Nowadays, ActionScript, JavaScript, and JScript all based on ECMAScript, but they have additional features on top of it. The explicit typing is an extension of ActionScript.

    Note that Mozilla defines the JavaScript scripting language, so they can specify whatever they want as "standard JavaScript". Meaning there really is no current JavaScript standard. Try finding a specification for JavaScript 1.7.



  • I agree, the documentation is quite confusing.

    Why don't they just explain that global variables just isn't variables at all, just properties of the _global object? That would make the difference so much clearer.

     



  • [quote user="Guffa"]

    I agree, the documentation is quite confusing.

    Why don't they just explain that global variables just isn't variables at all, just properties of the _global object? That would make the difference so much clearer.

     

    [/quote]

     

    I'm thinking it was probably written by a technical writer.  Those fuckers get all bent out of shape if you try to explain anything to them, so, it's easier just to let them do what they want, because no one ever reads the documentation anyway.



  • [quote user="huh"]

    because no one ever reads the documentation anyway.

    [/quote]

    Yeah, obviously no one who reads thedailyWTF would try to read documentation.  I mean, all code is self explanatory, isn't it?



  • I don't know if you're criticizing the design decisions behind Java/ActionScript, because the page is at least consistent in itself and makes sense to me (i.e. I understand what they're talking about).

    Oh, I don't criticize language design, I don't know it nearly good enough for that (Edit: but I am tempted :)).

    The WTF is documentation. Your writing of explanation is better but what kind of reason is this? I read it as  "they choose to make globals non-typable because you can't use 'var' with it."

    You have to use hammer to nail nails.
    You can't use your cellphone to do that because you have to use hammer.



  • Keeping somewath on topic... There is a new type of var on actionscript3 , its called int. yes gentleman the third version of this ...er... fine ..er... language, finaly added an int.



  • If you're coming from a development and not a designer background do yourself a favor:

    1) Close the flash IDE

    2) Get eclipse

    3) Get ASDT (eclipse plugin)

    4) Get MTASC (actionscript compiler)

    5) Figure out how they all work together.

     
    Some helpful links: 

    http://www.mtasc.org/

    Don't ever put actionscript in a .fla, you're asking for a world of hurt. 



  • The main problem isn't so much that you can't use strict typing without using the 'var' keyword, but that someone decided adding strict typing to a language like AS was a good idea. Why does it need it at all?



  • Why, to bring a trace of sanity to that blooming garden of madness... :)


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.