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 9134997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:46:00+00:00 2026-06-17T08:46:00+00:00

I am new to actionscript and flash, but i managed to make code that

  • 0

I am new to actionscript and flash, but i managed to make code that gets data from php file and refresh result every 30 seconds:

var timerRefreshRate:Number = 30000;
var fatherTime:Timer = new Timer(timerRefreshRate, 0);
fatherTime.addEventListener(TimerEvent.TIMER, testaa);
fatherTime.start();

function testaa(event:Event):void{

    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE,varsLoaded);
    loader.load(new URLRequest("data.php"));

    function varsLoaded (event:Event):void {
        this.opaqueBackground = loader.data.color;
        title.text=loader.data.title;
        banner_text.text=loader.data.text;

    }
}

But now i am facing 2 problems:

1.) User must wait 30 seconds for movie to load first time

2.) Setting background color does not work any more.

What am i doing wrong?

  • 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-17T08:46:01+00:00Added an answer on June 17, 2026 at 8:46 am

    You can call your function once to load immediately without waiting 30 seconds. Just change the parameters of the function to default to a null event:

    function testaa(event:Event = null):void{    
       //...    
    }
    

    Now you can call the function like so:

    //...
    fatherTime.start();
    testaa();
    

    So you start the timer but immediately run the function once.

    For your second problem, the issue is most likely that you are using a nested function, so this does not refer to your class but rather the testaa function. Nested functions are bad practice in general and you should avoid them if possible. Move the function and loader reference outside and it should work. Final result should be something like this:

    var loader:URLLoader;
    var timerRefreshRate:Number = 30000;
    var fatherTime:Timer = new Timer(timerRefreshRate, 0);
    fatherTime.addEventListener(TimerEvent.TIMER, testaa);
    fatherTime.start();
    testaa();
    
    function testaa(event:Event = null):void{
    
        loader = new URLLoader();
        loader.dataFormat = URLLoaderDataFormat.VARIABLES;
        loader.addEventListener(Event.COMPLETE,varsLoaded);
        loader.load(new URLRequest("data.php"));
    }
    
    function varsLoaded (event:Event):void {
        this.opaqueBackground = loader.data.color;
        title.text=loader.data.title;
        banner_text.text=loader.data.text;    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to actionscript. I'm trying to make a menusystem that will jump to
I am fairly new to actionscript but have quickly got sick of the flash
I created a Flash application that reads POST data from a form. A user
I knew ActionScript and ActionScript2 inside out, but I've been away from Flash for
I am very new to ActionScript and Flash development so excuse any incorrect terminology
Flash ActionScript myData = new LoadVars(); myData.onLoad = function() { myText_txt.text = this.myVariable; };
I'm very new to flash and actionscript 3. I've been reading a lot about
Preface: I am 100% new to the Flash and ActionScript world, doing research for
I'm new to Flex, Flash, and ActionScript. I'm attempting to create a video player
I'm new to actionscript 3. I want to create a textfield that is either

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.