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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:54:49+00:00 2026-05-13T12:54:49+00:00

I’m having some trouble getting Haxe to play audio files in Flash 8. At

  • 0

I’m having some trouble getting Haxe to play audio files in Flash 8.

At the top of my hx file, I have:

import flash.MovieClip;
import flash.Sound;

and, within the class itself, I preload a lot of image files along with the names of the audio files.

The idea is to do a slideshow with audio content. Basically, display the first slide and play the audio associated with it.

Then, once that audio is finished, move on to the next slide and next audio file. I have the slides fading in and out okay but when I tried to add sound, nothing comes out the speakers.

The following code is what I’m doing – the sound file associated with audios[0] never starts playing and I’m at a loss as to why.

class Whatever {
    static var master : MovieClip;
    static var slides : Array<MovieClip>;
    static var audios : Array<String>;
    static var sound  : Sound;

    function new () {}

    static function main () {
        master = flash.Lib.current;
        slides = new Array<MovieClip> ();
        sound = new Sound (null);

        var app  : Whatever = new Whatever ();
        var num  : String;
        var j    : Int;
        var clip : MovieClip;

        // There are 12 pictures in this test, image[001-012].jpg.
        // Each has an associated audioNNN.mp3 file.

        for (j in 1...13) {
            // Right-justify, zero fill.

            num = "" + j;
            if (j <  10) num = "0" + num;
            if (j < 100) num = "0" + num;

            // Load each image, hiding all but the first.

            clip = master.createEmptyMovieClip ("clip_" + num, master.getNextHighestDepth());
            clip.loadMovie ("image" + num + ".jpg");
            if (j > 1) clip._alpha = 0;
            slides.push (clip);

            // Make another list of the audio files.

            audios.push ("audio" + num + ".mp3");
        }

        // Start the first audio file.

        sound.loadSound (audios[0], true);
    }
}
  • 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-13T12:54:49+00:00Added an answer on May 13, 2026 at 12:54 pm

    Silly me!

    It turns out that I just forgot to allocate the array before pushing values on to it. Why the runtime lets you do that without an error is a separate question.

    All I had to do was change the code from:

    slides = new Array<MovieClip> ();
    

    to:

    slides = new Array<MovieClip> ();
    audios = new Array<String> ();
    

    so that the audio array is created properly.


    Regarding why the pushing to a non-existent array didn’t get caught by the runtime, there’s an interesting snippet in the Professional haXe and Neko book (which only arrived today and looks like it’s going to return my investment very quickly, which is why I don’t mind giving it a shameless plug) that explains it, pretty much exactly the situation I encountered:

    So, now that you can see what you’re up against, take a look at both Neko and Flash when generating an exception:

    class UncaughtException {
        public static function main() {
            var t : Array <String> ;
            t.push("me");
        }
    }
    

    Compile the preceding class for both Neko and Flash, and then run them both. When run, the Flash player should display a blank screen, while the Neko application will generate the following text:

    Called from  line 1
    Called from UncaughtException.hx line 6
    Uncaught exception - Invalid field access : push
    

    This is an uncaught exception, which means it is an exception that you have not caught and dealt with in your code. The problem with the preceding class is that the Array t was not instantiated before the method push was called, so as far as the virtual machine is concerned, there is no method called push available.

    Now, the fact of the matter is, the Flash virtual machine would have hit the same wall that the Neko virtual machine encountered, except that the Flash virtual machine chose to ignore the error and continue as normal. Does this mean the exception was even generated? Maybe, but, like most invisible pests, you’ll need to catch one to prove it exists.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a reasonable size flat file database of text documents mostly saved in
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text

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.