[SWFObject] SWFObject flashVars to pull in an image to be used as abackground

Aran Rhee aran.rhee at qdc.net.au
Mon Dec 11 14:31:32 PST 2006


Chris.
 
Flash lets you load images into any "movieclip" object.
 
If you are using flash 6 or less, you can use loadMovie(), or flash 7/8, you
can use the better movieclipLoader class (it gives you easier hoooks into
progress and complete events).
 
As an exmaple for f 7/8, you woulod do something like this:
 
 
// on your swfObject code for you HTML page, add a var like this:
// use full path to images, so IE doesn't cache from the wrong location

so.addVariable("bgimg", " <http://www.mysite.com/someimage.jpg>
http://www.mysite.com/someimage.jpg");

 
//INSIDE FLASH
// All variables passed from swfObject are available on the _root timeline
with the same names you passed in. In this case "bgimg"
//
 
// START FLASH CODE
//
// create object to "listen" to events from the movieclip loader
var loadListener:Object = new Object();

// functions for handling the various events from the loader
// add or remove as necessary

loadListener.onLoadInit = function(target_mc:MovieClip):Void {
    trace(">> loadListener.onLoadInit()");
    trace(">> =============================");
    trace(">> target_mc._width: " + target_mc._width); // your image
width/height
}
 
loadListener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number,
bytesTotal:Number):Void {
    trace(target + ".onLoadProgress with " + bytesLoaded + " bytes of " +
bytesTotal);
}

// create the movieclip loader
var mcLoader:MovieClipLoader = new MovieClipLoader();
// add the lister object to receive events from the loader
mcLoader.addListener(loadListener);

// create a movielcip to load the image into
var imgBGMC:MovieClip = this.createEmptyMovieClip("imgBGMC",
this.getNextHighestDepth());
// load the image loaction from an swfObject flash vars variable
mcLoader.loadClip(bgimg, imgBGMC);
 
 
This is really more of a general flash question though , and you'll have a
better response in beginner flash lists / forums.
 
Aran 
 


  _____  

From: swfobject-bounces at lists.deconcept.com
[mailto:swfobject-bounces at lists.deconcept.com] On Behalf Of Chris V. Gnarra
Sent: Tuesday, 12 December 2006 4:24 AM
To: swfobject at lists.deconcept.com
Subject: [SWFObject] SWFObject flashVars to pull in an image to be used as
abackground


Hi: 
 
I was wondering if anyone knew how to parse an image to be used as a
background in an SWF, for arguments sake a JPG into a flash file using the
SWFObject flashVars option and actually have it sitting behind the main
flash stage area?
 
I am pretty new to flash but more so actionscript and would love to know how
to do this as I know images can be pulled into the flash via the SWFObject
but I do not know how to pull an image in to be used as a background and
actually have it sit behind the main flash stage. If anyone can help here I
would be immensely grateful and appreciated.
 
Many thanks.
 
 
 
 
Chris.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deconcept.com/pipermail/swfobject-deconcept.com/attachments/20061212/db65ae97/attachment-0005.htm>


More information about the Swfobject mailing list