• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Auto format breaks code, does it in CS4

Guest
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

I found a reference to CS3 Flash's auto format breaking AS3 code on kirupa back in May 2007 but was surprised to find out that it still breaks code by removing parenthesis.
Before
truescale=Math.pow(8,(1 - i) * scaleit);
After
truescale=Math.pow(8,1 - i * scaleit);

Obviously the results are devastating. Would someone check to see if CS4 Flash's auto format still causes the same error when editing .as file? Might be worth the price of an upgrade if it does NOT mess up the format.

The original code was: truescale=Math.pow(8,-(i-1)*scaleit) to reflect the true logic of the statement but has now been rewritten to: truescale=Math.pow(8,scaleit - i*scaleit) which works but does not reflect the mathematical intent whatsoever.

BTW: I believe that others surely have run across this problem and that the topic would surely include the words "auto format" but my search revealed nothing appropriate to this issue. I find this mildly disconcerting. Please feel free to reset my expectations.
TOPICS
ActionScript

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 26, 2009 Feb 26, 2009
thinkingresearcher,

> I found a reference to CS3 Flash's auto format breaking AS3
> code on kirupa back in May 2007

I don't recall that reference in particular, but I have known autoformat
to rearrange my code in ways I wasn't expecting.

> surprised to find out that it still breaks code by removing
> parenthesis.
> Before
> truescale=Math.pow(8,(1 - i) * scaleit);
> After
> truescale=Math.pow(8,1 - i * scaleit);

Interesting. For what it's worth, I just pasted that exact line of code
into...

Votes

Translate

Translate
LEGEND ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

thinkingresearcher,

> I found a reference to CS3 Flash's auto format breaking AS3
> code on kirupa back in May 2007

I don't recall that reference in particular, but I have known autoformat
to rearrange my code in ways I wasn't expecting.

> surprised to find out that it still breaks code by removing
> parenthesis.
> Before
> truescale=Math.pow(8,(1 - i) * scaleit);
> After
> truescale=Math.pow(8,1 - i * scaleit);

Interesting. For what it's worth, I just pasted that exact line of code
into a pair of new Flash CS3 documents -- AS3 and AS2 -- and ran the
autoformatter. In neither case did Flash remove the parentheses. I tried
the same in Flash CS4 and the results are the same: the original
parenthesis structure remains unchanged.


David Stiller
Co-author, Foundation Flash CS4 for Designers
http://tinyurl.com/5j55cv
"Luck is the residue of good design."


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 27, 2009 Feb 27, 2009

Copy link to clipboard

Copied

Stranger and stranger. I added additional code and today I took the code in this email out, pasted it somewhere else, and then cut and pasted it back in. It now works. In fact I cannot duplicate yesterday's events. Nasty little bug as auto format changed it when I was working elsewhere in the code. It may have to do with changes to the nesting as this code is over five levels deep. C'est la vie and thanks for the CS4 test.

BTW: I like your residue quote. It's the first time I've seen it and the probability of success has a positive correlationl to planning and ideals.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2009 Feb 27, 2009

Copy link to clipboard

Copied

I've run across this problem quite a few times and at least now I know to look for missing parenthesis when code unexpectedly breaks.

I've never been able to replicate it until today, usually I can quit Flash and reopen the class—then run Auto format without a problem. This code breaks everytime:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2009 Feb 27, 2009

Copy link to clipboard

Copied

Also, try this:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 09, 2010 Mar 09, 2010

Copy link to clipboard

Copied

LATEST

Verified that auto format behaves badly in CS3 & CS4. Anonomous functions written like this seems to do the trick:

EventManager.addEventListener(footprints,"actionComplete",  function(){ trace('here'); });

However, this works fine:

EventManager.addEventListener(cliententerBTN,MouseEvent.MOUSE_OVER,function(){ trace('test'); });

A fix to the first example is to add a variable and uto format will handle correctly:

EventManager.addEventListener(footprints,"actionComplete", somevar=  function(){ trace('here') });

Usage Example:

package com.gwapps{


     public class Main extends MovieClip {
        
         public function Main() {
             doBuild();
         }
            
         public function doBuild() : void{
              EventManager.addEventListener(footprints,"footprintsComplete",  function(){ trace('here') });
         }
     }
};

Without variable added & after auto formatting:

package com.gwapps{


     public class Main extends MovieClip {

        public function Main() {
             doBuild();
         }

        public function  doBuild():void {
         }
     }
}
EventManager.addEventListener(footprints,"footprintsComplete",  function(){ trace('here') });


Hope this helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines