Digital Clock refreshing problem!

Hi all,

i was working on my project today and i created some easy digital clock and time that retrieves the time and date from the user his computer. The digital clock is completely working but the problem is, I need to refresh my swf all the time to get the time updated.

Declaring variables:


//variables for digital clock
        var time:TextField = new TextField();
        var datefinal:TextField = new TextField();
        
        var mydate:Date = new Date();
        var seconds = mydate.getSeconds();
        var minutes = mydate.getMinutes();
        var hours = mydate.getHours();
        var day = mydate.getDay();
        var date = mydate.getDate();
        var month = mydate.getMonth();
        var year = mydate.getFullYear();

This is my code:


public function DigitalClock(){
                var ClocktextFormat:TextFormat = new TextFormat();
                ClocktextFormat.font = myFont.fontName;
                ClocktextFormat.size = 130;
            
                time.autoSize = TextFieldAutoSize.LEFT;
                time.selectable = false;
                time.y = 550;
                time.x = 0;
                time.defaultTextFormat = ClocktextFormat;
                time.textColor = 0xFFFFFF;
                time.embedFonts = true;
                time.antiAliasType = AntiAliasType.ADVANCED;
                bg.addChild(time);
            
                datefinal.autoSize = TextFieldAutoSize.LEFT;
                datefinal.selectable = false;
                datefinal.y = 700;
                datefinal.x = 0;
                datefinal.defaultTextFormat = ClocktextFormat;
                datefinal.textColor = 0xFFFFFF;
                datefinal.embedFonts = true;
                datefinal.antiAliasType = AntiAliasType.ADVANCED;
                bg.addChild(datefinal);
                
                if (day==0){
                    day = "Sunday"
                } else if (day==1){
                    day = "Monday"
                } else if (day==2){
                    day = "Tuesday"
                } else if (day==3){
                    day = "Wednesday"
                } else if (day==4){
                    day = "Thursday"
                } else if (day==5){
                    day = "Friday"
                } else if (day==6){
                    day = "Saturday"
                }


                if (month==0){
                    month = "January"
                } else if (month==1){
                    month = "February"
                } else if (month==2){
                    month = "March"
                } else if (month==3){
                    month = "April"
                } else if (month==4){
                    month = "May"
                } else if (month==5){
                    month = "June"
                } else if (month==6){
                    month = "July"
                } else if (month==7){
                    month = "August"
                } else if (month==8){
                    month = "September"
                } else if (month==9){
                    month = "October"
                } else if (month==10){
                    month = "November"
                } else if (month==11){
                    month = "December"
                }
                
                if (minutes<10) {
                    minutes = "0"+minutes;
                }
                if (seconds<10) {
                    seconds = "0"+seconds;
                }
                
                time.text = ((hours) + ":" + (minutes) + ":" + (seconds));
                datefinal.text = ((day) + " " + (date) + " " + (month) + " " + (year));
                
            }//end of public function DigitalClock(){

Thanks in advance,

Wouter