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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:05:55+00:00 2026-05-11T20:05:55+00:00

Calling channel.position on an ENTER_FRAME event, I notice that it’s not being updated every

  • 0

Calling channel.position on an ENTER_FRAME event, I notice that it’s not being updated every frame, but it looks more like every frame and a half.

var sound:Sound = new Sound(new URLRequest('music.mp3')); 
var channel:SoundChannel = sound.play(); // assume the sound is completely,
                                         // totally, 100% loaded

addEventListener(Event.ENTER_FRAME, function(e:Event):void{
   trace(  "Position : " + channel.position 
         + " - Frame : " + int(channel.position / 30));
});

will result in something along the lines of (30 FPS)

   ...
   Position : 1439.6371882086166 - Frame : 47
   // 48 is missing
** Position : 1486.077097505669 -  Frame : 49
** Position : 1486.077097505669 -  Frame : 49
   Position : 1532.517006802721 -  Frame : 51
   Position : 1578.9569160997733 - Frame : 52
   // 53 is missing
** Position : 1625.3968253968253 - Frame : 54
** Position : 1625.3968253968253 - Frame : 54
   Position : 1671.8367346938776 - Frame : 55
   // 56 is missing
   Position : 1718.2766439909296 - Frame : 57
   ...

Has anyone noticed this behavior before? Are there any techniques for determining which ‘frame’ of audio is being played, knowing this inaccuracy?

  • 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-11T20:05:55+00:00Added an answer on May 11, 2026 at 8:05 pm

    Yes, this is normal behaviour because events are threaded and therefore will call their delegates whenever their thread has priority. Printing to the console is also threaded so it may not always be printing messages at the right time either. Infact, the issue you’re seeing is probably just a printing issue. Try boosting your framerate, see what happens.

    Still, in order to be more accurate you could try using the timer class. Typically, you can make the ticks happen much faster than your frames, meaning the margin for error will be lower. Still, you’re using the event so there may be some drift.

    To compensate for this, you can check the time versus the frames to determine the offset. This allow you to correct for any drift.

    EDIT: This example was pulled straight from this page in the ActionScript 3 documentation, notice the positionTimer they’re using:

    package {
        import flash.display.Sprite;
        import flash.events.*;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.net.URLRequest;
        import flash.utils.Timer;
    
        public class SoundChannelExample extends Sprite {
            private var url:String = "MySound.mp3";
            private var soundFactory:Sound;
            private var channel:SoundChannel;
            private var positionTimer:Timer;
    
            public function SoundChannelExample() {
                var request:URLRequest = new URLRequest(url);
                soundFactory = new Sound();
                soundFactory.addEventListener(Event.COMPLETE, completeHandler);
                soundFactory.addEventListener(Event.ID3, id3Handler);
                soundFactory.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                soundFactory.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                soundFactory.load(request);
    
                channel = soundFactory.play();
                channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
    
                positionTimer = new Timer(50);
                positionTimer.addEventListener(TimerEvent.TIMER, positionTimerHandler);
                positionTimer.start();
            }
    
    
            private function positionTimerHandler(event:TimerEvent):void {
                trace("positionTimerHandler: " + channel.position.toFixed(2));
            }
    
            private function completeHandler(event:Event):void {
                trace("completeHandler: " + event);
            }
    
            private function id3Handler(event:Event):void {
                trace("id3Handler: " + event);
            }
    
            private function ioErrorHandler(event:Event):void {
                trace("ioErrorHandler: " + event);
                positionTimer.stop();       
            }
    
            private function progressHandler(event:ProgressEvent):void {
                trace("progressHandler: " + event);
            }
    
            private function soundCompleteHandler(event:Event):void {
                trace("soundCompleteHandler: " + event);
                positionTimer.stop();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
Calling Html.RenderPartial(~/Views/Payments/MyControl.ascx); from a view works if MyControl.ascx is a control that directly inherits
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
When calling functions that always throw from a function returning a value, the compiler
I’m calling a web service via WCF (w/ .NET 4.0) that requires basic HTTP
i am running 12 threads .function which these threads are calling is not having
I've been looking through forums all day, but I'm not figuring it out. I'm
I have a feeling that this should really not be all that difficult, yet
I'm calling FB.login() on a click event in my application. The dialog pops up
I have an AS3 function that I need to end with calling another function.

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.