Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-23-2011, 01:25 PM   #1
M1KE
Senior Member
 
Join Date: Feb 2009
Posts: 143
Red face Flash CS5 Auto Format stops my code working?

I have some code that looks like this:
ActionScript Code:
level_btn.x = 50 + (i - 1) % 10 * 50;
it sets the x location of my level button. But this is in a for loop (that's what the 'i' is for.)
I run it and everything works perfectly, as it should, not a single problem.

Then I press the auto format button in the flash actionscript editor. (It's the button that adds all of the ; to the end of each line and other stuff)

Well that changes my code to this:
ActionScript Code:
level_btn.x = 50 + i - 1 % 10 * 50;
thinking it's done me a favour but it hasn't. It's got rid of the brackets so it won't do the maths functions in the correct order.

I've tried adding more brackets in places and other stuff but I just don't know how to fix it. It's annoying because every time I press the auto format button I have to add the brackets in again. Does anyone know how to fix this bug in flash?
M1KE is offline   Reply With Quote
Old 03-25-2012, 12:49 PM   #2
Zanzlanz
Zanzlanz
 
Join Date: Nov 2011
Location: United States
Posts: 12
Send a message via Skype™ to Zanzlanz
Default

Hello!
Were you able to find any ways to fix this?
I'm having a similar problem.


ActionScript Code:
function movement(ev:Event):void {     if (isDown["left"] == 1) {         mainScreen[mainScreen.length-mainCharacterDepth][3] -=  5;     }     if (isDown["right"] == 1) {         mainScreen[mainScreen.length-mainCharacterDepth][3] +=  5;     }     if (isDown["up"] == 1) {         mainScreen[mainScreen.length-mainCharacterDepth][4] +=  5;     }     world.x+=mainScreen[mainScreen.length-mainCharacterDepth][3];     world.y+=mainScreen[mainScreen.length-mainCharacterDepth][4];     mainScreen[mainScreen.length-mainCharacterDepth][3]*=.3;     mainScreen[mainScreen.length-mainCharacterDepth][4]*=.94; }


Turns into:

ActionScript Code:
function movement(ev:Event):void {     if (isDown["left"] == 1) {     }     mainScreen[mainScreen.length-mainCharacterDepth][3] -=  5; }; if (isDown["right"] == 1) { } mainScreen[mainScreen.length-mainCharacterDepth][3] +=  5; }; if (isDown["up"] == 1) { } mainScreen[mainScreen.length-mainCharacterDepth][4] +=  5; }; world.x +=  mainScreen[mainScreen.length - mainCharacterDepth][3]; world.y +=  mainScreen[mainScreen.length - mainCharacterDepth][4]; } mainScreen[mainScreen.length-mainCharacterDepth][3]*=.3; mainScreen[mainScreen.length-mainCharacterDepth][4]*=.94; };

And this messes up my code so badly of course.
If I get rid of this function altogether, though, it works fine.
Zanzlanz is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:42 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.