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 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

Related Questions

people. I have slight problem with GD2 text on image. I have everything working
I have a slight problem... we made a change to our url structure the
I have a slight problem. Having recently migrated on Mac, I've been pulling my
I have a slight problem with a path: D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of
I have a slight problem, I am trying to capture the input of two
am new here. i have a slight problem; PLease look at the following code
I've wrote this simple piece of code. And I have a slight problem with
hey everyone, here is the site SEE BELOW I have a slight jquery problem
I have an extremely odd problem in my JUnit tests that I just can't
I have a slight javascript problem, and this is the reason to why i

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.