[SWFObject] insert swf via css?

Rostislav Hristov rostislav.hristov at gmail.com
Fri Oct 20 13:19:46 PDT 2006


Probably something like this is possible:

In the HTML you may have 2 classes applied to the same object, the
first is content specific and the second is a pointer to the SWFObject
objects.
<div class="flash-banner swfobject">Ad content.</div>

In the CSS you specify only the first class, it hides the text which
is for search engines and displays an alternative image content.
.flash-banner {
    text-indent: -9999px;
    background: #FFFFFF url(banner.jpg) no-repeat;
    width: 468px;
    height: 60px;
}

The JS collects references to all the objects with class 'swfobject'.
The standard SWFObject embedding is done with the parameters available
in the CSS. There should be a convention for the img/swf file names.
An option for customizing the general SWFObject settings will be nice
for parameters like menu=false.
window.onload = function() {
   var swfobjects = getElementsByClassName();
   var width = getRuntimeStyle(swfobjects[0], 'width');
   var height = getRuntimeStyle(swfobjects[0], 'height');
   var bgcolor = getRuntimeStyle(swfobjects[0], 'background-color');
   var img = getRuntimeStyle(swfobjects[0], 'background-image');
   var swf = (img.replace(/url\(/, '')).replace(/.(gif|jpg)\)/, '.swf');
   // swfo = new SWFObject...
}


Another valid approach will be to use a similar CSS for
width/height/bgcolor and specify swf url that can be rewritten
serverside to serve a blank image. SWFObject can parse the CSS value
and call the swf url with a reserved (?swf=true) parameter so that the
server can serve the real swf content.





On 10/20/06, Geoff Stearns <geoff at deconcept.com> wrote:
> no, not in all browsers at least...
>
> theoretically you could do it in IE since it supports expression()
> statements in css, but then all the other browsrs wouldn't work
>
>
>
> On Oct 20, 2006, at 10:12 AM, Jim Berkey wrote:
>
> > Is there any way to insert a swf with swfobject in the css file,
> > for easy insertion? I'd like to insert a swf 'bullet' in every h2
> > div via css:
> >
> > Adding a bitmap bullet is easy:
> > h2 {
> > background: transparent url("img/large_bullet.png") no-repeat 0;
> > }
> >
> > This does not work:
> > h1 {
> > background: transparent url("swf/Smiley_01.swf", "icon", "25",
> > "25", "7", "#fff") no-repeat 0;
> > }
> >
> > Can this be done?
> > jimbo
> > _______________________________________________
> > SWFObject mailing list
> > SWFObject at lists.deconcept.com
> > http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com
>
> _______________________________________________
> SWFObject mailing list
> SWFObject at lists.deconcept.com
> http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com
>


-- 
EnFlash - It's all about features...
http://www.asual.com/enflash/



More information about the Swfobject mailing list