Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:36:47+00:00 2026-06-11T03:36:47+00:00

Is there a way to schedule a task (function) to execute at a given

  • 0

Is there a way to schedule a task (function) to execute at a given date/time with Action Script 3.0? I mean something like schedule(myFunction:Function, dateTime:Date). Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:36:49+00:00Added an answer on June 11, 2026 at 3:36 am

    Not natively per se.

    SetTimeout as outlined in another answer is probably you’re easiest bet. But if you had many things you wanted scheduled, here is a class that could manage it: (it could be modified to use setTimeout instead of a timer, but I prefer timers)

    public class Scheduler {
        public var time:Date;
        public var action:Function;
        public var parameters:Array;
    
        private var checkInterval:Number = NaN;
        public function get interval():Number { return checkInterval; };
        public function set interval(val:Number):void {
            checkInterval = val;
            if (schedules && (mainTimer && mainTimer.delay > val)) {
                mainTimer.delay = val;
            }
        }
    
        public function Scheduler(time_:Date, action_:Function, interval_:Number = NaN, parameters_:Array = null):void {
            time = time_;
            action = action_;
            checkInterval = interval_;
            parameters = parameters_;
        }
    
        //static stuff
    
        private static var mainTimer:Timer;
        public static function stop():void {
            if (mainTimer) {
                mainTimer.stop();
            }
        }
    
        public static function start():void {
            if (mainTimer && !mainTimer.running) {
                mainTimer.start();
            }
        }
    
        public static function get curInterval():Number { return (mainTimer) ? mainTimer.delay : 0; };
    
        private static var scheduleList:Vector.<Scheduler>;
        public static function get schedules():Vector.<Scheduler> { return scheduleList; };
    
    
        /**
         * Schedules a function to run at a certain time (with the margin of the interval)
         * @param   time - what time to run this passed action
         * @param   action - a function to call between the time passing, and the next interval
         * @param   interval - how often to check if the time has come, default is 1 second
         * @param   ... rest - parameters to pass to the action method
         * @return
         */
        public static function scheduleAction(time:Date, action:Function, interval:Number = NaN, ... rest):Scheduler {
            var s:Scheduler = new Scheduler(time, action, interval, rest);
    
            //if already old
            if (time.time < new Date().time) {
                action.apply(null, rest);
                return s;
            }
    
            if (!scheduleList) {
                scheduleList = new Vector.<Scheduler>();
            }
    
            scheduleList.push(s);
    
            if (!mainTimer) {
                mainTimer = new Timer(1000);
                mainTimer.addEventListener(TimerEvent.TIMER, timerTick);
                mainTimer.start();
            }
    
            if (!isNaN(interval) && interval < mainTimer.delay) {
                mainTimer.delay = interval;
            }
    
            return s;
        }
    
        private static function timerTick(e:TimerEvent):void {
            var tmpDate:Date = new Date();
            for (var i:int = scheduleList.length-1; i >= 0;i--){
                if (tmpDate.time >= scheduleList[i].time.time) {
                    scheduleList[i].action.apply(null, scheduleList[i].parameters);
                    removeSchedule(i);
                }
            }
    
            checkTimerNeeded();
        }
    
        private static function checkTimerNeeded():void {
            if (scheduleList && scheduleList.length < 1) {
                mainTimer.stop();
                mainTimer.removeEventListener(TimerEvent.TIMER, timerTick);
                mainTimer = null;
                scheduleList = null;
            }
        }
    
        private static function removeSchedule(index:int):void {
            scheduleList.splice(index, 1);
            checkTimerNeeded();
        }
    
        /**
         * Cancels a scheduled item
         * @param   s - the item to cancel
         * @return  returns true if the item was scheduled, false if the item wasn't scheduled
         */
        public static function cancelSchedule(s:Scheduler):Boolean {
            if (scheduleList) {
                var index:int = scheduleList.indexOf(s);
                if (index > 0) {
                    removeSchedule(index);
                    return true;
                }
            }
    
            return false;
        }
    
        public static function status():void {
            trace("isRunning:", (mainTimer) ? mainTimer.running : null);
            trace("List Length:", scheduleList ? scheduleList.length : null);
        }
    }
    

    Use as follows:

    Scheduler.scheduleAction(myDateToRunTheFunction, myFunctionToRun, howOftenToCheckTime, functionParameter1, functionParameter2, functionParameter2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to schedule a task at a specific time
The task to schedule is something like: notepad.exe D:\ben's notes\foo.txt After some digging I
Is there some way to use schtasks to create a task with multiple schedules
is there way how to get name ov event from Lambda expression like with
How to schedule a task to linux server system using php script? For example,
I'm looking for a way to input a 'schedule' for a task from a
I have a periodic task scheduled via Spring TaskScheduler.schedule(Runnable, Trigger) . Given the returned
I have a simple question: is there a way in Windows Mobile to schedule
I would like to schedule threads like the Task Scheduler 2.0 only problem that
Is there any way to use Task Parallel Library in multi computer scenarios ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.