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

  • Home
  • SEARCH
  • 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 547959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:01:45+00:00 2026-05-13T11:01:45+00:00

Slight problem i have been pondering on, i have a class that loads a

  • 0

Slight problem i have been pondering on, i have a class that loads a text from a url as a means to sync the time.

The swf file can be on the same page multiple times, but i want it to check to see if one of the swf is sync’ing, if so then wait for it to complete and load its sync’d value (rather then query the url itself), so that they are all sync’d to the same value (of the 1st swf file to load).

I am trying this using Shared Objects, which looks a little like this (snippets):

public function sync():void
    {
        sharedObject = SharedObject.getLocal("synctime", "/");
        trace(sharedObject.data.startOfRequest, sharedObject.data.endTime);
        if ( ((new Date().getTime() - 10000) < sharedObject.data.startOfRequest) && (sharedObject.data.endTime !== undefined))
        {
            loadUTCFromSharedObject();
        } 
        else if ( ((new Date().getTime() - 10000) < sharedObject.data.startOfRequest) && (sharedObject.data.endTime == undefined ) )
        {
            timer.addEventListener(TimerEvent.TIMER, loadUTCFromSharedObject);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, startSync);
            timer.start();
        } else {
            startSync()
        }
    }

    private function startSync(e:Event = null) 
    {
        var syncRequest:URLRequest = new URLRequest(TIMEURL + "?cb=" + Math.random());
        var syncTimeLoader:URLLoader = new URLLoader();

        syncTimeLoader.dataFormat = URLLoaderDataFormat.TEXT;
        syncTimeLoader.addEventListener(Event.COMPLETE, syncTimeComplete );
        syncTimeLoader.addEventListener(IOErrorEvent.IO_ERROR, syncTimeFailed );

        sharedObject.clear();
        startOfRequest = new Date();
        sharedObject.data.startOfRequest = startOfRequest.getTime();
        sharedObject.flush();
        syncTimeLoader.load(syncRequest);
    }
    private function loadUTCFromSharedObject(e:Event = null):void
    {
        var sharedObjectCheck:SharedObject = SharedObject.getLocal("synctime", "/");

        trace (sharedObject.data.endTime, sharedObjectCheck.data.endTime);
        if ( sharedObject.data.endTime !== undefined )
        {
            timer.removeEventListener(TimerEvent.TIMER, loadUTCFromSharedObject);
            timer.removeEventListener(TimerEvent.TIMER_COMPLETE, startSync);
            dispatchEvent( new LoadUTCTimeEvent(LoadUTCTimeEvent.SYNC_COMPLETE, null, null, sharedObject, true));   
            trace(sharedObject.data.UTCOffset);
        }
    }
    private function syncTimeComplete(event:Event):void 
    {           
        var loadedText:URLLoader = URLLoader(event.target);
        dispatchEvent( new LoadUTCTimeEvent(LoadUTCTimeEvent.SYNC_COMPLETE, loadedText.data, startOfRequest, sharedObject, false));

    }

Event Dispatcher:

public function LoadUTCTimeEvent(eventStatus:String, timeString:String = null, startOfRequest:Date = null, sharedObject:SharedObject = null, loadFromSharedObject:Boolean = false):void
    {
        super(eventStatus);
        if (eventStatus == SYNC_COMPLETE) {
            if (loadFromSharedObject == true) {
                time = sharedObject.data.syncTime;
                UTCOffset = sharedObject.data.UTCOffset;
            } 
            else
            {
                //...snip....//
                sharedObject.data.UTCOffset = UTCOffset;
                sharedObject.data.syncTime = time;
                sharedObject.data.endTime = curDate.getTime();
                sharedObject.flush(1000);
            }

        }
    }

The problem i am getting is that the 1st swf creates the sharedobject fine, but the second one reads the endTime as undefined, unless i refresh the page (i.e it doesnt pick up live changes). Is this method not posible, should i try another aproach?

Thanks in advance.

Edit: decided to add another stack to explain a little more:(as3) Sync data between 3 or more identical flash objects on the same page

  • 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-05-13T11:01:45+00:00Added an answer on May 13, 2026 at 11:01 am

    you can call a javascript function to do the locking if you stuck with this solution

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 298k
  • Answers 298k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer One thing you can do is include it as a… May 13, 2026 at 7:29 pm
  • Editorial Team
    Editorial Team added an answer In short, not quite. fwrite returns the number of elements… May 13, 2026 at 7:29 pm
  • Editorial Team
    Editorial Team added an answer Found answer, sorry: add to IService [ServiceKnownType(typeof())] May 13, 2026 at 7:29 pm

Related Questions

I recently created a generic Matrix<T> class that acts as a wrapper around a
Recently I have been studying recursion; how to write it, analyze it, etc. I
I'm starting out with wxPython and have been working my way through every tutorial
I have a slight problem. Having recently migrated on Mac, I've been pulling my
I have a class that serializes a set of objects (using XML serialization) that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.