more strict compiling in actionscript

Ask a Question related to Macromedia Flash, Design and Development.

  1. #1

    Default more strict compiling in actionscript

    Is it possible to set the compiler into a more strict or error mode where it doesn't just run through everything sans syntax errors without a whisper? I'm not even talking about dynamic typing here, I have no problem with that, but its not cosure if I call a nonexistant function, or reference a nonexistant variable, or a nonexistant property of a nonexistant variable (among many other things). There must be a better way of dealing with this than trace()ing back 20 lines to find the source of the problem. I'm going to have to switch to MTASC soon..
    for example this code:

    _root.thecompiler()
    a = _root.isnowheretobefound()
    w = a.doesnotexist
    a.cool=4
    a.wha=5
    trace(a.cool+a.wha)

    compiles just fine!

    The only reason I see for this sort of thing (unless there is an option for stricter compiling that I've missed) is so that users on the web don't have to deal with the errors, but if this is the case, then either A. recognize when you are being played in a browser, or B. have two different compile modes. Although even this doesn't make sense as the traces aren't visible except in the authoring environment.

    I've thought about either using a premade framework to build on top of, or wrap everything in my own, but this would be a big project that I'm not excited about.

    Any thoughts, prior discussion about this? I couldn't find it.


    --
    ==============================
    Ashot Petrosian
    University of Texas at Austin, Computer Sciences
    (views expressed are solely my own)
    ==============================
    Ashot Guest

  2. Similar Questions and Discussions

    1. how to strict the movement?
      i got this behavior from a tutorial on web. i drag and drop it to my 3d member, and it works great. i can move the model i clicked anywhere on the...
    2. Use strict with plperl
      In 8.0 how does one have a plperl function use strict? If I add "use strict" within the function body I receive an error message: "creation of...
    3. Use Strict Error
      When I use the following portion of Perl code: __________________________________________________ #!/usr/bin/perl # use with: # perl IfThenElse...
    4. use strict and filehandles
      Hi All, I'm having trouble understanding what use strict is trying to tell me. If I have run this program ...
    5. Using strict references
      Hi, I am trying to write all of my code using strict to improve my code. However, the correct use of references for the following problem...
  3. #2

    Default Re: more strict compiling in actionscript

    Flash compiler cannot tell what you may have dynamically created when the
    movie was run.

    eg

    _root.f = function() { ... };

    dynamically creates a function f .. Flash compiler cannot tell if a
    reference to _root.f() elsewhere is valid.

    It will check for valid methods and properties for AS2 classes (if the class
    is not marked as able to have properties and methods added dynamically).

    You may be able code some of your own runtime error detection using
    _resolve. If would be nice if the debug player showed you 'errors' like
    referencing undefined variables (there is no problem with that in the
    language .. undefined vars are allowed and are not an error per se, although
    often they can be a symptom of a program logic/design error)
    --
    All the best,
    Jeckyl


    Jeckyl Guest

  4. #3

    Default Re: more strict compiling in actionscript

    On Mon, 21 Feb 2005 05:30:24 GMT, Jeckyl <Jeckyl@Hyde.com> wrote:
    > Flash compiler cannot tell what you may have dynamically created when the
    > movie was run.
    >
    > eg
    >
    > _root.f = function() { ... };
    >
    > dynamically creates a function f .. Flash compiler cannot tell if a
    > reference to _root.f() elsewhere is valid.
    I'm sorry, you are right, I meant it should check for these things at runtime. But how hard would it be for the flash runtime to simply through out a trace when something doesn't resolve?
    > It will check for valid methods and properties for AS2 classes (if the class
    > is not marked as able to have properties and methods added dynamically).
    >
    > You may be able code some of your own runtime error detection using
    > _resolve. If would be nice if the debug player showed you 'errors' like
    thats interesting, I hadn't seen that before, but this should be built into the system, not up to the user. I'll check that out tonight.
    > referencing undefined variables (there is no problem with that in the
    > language .. undefined vars are allowed and are not an error per se, although
    > often they can be a symptom of a program logic/design error)
    This is true, but it would be very bad programming practice to use the extremely loose undefines in Flash as part of the regular logic of the program.



    --
    ==============================
    Ashot Petrosian
    University of Texas at Austin, Computer Sciences
    (views expressed are solely my own)
    ==============================
    Ashot Guest

  5. #4

    Default Re: more strict compiling in actionscript

    Sometimes the presence (or absence) of a variable can indicate that
    something has/hasn't happened. Eg you might be loading variables and can
    then check that a given variable has been defined or not etc.
    --
    All the best,
    Jeckyl


    Jeckyl Guest

  6. #5

    Default Re: more strict compiling in actionscript

    Ashot wrote:
    > Is it possible to set the compiler into a more strict or error mode
    > where it doesn't just run through everything sans syntax errors without
    > a whisper? I'm not even talking about dynamic typing here, I have no
    ....


    welcome to Flash IDE (so-called). i empathise with you. i was a "C++"
    speaker before learning Flash, and i faced exactly the problems. no
    warnings of "variable undeclared" errors, don't know what type of
    parameter actally coming into a function, ... etc. etc. sometimes the
    script just hangs - and if you forgot to save your last version before
    you test-run, that's precious minutes of your work gone.

    so i found the hard way that Macromedia's IDE is really trashy (from
    a programmer's point of view).

    but over time, one copes. one develops new debugging strategies. i
    tend to use lots of traces. sometimes variables which i think are
    defined are actually undefined. trace variables, properties, use typeof().
    sometimes i am not sure whether a function has been called, or where
    the h*** the script actually flowed. i use check-point tracing e.g.
    trace("function name"); at the start of the function and
    trace("checkpoint #1); trace("checkpoint #2); ... etc inside and
    outside loops, or at every branch of if() or switch statements.

    -----
    The Count, Singapore
    Learning Objects (e-Learning) Consultant
    Der Zählmeister Guest

  7. #6

    Default Re: more strict compiling in actionscript


    On Mon, 21 Feb 2005 11:59:46 GMT, Jeckyl <Jeckyl@Hyde.com> wrote:
    > Sometimes the presence (or absence) of a variable can indicate that
    > something has/hasn't happened. Eg you might be loading variables and can
    > then check that a given variable has been defined or not etc.
    right, but if you are going to use this sort of logic in your code you should define it explicitly. Use -1 for array indexes, or an UNDEFINED contant. Some languages have strict definitions of NULL and in those languages it makes sense to use the built in. In actionscript the whole world is undefined.


    --
    ==============================
    Ashot Petrosian
    University of Texas at Austin, Computer Sciences
    (views expressed are solely my own)
    ==============================
    Ashot Guest

  8. #7

    Default Re: more strict compiling in actionscript

    On Mon, 21 Feb 2005 23:54:14 +0800, Der Zählmeister <the_count@mozilla.com.sg> wrote:
    > Ashot wrote:
    >
    >> Is it possible to set the compiler into a more strict or error mode
    >> where it doesn't just run through everything sans syntax errors without
    >> a whisper? I'm not even talking about dynamic typing here, I have no
    > ...
    >
    >
    > welcome to Flash IDE (so-called). i empathise with you. i was a "C++"
    > speaker before learning Flash, and i faced exactly the problems. no
    > warnings of "variable undeclared" errors, don't know what type of
    > parameter actally coming into a function, ... etc. etc. sometimes the
    > script just hangs - and if you forgot to save your last version before
    > you test-run, that's precious minutes of your work gone.
    >
    > so i found the hard way that Macromedia's IDE is really trashy (from
    > a programmer's point of view).
    >
    > but over time, one copes. one develops new debugging strategies. i
    > tend to use lots of traces. sometimes variables which i think are
    > defined are actually undefined. trace variables, properties, use typeof().
    > sometimes i am not sure whether a function has been called, or where
    > the h*** the script actually flowed. i use check-point tracing e.g.
    > trace("function name"); at the start of the function and
    > trace("checkpoint #1); trace("checkpoint #2); ... etc inside and
    > outside loops, or at every branch of if() or switch statements.
    >
    yea this is essentially the sort of thing that I have to resort to as well, probably many others. It also doesn't help that the default trace is pretty useless for arrays and strings. This is unacceptable IMO on Macromedia's part. It would be very easy for them to fix this at least on an elementary level, without breaking anything else. The only way I see around this is to build your own type library and wrap everything in some base type which would check existance.
    How can Macromedia push Flash as a RIA client and ignore such simple things? They have the only unified RIA client which has a 98 install base, but its absolutely impossible to develop on their platform without jumping through a dozen hoops. There are other things as well, such as lightweight more powerful components. Aren't they shooting themselves in the foot or am I missing something here? Maybe I'm not seeing something, I dunno..

    Although there are some great third party tools that fill in some of the gaps.

    You should check out MTASC:
    [url]http://team.motion-twin.com/ncannasse/mtasc.html[/url]
    under very rapid development at this point, although its in beta and you may have to slightly change any code you already have to get it to compile the first time. Well worth it though I think, I've been working on transfering ~10,000 lines of Actionscript.

    Ghostwire has the best component framework I have been able to find:
    [url]http://ghostwire.com/[/url]



    --
    ==============================
    Ashot Petrosian
    University of Texas at Austin, Computer Sciences
    (views expressed are solely my own)
    ==============================
    Ashot Guest

  9. #8

    Default Re: more strict compiling in actionscript

    AS just follows (pretty much) the ECMA standards (for JavaScript) ..
    undefined variables are well supported and their behaviour defined.
    'undefined' is a special valid value and how it works is all laid out in the
    standard. So its not look other languages where using undefined values
    gives you undefined behaviour, and crashes etc. You need to appreciate that
    its not a fully compiled static language .. and cannot be without severely
    restricting what you can do with it .. so it cannot do the type checking you
    want at compile time.

    Also, as a matter of good design, it should NOT display any runtime errors
    (the last thing you want is someone coming to your site and seeing some
    runtime error message) .. but a testing environment that DOES do so would be
    good. Or a way to maybe have errors reported back to a server would be
    good.

    Regarding tracing of array etc, the 'trace' simply does a conversion to
    string .. you can change that to get whatever output you want .. so if you
    don't like how arrays are traced, you can change that.
    --
    All the best,
    Jeckyl


    Jeckyl Guest

  10. #9

    Default Re: more strict compiling in actionscript

    On Mon, 21 Feb 2005 21:34:54 GMT, Jeckyl <Jeckyl@Hyde.com> wrote:
    > AS just follows (pretty much) the ECMA standards (for JavaScript) ..
    > undefined variables are well supported and their behaviour defined.
    > 'undefined' is a special valid value and how it works is all laid out in the
    > standard. So its not look other languages where using undefined values
    I wasn't saying that the behavior of undefined is not deterministic, which is what you seem to be saying, I was saying it was loose.
    anything you haven't defined is undefined, and this slips right by.
    > gives you undefined behaviour, and crashes etc. You need to appreciate that
    > its not a fully compiled static language .. and cannot be without severely
    > restricting what you can do with it .. so it cannot do the type checking you
    > want at compile time.
    This is not true. Being a dynamic language is no excuse for not providing sensible default behaviour. Being completely silent when undefined objects are assigned to, called, and so on is NOT SENSIBLE. If its an EMCA standard, its still absurd. I'm not talking about type checking here. Python is a dynamic, loosely typed language and I have no qualms with it whatsoever (in fact its usually my language of choice).
    It doesn't have to crash, it can emit a trace the same way it does when there is a syntax error.
    >
    > Also, as a matter of good design, it should NOT display any runtime errors
    > (the last thing you want is someone coming to your site and seeing some
    > runtime error message) .. but a testing environment that DOES do so would be
    > good. Or a way to maybe have errors reported back to a server would be
    > good.
    >
    > Regarding tracing of array etc, the 'trace' simply does a conversion to
    > string .. you can change that to get whatever output you want .. so if you
    > don't like how arrays are traced, you can change that.
    I've done this, after scouring the net for hours for the relevant introspection info, but why should I have to resort to this?

    Its just not acceptable, I don't agree. How can Macromedia expect serious development to be done on their platform (which is a great platform, and the only viable option at the moment other than freaky javascript/dhtml hacking) if they have raised the bar so high for such simple things?
    I'm not usually one to argue against a large organization but after dealing with this kind of stuff for over a year I've gotten angry. I don't see how this is anything but completely absurd. I have personally dealt with it in other ways as well at this point (the third party tools I've mentioned in this thread).



    --
    ==============================
    Ashot Petrosian
    University of Texas at Austin, Computer Sciences
    (views expressed are solely my own)
    ==============================
    Ashot Guest

  11. #10

    Default Re: more strict compiling in actionscript

    I think the problem is not so much the language per se .. but that it is
    being used for things beyond those for which it was originally conceived.

    A debug environment that better detects problems like undefined variables
    would be good.

    For instance, SWiSHmax (which uses pretty the same actionscript for making
    SWF movies) will detect and warn you about things like undefined variables
    and calling functions that don't exist etc etc. So if you are checking your
    code in SWISHmax itself, these errors get picked up while developing and
    testing. And you end up being 'forced' to write better code (eg explicitly
    initialise your variable, or explicitly check for undefined values rather
    than using a variable without checking). Basically, it forces you to have
    to write less sloppy code .. whereas Flash lets you write sloppy code and
    doesn't complain about it, and Flash puts the onus on you to realise where
    your code is 'sloppy' .. it doesn't help you much with that.
    --
    All the best,
    Jeckyl


    Jeckyl Guest

  12. #11

    Default Re: more strict compiling in actionscript

    Jeckyl wrote:
    > I think the problem is not so much the language per se .. but that it is
    > being used for things beyond those for which it was originally conceived.
    >
    > A debug environment that better detects problems like undefined variables
    > would be good.
    >
    > For instance, SWiSHmax (which uses pretty the same actionscript for making
    > SWF movies) will detect and warn you about things like undefined variables
    > and calling functions that don't exist etc etc. So if you are checking your
    > code in SWISHmax itself, these errors get picked up while developing and
    > testing. And you end up being 'forced' to write better code (eg explicitly
    > initialise your variable, or explicitly check for undefined values rather
    > than using a variable without checking). Basically, it forces you to have
    > to write less sloppy code .. whereas Flash lets you write sloppy code and
    > doesn't complain about it, and Flash puts the onus on you to realise where
    > your code is 'sloppy' .. it doesn't help you much with that.

    this is a point i made in another post: self-discipline is essential.
    for coding Flash AS esp. in the current environment. i'd definitely
    would not recommend Flash AS as the first programming language one
    learns. one would tend to develop bad programming habits which remain
    uncorrected - unless one has the benefit of a very good mentor.

    --
    -----
    The Count, Singapore
    Learning Objects (e-Learning) Consultant
    Der Zählmeister Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139