Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 03-18-2011, 07:12 PM   #1
easleyt
Registered User
 
Join Date: Mar 2011
Location: Los Angeles
Posts: 4
Default Problem with if then else

Sorry but this is my 1st attempt @ actionscript and I've yet to find a really good reference and training is weeks away. I'm using Flex Builder 3 and trying to create a percentage based on current month sales vs prior month sales and avoiding zero divide for entities with no prior month sales but it isn't compiling, the relevant code is:

private function formatCMCPct(item:Object, columnataGridColumn) :String {return fmtCMCPct.format(if(item.PMC == 0) {0;}
else {(item.CMC/item.PMC)*100;}) + "%"; }

<mx:NumberFormatter id="fmtCMCPct" precision="0" useThousandsSeparator="true" useNegativeSign="true"/>


When I first tried simply (item.CMC/item.PMC)*100 it worked except for the zero divide rows. The error is as follows:

1083: Syntax error: else is expected
1084: Syntax error: expecting identifier before if
1084: Syntax error: expecting identifier before rightparen
1084: Syntax error: expecting rightparen before leftbrace
1086: Syntax error: expecting semicolon before leftbrace

Thanks!
easleyt is offline   Reply With Quote
 


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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:44 PM.

///
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.