Hi there. I am completely new to Flash, so I'm blank on this one, but haven't been able to find help on this specific subject either. I want a SWF movie to load an URL from a query () and apply it as a background image. I'm not even sure if it's possible to query an URL in an URL, but I guess it's worth a try. Thanks in advance.

Dani AI

Generated

Yes — a SWF can accept an image URL as a parameter and load that image as a background. For embedded SWFs, pass the value via FlashVars; for direct links the SWF will expose query parameters through the loaderInfo.parameters object (AS3) or by parsing _root._url (AS2). was right to ask for clarity: URL-encode the image URL when you pass it, and decode it in the SWF. 's point about backgrounds is incorrect — the display list lets you put loaded content behind other display objects (use addChildAt(..., 0) or an empty movie clip at a low depth).

A minimal AS3 pattern (document timeline or class) — read the parameter, load the image, put it behind other content, and optionally scale:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.LoaderInfo;

var params:Object = LoaderInfo(root.loaderInfo).parameters;
var imgURL:String = params["img"];

if(imgURL){
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
    loader.load(new URLRequest(decodeURIComponent(imgURL)));
}

function onLoaded(e:Event):void {
    var bg:* = e.target.content;
    bg.smoothing = true; // if it's a Bitmap
    addChildAt(bg, 0);   // ensure background
    // resize logic here if needed
}

Quick tips: always URL-encode the parameter, check for cross-domain policy if you need pixel access (display-only usually works), handle stage resize to keep the background fitted, and provide a fallback image if the param is missing. Note: Flash Player reached end-of-life on December 31, 2020, so use this only in environments that still support SWF playback.

Recommended Answers

All 2 Replies

pls write ur querry clear, the way in which u write ur querry is not clear what exactly u want?

Hi there. I am completely new to Flash, so I'm blank on this one, but haven't been able to find help on this specific subject either. I want a SWF movie to load an URL from a query () and apply it as a background image. I'm not even sure if it's possible to query an URL in an URL, but I guess it's worth a try. Thanks in advance.

Moving images usually can't be in the background. The player for a moving image will usually place itself on top.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.