Mar
Wed
17
admin
  • :hitman2: the flash autoformat destroys my code... And i use it all the time :(..

    my switch and for statements doesnt work anymore after autoformat, it adds ';' where it shouldnt..

    Anyone ? Please ?


  • :huh:
    You seem pretty excited, sen. Let me get this straight- you were able to reproduce all these auto-format oddities, by associating an actionscript file with an AS2 Flash file? Or do you mean that you were able to reproduce Macsy's issue? Or what?


  • no, i have a Asus :) A7T Laptop. . .

    autoformat did work, for a lot of time, but... Suddenly, after 3000 formats;

    "HEY! I know what i can do, i can destroy your code*evil*"


  • lol that's like the only anchor he doesn't have basiclaly


  • Repro? Is that how it's said on the streets? ;)

    My auto-format settings are,


    Inserting { after function, class, and interface keywords,
    Inserting spaces around operators, and
    Don't format multiline comments.


    I just turned the last one off, and the issue with the comments shifting has disappeared. (I guess I'll leave that one off for now.) The semicolon issue still pops up, and the weird constructors still occur. In fact, if I have a constructor with no parentheses following it, Auto Format will add two spaces to the end rather than two parentheses.

    EDIT: Speaking of Auto Format settings, the "put spaces around operators" setting doesn't put spaces around my assignment-related operators like "=" and "+=". Is it meant to be that way?


  • what do you mean?


  • Alright, I just went through all the examples I've posted, and they all exhibit the behavior I've described by inserting the code into the Actionscript editor (in either panel or window mode) and then hitting Auto-format– the only exception being the one about parentheses disappearing from contructors. The others are reproducible as they appear in this thread.

    I should add that my Mac's PowerPC-based, in case that has any implications.


  • Hello, it was a long time since i made this thread, have you find any answers to why the code gets broken after autoformat?
    Please quote me!


  • That's it. I'll throw out my Flash prefs, reinstall and tell you how it goes.


  • God morning... Did you findout anything that can be solving this issue, now i mean, something that will let me use autoformat?
    Did reinstalling work Rezmason?
    I go to my school and import the AS into Fla MX 2004 , Hope it will solve...


  • This happens to me, too! :( On a daily basis! And oftentimes the damage isn't even reproducible!

    For instance, I have a Main class that I've made public final, and it formats this:

    public final class Main extends Editor {
    // class stuff
    }

    into this!

    public final class Main extends Editor {;
    // WTF?
    }

    It's not even valid code! And heaven forbid you're like me and use curly braces in your switch statements:

    switch (something) {
    case 1: {
    // do thing 1
    break;
    }
    case 2: {
    // do thing 2
    break;
    }
    default: {
    // do default
    }
    }

    You know what it does to that code? It does this!

    switch (something) {
    case 1: {
    // do thing 1
    break;





    }
    case 2: {
    // do thing 2
    break;





    }
    default: {
    // do default



    }
    }

    Each time you hit Auto Format, it'll add another blank line in there. And these are just a few stupid examples.


  • ack! I started that thing in Word and re-added anchors every time I converted to HTML... I must have forgetten the events on the last go around :crazy: I'll update though my current version is a bit messier


  • for(var i:Number=0;i<=100;i++){
    trace(i);
    }

    Works perfectly...


  • please provide examples. Thanks


  • Oh, and yeah. sometimes, flash wont read my for-loops... doesnt have anything to do with autoformat, i think... but a simple for loop like this,

    for(i=0;i<100;i++){
    trace(i)
    }

    will end upp with the output: 100
    Nothing else, not 1,2,3,4,5,6//

    weird?


  • In AS3 you must use event listeners to handle events. You can read about this here:
    http://www.senocular.com/flash/tutorials/as3withflashcs3/#events
    (you'll have to scroll around to find it because the almighty sen hasn't created an 'events' anchor :P)


  • wow.. thats a lots of answers, i have exaclty the same problems as posted,

    //this goes...
    weird = function ()
    {
    //blah
    }

    //into this:

    weird = function ();
    {
    //blah
    }


    Whyyy damnit?! Anyone who can post a script file? I can later on...


  • The next time that happens, provide me with the exact script.


  • Why is my code all a sudden being slammed to the left side of the actions pane instead of being properly formatted?

    example:
    MovieClip.prototype.easeY = function(to) {
    this.onEnterFrame = function() {
    this._y = to-(to-this._y)/1.1;
    if (this._y > to-1 && this._y < to+1) {
    this._y = to;
    delete this.onEnterFrame
    //do other stuff here, this is the point at which the object reaches its target
    }
    }
    };

    mainStage.button.onRelease = function() {
    mainStage.stageBottom.easeY(100);
    };

    when it should be:
    MovieClip.prototype.easeY = function(to) {
    this.onEnterFrame = function() {
    this._y = to-(to-this._y)/1.1;
    if (this._y > to-1 && this._y < to+1) {
    this._y = to;
    delete this.onEnterFrame
    //do other stuff here, this is the point at which the object reaches its target
    }
    }
    };

    mainStage.button.onRelease = function() {
    mainStage.stageBottom.easeY(100);
    }


  • There will be no "solving" this issue. If history is any indication, you'll have to wait for the next release of Flash (previous versions of auto format did things like remove continue statements from your code). This release is particularly flaky - what with a new language to support - so the best solution is just not to use it and format as you type.


  • I'm running Mac OS 10.4.9. I downloaded the CS3 trial; version 9.0.0.494.

    Like I said, these don't always happen (well, the switch statement one does for me), which makes it hard to demonstrate.

    EDIT: Here, try auto-formatting this:

    package net.rezmason.BitmapEditor
    {

    public final class Main extends Editor
    {
    public function Main():void
    {
    }
    }
    }


    That one should cause the weird semicolon bug. And here's another bug I'm experiencing:

    // before auto-formatting:
    package net.rezmason.BitmapEditor
    {
    public final class Main extends Editor
    {
    }
    }

    // and after:

    package net.rezmason.BitmapEditor
    {
    }
    }
    public final class Main extends Editor;


  • The problem is AS1 and AS3 are not at all compatible.. Try doing a search for the new AS3 event structure, or reading through senocular's AS3 Tip of the Day thread..


  • will end upp with the output: 100
    Nothing else, not 1,2,3,4,5,6//

    weird?

    Try

    for(var i:Number=0;i<100;i++){
    trace(i);
    }


  • Merged threads.


  • Well, if you've found a correlation, that's good. I made my main Flash file in the Public Alpha, and converted it to CS3; I'll see whether using a new AS3 Flash file will have any effect on my auto-formatting.

    EDIT: No dice. I'm going to try these things on another Mac as well.


  • :D Want to trade computers, FizixMan?


  • No, it wasn't. I'm not really good at this "reproducible bug" thing, am I?

    Here, I'm going to upload the class that the code above was in. It's one of my favorite classes, actually.

    ...

    Here's the link to the zip file. (http://homepage.mac.com/rezmason/BMPMotleyBrush.as.zip) Auto-formatting this class has exhibited most of the bugs I've written about at one time or another. The code whose operator precedence was messed up is on lines 50 through 55.


  • If you have any more unique examples, please post them; the more complete they are (easier to test) the better.


  • Son of a gun! Auto Format just broke operator precedence. :upset:

    // before:
    xa = (xArray[0] + xArray[9]) / 2;

    // after:
    xa = xArray[0] + xArray[9] / 2;

    Christ on a bike. And it did this several times throughout my class just now.

    NOTE: You know, sen, I feel like an ***, and if all this wasn't actually happening this would be a really mean joke that I wouldn't wish on anybody. Sorry to put it all in your lap. I think the rest of Flash CS3 is awesome, if that helps soften the blow. :thumb2:


  • ^ always worked just fine for me.... hmm


  • Done anyone else have a PowerPC issue with which they can confirm this?


  • Wow... all because I was trying to publish it in AS 3.0. Why the heck won't the above code work in AS 3.0? It seems I can't connect any script to the button? WTF.

    It seems to be the prototype. How would the "golden formula" be migrated to AS 3.0?


  • I came across the same issues on autoformating in Flash, both as2 and as3 was rendered unuseable after hitting autoformat.

    ok, I already read, that 'word on the street' is not using autoformat at all, but in most cases, autoformat works fine - at least for me.

    I also think, that autoformating errors are not very reproduceable, because they do not really depend on the code, but on some other meta information saved along with the code internally.

    my errors came from a completely corrext function, which was named:

    myFunction = function(myParams:Array):Void
    {
    // something usefull in here; switch and case, etc.
    }
    autoformat appended semicolons on all switch and case statement inside and after the Void in the function line, which obviously breaks the code.

    i made sure that there really was no error in the code, so I startet to play arround with the function line and rewrote it to:

    function myFunction(myParams:Array):Void
    {
    // something usefull in here; switch and case, etc.
    }this way, autoformating worked (even if there where some semicolons removed).

    so, again I rewrote the function line to:
    myFunction = function(myParams:Array):Void
    {
    // something usefull in here; switch and case, etc.
    }yes, they same is before!

    guess what?

    autoformating is still working.

    this is, why I think that there is some metainformation saved along with the code.

    but maybe it's only on my system.

    hope it helps anyway.

    ----8<----
    krck


  • Go ahead and list your computer specs, Macsy. I'm betting this is a PowerPC issue. I assume based on your forum handle that you have a Mac?


  • lol, oh wow. And here I am hating the fact that it removes my whitespace. Hello Flash! I put that extra whitespace in for a reason! I like to be able to read my code easier!

    Meanwhile, yours is completely rewriting your code. That's nuts!


  • I still havent been able to replicate any of yours Rezmason; what OS are you using?


  • :huh:
    You seem pretty excited, sen. Let me get this straight- you were able to reproduce all these auto-format oddities, by associating an actionscript file with an AS2 Flash file? Or do you mean that you were able to reproduce Macsy's issue? Or what?

    Just your last one. I've been working on these things since you mentioned them in that other thread. I never would have thought having an FLA open (which I normally always do) would have any bearing on how auto format worked. I will probably try the other issues again without FLA's to see if I can get those as well, but its getting late and I need to get out of here ;)


  • it would trace 100 if the trace statement was out of the for loop


  • Um, the one other one I can recall is the exact same as the first example I gave, except the semicolon was being put on a package statement rather than a class statement.

    And this one I'm on the fence about, but when you use /* and */ to comment out something, the commented text should retain the level of indentation as the code around it, right? Because right now, Flash will turn this:

    if (something) {
    /*comment
    blah
    blah
    blah*/
    }

    into this:

    if (something) {
    /*now
    it's
    over
    here*/
    }

    EDIT: Wait! There's one more!

    //When you write this:

    var s:SomeClass = new SomeClass();

    // it turns it into this:

    var s:SomeClass = new SomeClass ;

    // Notice the spaces.


  • Found a powerpc mac, still cant reproduce. :-/


  • Ah! I think I was able to do it this time! It seems that you can't have an FLAs open since when the AS file is associated with an FLA it will work. Assoc. with an AS2 FLA will generate errors (not a valid AS2 class); assoc. with an AS3 FLA makes it work fine (for the most part, from what I could tell), but no FLA and I see it did remove those parens :cop:


  • I was having the same issue, and it was because I was developing in an AS 3.0 Document and pasted in 2.0 code. Make sure that your code is appropriate for the document type.


  • Man! this is stupid! now im really frustrated... It work for, 2-3 formats, and then it made me have to retype 40 lines... There is no error on the line, but flash hates my For loops, no changes, nothing, but flash wont read it properly...

    for (j = 0; j < map.length; j++);

    just gives j = 10

    That SUCKS!!! Im so angry!!!

    Ive tried other switch statements and made other functions.. they work, but CS3 HATES this function, this functions is made on 5 line, just some variables above...


    createMap = function (map)
    {
    _root.attachMovie('tempMap','tempMap',this.getNext HighestDepth());
    for (j = 0; j < map.length; j++);
    {
    for (i = 0; i < map[j].length; i++);
    {
    switch (map[j][i])
    {
    case 0 :;
    mapDraw = "black";
    tempMap.attachMovie ("white",'tile' + i + j,tempMap.getNextHighestDepth ());
    tempMap["tile" + i + j].tileWalkable = true;
    break;
    case 1 :;
    tempMap.attachMovie ("black",'tile' + i + j,tempMap.getNextHighestDepth ());
    tempMap["tile" + i + j].tileWalkable = false;
    break;
    };
    tempMap["tile" + i + j]._x = i * 100;
    tempMap["tile" + i + j]._y = j * 100;
    };
    };
    };
    createMap (map1);



    Now there is no errors, but i get j = 10 at once... GRR!!!


  • when it happened for that last script, was that the only script within the Actions panel window?


  • the final class and switch Ive been able to repro. Still getting nothing for the constructor parens and the block comments comments in the if block. What are your auto format settings?

    (and maybe the PowerPC thing has something to do with it; Ive only been testing on a Mac intel)


  • Interesting... never happened to me...
    I guess i'm lucky :D







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Auto format ( Stupid Flash!) , Please add it free.
    • edit