A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Beginner question about errors and warnings

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    20

    Beginner question about errors and warnings

    Hi, I'm still kind of new to Flash development -- coming from a Visual Studio background. Is there a way to set up flash so that it will give me additional errors or warnings when I compile my .swf file? For example:

    var myNumber:Number = 3;
    myNumber = myNummer + 2;


    This code compiles and runs just fine, but I'd much prefer an error "variable myNummer not declared"

    if (myTestVar = 3) doSomething();

    This line of code would give me "Warning: Assignment within conditional expression" in Visual Studio, and that was quite useful.

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    Montreal
    Posts
    101
    Flash being a dynamically typed language, this is legal. You actually don't have to type the variable for it to work. At runtime, Flash will cast it to the proper type according to the value it stores.

    Bottom line, you have to get used to this. I'm not sure but I believe that you can actually do some minor compilor tweaking for the Flash Virtual Machine 2 (VM2) but definitely not for this.

  3. #3
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Your code actually give and error:
    PHP Code:
    var myNumber:Number 3;
    myNumber myNummer 2
    You'll get something like this:
    1120: Access of undefined property myNummer.

    PS: just remembered... the code you posted would not display an error only if you are using ActionScript 2.0 ; why ? Because AS 2.0 is not as strict as AS 3.0 and it did permit variable declaration anywhere, any when...

    Not sure if you can do anything about it in AS 2.0, it wasn't designed to be strict.
    Last edited by fx.barrett; 01-05-2008 at 04:30 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  4. #4
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Quote Originally Posted by Whyves
    Flash being a dynamically typed language, this is legal. You actually don't have to type the variable for it to work. At runtime, Flash will cast it to the proper type according to the value it stores.
    This is only true for ActionScript 2.0, things have changed in AS 3.0.
    Last edited by fx.barrett; 01-05-2008 at 04:02 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  5. #5
    Senior Member
    Join Date
    Jan 2008
    Location
    Montreal
    Posts
    101
    I have not really used AS3 for the moment. But from what I read you can set some setting for the VM2 that will allow for a more or less strict compilation. So, depending on your VM2 settings, you might not get the errors. I also think that some classes are dynamic by nature and that will allow you to add non typed variable. Is it the case?

  6. #6
    Junior Member
    Join Date
    Nov 2007
    Posts
    20
    you're right, it gives an error in AS3.0. Unfortunately I have to use AS2.0 for this project.

    I'm really surprised they couldn't have written the AS2.0 compiler to have some kind of a 'strict mode' where it at least give warnings for these kinds of things.

  7. #7
    Junior Member
    Join Date
    Nov 2007
    Posts
    20
    Whyves, you are right that it does catch the error when its inside a class, even in AS2. I didn't realize that. Thanks!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center