Using sound and Image files

3 posts

Flag Post

I am writing a program in Actionscript using FlashDevelop. Using URLRequest, I am loading image and sound files perfectly fine when the program is run through FlashDevelop. The files are located in bin with my HTML and swf files. However, when I run it using the browser (Chrome), the sound files works fine but the image does not load. I would think that it is a problem with the path, but the mp3 plays just fine, so I know that it can’t be that.

Any ideas about what it could be?

Flag Post

Do these resources need to be loaded while the application is running? If not, I suggest you embed them with your .swf file. For instance:

		[Embed(source = "../png/Collectionbgd.png")]
		private static const Background:Class;
		private static const background:Bitmap = new Background();

In my project directory I have a ‘src’ subdirectory of course, but also a ‘png’ subdirectory where I store images. Collectionbgd.png is one of them. The code above looks it up at compile time and shoves it into the .swf file, so once my .swf is compiled it is no longer dependent on that image being anywhere in range. It’s included with the file, and an instance of it is always available for that class as the Bitmap ‘background’.

You can do it for sounds as well, and I think for fonts (but I don’t know the details of that.)

Flag Post

My problem with embedding is that I have a ton of images I need to load. Rather than making a separate class for each of my enemies, I am using the constructor to instantiate the type of enemy I need based on constants. Also, I need a number of different frames for animations (I am using a Timer to animate). It would be so much easier to load only the images I need depending on the String that is passed to the constructor. I have seen a number of things about security issues. If I add the loader to the Main Sprite, the images load without a problem, but I can’t exactly do that. Do you anything about security issues or anything like that?