Results 1 to 5 of 5

Thread: setTimeOut() functions not working in AS3

  1. #1
    Join Date
    Apr 2009
    Posts
    65

    setTimeOut() functions not working in AS3

    I was developing an application in the AS3 and for the immediate connection with the other variables i need to use the "this" Keyword. for example In setTimeout AS3 method i wanted to develop an function where need to setup clock settings which out be something as follows.

    setTimeout(function(){ this.alpha = 0.5}, 2000); // does not work.

    But when i have upgraded to AS3 this code no longer works.

    Any ideas on how I can make this code work for AS3.

  2. #2
    Join Date
    Jan 2006
    Posts
    211

    Re: setTimeOut() functions not working in AS3

    I suppose you need to go through the following program settings

    Code:
    setTimeout(A2secTimer(this), 2000);
               {
                 public function A2SecTimer(mc:MovieClip)
                          {
                          mc.gotoAndStop( mc.currentframe +1);
    
                           }
                 }

  3. #3
    Join Date
    Dec 2008
    Posts
    183

    Re: setTimeOut() functions not working in AS3

    The problem would be that SWF file isn't fully loaded by the time you try to call it. The flash player version you have loaded might be taking long time to load and to initiate SWF file.

    And to achieve that you need to make a call from the SWF file to a javascript function when it's loaded and you need to put your javascript rather than in the page loading handler that you seem to be doing now. That way you know that your flash application is properly initialized by then. The ExternalInterface class you are using has methods to let you call back into the javascript.

  4. #4
    Join Date
    Mar 2008
    Posts
    258

    Re: setTimeOut() functions not working in AS3

    The setInterval() and setTimeout() functions in AS3 were the two most commonly used ways of calling a function after a specified amount of time had lapsed. But in ActionScript 3 Timer class and its functions basically stored in flash.utils package. and the classes from these package contains all the functionality that never been utilized to need for time-based Applications. In order to implement the class, you first need to import the flash.utils package. The Timer constructor expects one argument that represents the desired delay in milliseconds between function calls. But you need to consider about an optional seconds argument that determines the number of times the function call has made. The default value set for this is 0, which means that it will call the function indefinitely. If function has been replicated the functionality of the deprecated setTimeout() function, you can simply pass 1 as the value for this parameter.

  5. #5
    Join Date
    Mar 2012
    Posts
    1

    ThumbsUp Re: setTimeOut() functions not working in AS3

    Please keep semicolon after this.alpha = 0.5 and try working
    it may help

Similar Threads

  1. Replies: 4
    Last Post: 03-05-2012, 08:24 AM
  2. Working with NPV functions on Microsoft Excel
    By Irritator in forum MS Office Support
    Replies: 5
    Last Post: 17-02-2012, 07:45 PM
  3. Replies: 4
    Last Post: 03-04-2010, 05:00 AM
  4. Functions in PHP
    By Gyan Guru in forum Guides & Tutorials
    Replies: 3
    Last Post: 13-12-2008, 06:20 PM
  5. Functions keys are not working on Windows XP
    By Dakshi in forum XP Hardware
    Replies: 2
    Last Post: 12-10-2008, 12:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,284,840.28965 seconds with 17 queries