Hi All,

Thanks, as most savvy programmers have figured this is a training exercise, an I'm learning quite a bit.



Respectfully,


Christopher Kennon
Principal & Creative Director -Bushidodeep
www.bushidodeep.com

______________________________
"Knowing is not enough, you must apply;
       willing is not enough, you must do."
                                         ---Bruce Lee


On Jan 16, 2006, at 3:32 PM, PR Durand wrote:

Hi Chris

At the end of your code you have this now = new Date(); outside any method
so flash doesn't know what to make with.
Those 2 lines
   now = new Date();
   trace ("The Time is " + formatTime(now));
seem to be here to test your formatTime method, but it has to be in flash, not in the class, if you keep this format.
Or you can also integrate it to your constructor:
   public function Hello(target:MovieClip) {
       container_mc = target.createEmptyMovieClip("blah", 1);
       placeGreeting();
       var now:Date = new Date();
       trace ("The Time is " + this.formatTime(now));
   }

Regards,

PR




Chris Kennon a écrit :

Hi All,

In the following code my attempt at formatting the date returns this to the output window:
//
**Error** BushidoDeep:Users:chris:Desktop:hello:com:bushidodeep:Hello.as: Line 55: This statement is not permitted in a class definition.
         now = new Date();

**Error** BushidoDeep:Users:chris:Desktop:hello:com:bushidodeep:Hello.as: Line 56: This statement is not permitted in a class definition.
         trace ("The Time is " + formatTime(now));

**Error** BushidoDeep:Users:chris:Desktop:hello:com:bushidodeep:Hello.as: Line 61: ActionScript 2.0 class scripts may only define class or interface constructs.
     }

Total ActionScript Errors: 3      Reported Errors: 3
//
/**
A Simple hello class
that assigns a custom
message to a text field
based upon time of day.
**/
class com.bushidodeep.Hello {
    private var width:Number;
    private var height:Number;
    private var stageHeight:Number = 300;
    private var stageWidth:Number = 300;
    private var theDate:String;
    private var now:Date;
    private static var textFieldDepth:Number = 0;
    private var messageFormat:TextFormat;
    public var messageDisplay:Function = displayGreeting;
    public var message:String = "";

    // Movie clip that will contain visual
    // elements of the hello.
    private var container_mc:MovieClip;
    //
    public function Hello(target:MovieClip) {
        container_mc = target.createEmptyMovieClip("blah", 1);
        placeGreeting();
    }
    private function placeGreeting() {
        messageFormat = new TextFormat();
        messageFormat.font = "Verdana";
        messageFormat.color = 0xffffff;
        messageFormat.bold = true;
container_mc.createTextField("messageText", textFieldDepth, 75, 100, 150, 25);
        container_mc.messageText.text = messageDisplay();
        container_mc.messageText.border = false;
        container_mc.messageText.setTextFormat(messageFormat);
    }
//for testing only will use am/pm passed from formatTime() to output message
    private function displayGreeting() {
        if (now == "afternoon") {
            message = "Disco Rules";
        } else {
            message = "Samba Rules";
        }
        return message;
    }
    private function formatTime(theDate){
        var hour=theDate.getHours();
var minute=theDate.getMinutes()>9 ? theDate.getMinutes() : "0" + theDate.getMinutes();
        if (hour > 12){
            var timeString = (hour-12) + ":" + minute + "PM";
        }else{
            var timeString = hour + ":" + minute + "AM";
        }
        return timeString;
    }
    now = new Date();
    trace ("The Time is " + formatTime(now));

                  }
}




_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to