View Full Version : preloader question
mmezo
11-14-2008, 06:02 PM
hey all, i had a question about preloaders. im currently putting together a site that has a few pages with embedded flash elements - id like to use the same preloader for all the flash files.
i know i can easily just create a preloader for each file based on one common style, but i was wondering if there is perhaps some way to pass a VAR with the SWFs url from the page to the preloader, rather than hard-coding it into the preloder? or something to that effect?
raydowe
11-14-2008, 06:49 PM
That is by far the best idea. What I would do is create a preloader that gets passed the url of the swf through flashvars, then loads it and displays it.
The best way in my opinion is to use Swfobject http://code.google.com/p/swfobject/
Just create and object in javascript like:
var myFlashVar = {pathtoswf:'myswfpath/myswfname.swf'};
and pass it in using 'swfobject.embed(a,b,c,d,e...)';
the passed in value can then be referenced in flash using:
var thepathtomyswf:String = root.loaderInfo.parameters['pathtoswf'];
The swfobject site also has documentation on it's use and the use of flashvars.
Hope that helps.
mmezo
11-15-2008, 10:00 PM
thats funny - i just came upon swfobject while poking into flash version detection. i tried what you recommended and i think i have it working, thank you so much!
mmezo
11-17-2008, 07:24 PM
Raydowe - i had one more quick question regarding this: is it possible either tell the preloader NOT to have a bg color (just use whatever is there or use the bg of the swf its loading), or if not that can i use flashvars to set the bg color of the file? the problem im trying to solve is that there are 2 different background colors the flash may appear against.
there wouldnt happen to be any list of common or acceptable flashvars, is there?
raydowe
11-17-2008, 08:22 PM
http://code.google.com/p/swfobject/wiki/documentation
Search the page text for "color". SWFobject takes in a parameter that specifies the background colour, but I think that is just until the swf has been loaded.
What you would probably want to do is add another property to the flashvar object, such as:
{path:'Something, color:'0xeaeaea', somethingElse:whatever.....}
Then you can access this from within the preloader swf and draw a rectangular box to cover the background in the desired colour. You can even pass in a few different colours to draw the background, the load bar, maybe a colour for text...
mmezo
11-17-2008, 08:46 PM
thank you for the ideas! that makes senses if the bgcolor attribute doesnt function how id like.
hey, one thing i noticed and cant seem to find any info on - swfobj wont allow the use of percentages for the swf size?
raydowe
11-17-2008, 08:54 PM
I'm not positive but I believe you can the width and height property default to pixels but can be set to percent by using "100%"
mmezo
11-18-2008, 01:15 PM
yeah, id tried that and it doesnt seem to work (maybe its a browser thing, but if it it doesnt work in FF...)
ill poke around and see if i can find something, i think i saw there was a forum linked from that site that may have some info or work arounds. Thank you again for all the help, youve been great!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.