PDA

View Full Version : Embeding Images in the swf file?


andres625
01-16-2009, 02:04 AM
Hello,

I am using a Canvas with a background image. At first I gave it an absolute path: http://uniandino.com/oraria/fondo1.jpg. The image isn't very big (50K), but it does take a few seconds to load when I view the swf in my browser. I then tried to pass it as a relative path: fondo1.jpg, but it still takes a few seconds to load. I was wondering if there was any way to include the image within the swf so that it wouldn't have to wait a few seconds while it loads it from an external file. Is there any way to do this? Or is there anything better than using the background image of Canvas to do this?

Here is the swf by the way: http://www.uniandino.com/oraria/huecos.swf

Thanks in advance!!!

Peter Cowling
01-16-2009, 04:13 PM
Yes you can embed images in a .swf file. Just search for flex embed assets, and the first result should be an Adobe article to get you started.

charlesshoults
01-16-2009, 04:47 PM
You can put something like this in the section with your variable definitions:

[Embed(source="assets/badges/MCII.png")] public var MCII:Class;

In my instance, I then do this:

private function init():void {
catLogo.source = MCII;

Although, I would take it easy with embedding images. It seems like if there are lot of images or large images, editing with Flex really starts to crawl.

Sekhar
01-16-2009, 04:56 PM
50K is nothing, are you sure it's the image that's slowing down the startup? There're many ways to speed up the start, the Flex docs have a full section. At the minimum, make sure you're not creating all your components at startup, but just the ones that're visible ("deferred creation").