Monday, May 14, 2012

[Action Script] class Syntax issues. May,2012

Hello All. I am creating a calender app based on a tutorial, which I have been following to the letter so far. I go to run it to test the code so far and it has thrown about 8 syntax errors at me. I have checked and doublechecked and my code matches that of the tut perfectly. and with what little AS3 knowlege I have, I dont see where these errors are coming from.

code is:

ActionScript Code: package  {        import flash.display.Sprite;    import flash.text.TextFormat;        public class calender extends Sprite {        private var cellW:Number;        private var cellP:Number;        private var allDatesCells:Array = new Array();        private var dateCellFormat:TextFormat;        private var dayLabelTxtFmt:TextFormat;                private var weekDays:Array = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")                private var currDateTime:Date = new Date();        private var firstDay:Date = new Date(currDateTime.fullYear,currDateTime.month,1);        private var firstDayColumn:uint = firstDay.day;        private var daysOfMonths:Array = new Array(31,28,31,30,31,30,31,31,30,31,30,31);        private var maxDays:uint;                public function calender(fontFace:String = "Arial", fontSize:int = 15,                                  cellWidth:Number = 30, padding:Number = 3,                                  originX:Number = 15, originY:Number = 15) {            // constructor code            cellW = cellWidth;            cellP = padding;            setTextFormat(fontFace, fontSize);            makeDatesCellGrid(orignX,originY);            makeDaysLabels(originX,originY);            monthSetup();        }        private function setTextFormat(whichFont:String, size:int):void{            //date text format            dateCellFormat = new TextFormat();            dateCellFormat.font = whichFont;            dateCellFormat.color = 0xFFFFFF;            dateCellFormat.size = size;            dateCellFormat.align = "center";                        //day label text            dayLabelTxtFmt = new TextFormat();            dayLabelTxtFmt.font = "_sans";            dayLabelTxtFmt.color = 0x000000;            dayLabelTxtFmt.size - 3;        }        private function makeDatesCellGrid(cellXPos:Number, cellYPos:Number):void{            //create grid            for(var i:int = 0; i<42; i++){                var dateCell:TextField = new TextField();                addChild(dateCell);                //position cells for form grid                dateCell.x = cellXPos + (cellW * (i-(Math.floor(i/7)*7)));                dateCell.y = cellYPos + (cellW * Math.floor(i/7));                //put all date cells into array                allDatesCells.push(dateCell);            }        }        private function makeDaysLabels(cellXPos:Number, cellYPos:Number):void{            //Add week day names            for(var i:int = 0; i<7; i++){                var dayLabel:TextField = new TextField();                addChild(dayLabel);                                dayLabel.selectable = false                dayLabel.text = weekDays[i];                dayLabel.setTextFormat(dayLabelTxtFmt);                dayLabel.x = cellXPos + (cellW*i);                dayLabel.y = cellYPos - 15;            }        }        private function monthSetup():void {                        for (var i:int = 0; i < 42; i++){                allDatesCells[i].text = "";                //decor all cells                allDatesCells[i].background = true;                allDatesCells[i].backgroundColor = 0x000000;                allDatesCells[i].border = true;                allDatesCells[i].borderColor = 0xCCCCCC;                allDatesCells[i].selectable = false;                allDatesCells[i].width = allDatesCells[i].height = cellW - cellP;                allDatesCells[i].setTextFormat(dateCellFormat);                                arrangeDates();            }        }        private function arrangeDates():void{            //get column number for first day            if(firstDay.day == 0){                //when last date of prev month is sat, move to second row                firstDayColumn = firstDay.day+7            }            else{                firstDayColumn = firstDay.day;            }            //get max days for current month w.r.t leap year if any            maxDays = (firstDay.getFullYear()%4 == 0 && firstDay.getMonth() == 1 ? 29 : daysOfMonths[firstDay.getMonth()]);            //put dates for current month            for(var i:int = 0; i<maxDays; i++){                allDatesCells[firstDayColumn + i].text = i+1;                allDatesCells[firstDayColumn + i].setTextFormat(dateCellFormat);                allDatesCells[firstDayColumn + i].alpha = 1;            }        }    }    }
Syntax errors are:

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 23 1084: Syntax error: expecting rightparen before cellWidth.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 34 1084: Syntax error: expecting rightparen before size.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 50 1084: Syntax error: expecting semicolon before lessthan.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 50 1084: Syntax error: expecting semicolon before rightparen.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 51 1084: Syntax error: expecting identifier before var.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 51 1084: Syntax error: expecting rightbrace before semicolon.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 59 1084: Syntax error: expecting rightparen before rightbrace.

C:\Users\shane\Documents\Lee\Pagan\WEBSITE\calande r\calender.as, Line 59 1084: Syntax error: expecting identifier before rightbrace.


tut site is active.tutsplus.com/tutorials/actionscript/understanding-date-making-a-calendar-in-as3

Any advice on WHY I am getting these Syntax errors would be great. :confused:
class Syntax issues.

Related Post



0 comments: