[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Load an image into a flash application from an external location

I am having a flash application built and need the following :

I have an image that is stored in a folder called 'Images'. I need this image called main.jpg to be shown as the background in a flash .swf but I do not want the image to be stored internally to the flash file. It's location must stay external to the flash file in this 'images' folder.

The reason I need this is becasue this flash file will be used many times, and every time it is used again the image (main.jpg) will change and I want to be able to simply replace the image in the 'Images' folder rather than having to do it through Flash, as I do not have adobe flash.

How can I do that
0
nathan1038
Asked:
nathan1038
1 Solution
 
deepanjandasCommented:
In AS3, user Loader Class to load image.
 
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;

var image_path:String = "imagse/my_image.jpg";
var loader:Loader;
var request:URLRequest;

public function loadImage()
{
    loader=new Loader();
    request=new URLRequest(image_path);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete, false, 0, true);
    loader.load(request);
}

function onComplete(event:Event):void {
    addChild(loader);
    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onComplete);
}

loadImage();

Open in new window


Warm Regards
Deepanjan Das
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now