So are you in control of the page, or does your script have to work on some
3rd party site?
The simplest way to maintain styles/position is to style a wrapper div and
replace a child div inside the wrapper with your swf:
<div id="styledParent">
<div id="replaceMeWithFlash">
alt content in here (perhaps also styled until replaced)
</div>
</div>
You can also check out the api method to create css on the fly:
swfobject.createCSS(selStr, declStr, mediaStr, newStyleBoolean)
Exposes SWFObject's internal cross-browser method to create a dynamic
stylesheet. It's most important feature is that it can be called before the
DOM of a page is loaded. Based on a
solution<http://www.bobbyvandersluis.com/articles/dynamic_css/index.html>
by
Bobby van der Sluis:
- selStr (String, required) represents a CSS selector
- declStr (String, required) represents a CSS declaration
- mediaStr (String, optional) to indicate the CSS media type (media type
scree is the default, SWFObject 2.2+)
- newStyleBoolean (Boolean, optional) to indicate whether a new dynamic
style element should be appended to the head of the HTML document, or that
SWFObject should reuse a possible earlier created dynamic style element
(default, SWFObject 2.2+)
>From SWFObject 2.2 onwards this method will by default append new dynamic
styles to an earlier created dynamic style sheet (if available).
An example:
if (swfobject.hasFlashPlayerVersion("6.0.0")) {
// Overwrite regular CSS used for alternative content to enable Full
Browser Flash
swfobject.createCSS("html", "height:100%;");
swfobject.createCSS("body", "margin:0; padding:0; overflow:hidden;
height:100%;");
swfobject.createCSS("#container", "height:100%;");
}
Basic example
page<http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_api_createcss.html>
Advanced example page
<http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_api_createcss2.html>
In some use cases, perhaps SWFObject 2.x will not be as simple or applicable
is 1.x notation. Part of the overall goals of the 2.x rewrite was to be a
standards based as possible, so the innerHTML writing method was revised.
SWFObject 1.x, while not officially supported any more does work, so feel
free to continue to use it if it works better for what you need to achieve.
Cheers,
Aran
On Fri, Feb 5, 2010 at 11:57 AM, anobre <[email protected]> wrote:
> Thx for the quick reply Aran,
>
> As i said, i'm new to 2.x and i'm just getting an idea of how it works
> and the amount of work needed to adapt it to my current needs
>
> On css, Imagine i want to dynamically add flash content to a
> div#flashhere and that i don't know (forehand) the css styles (inline
> styles or other) applied to it,
> example: div#flashhere style="margin-top:150px"
> Is there an easy way to maintain that style without involving creating
> more selectors?
>
> Imagine now that my script also needs to append a new child selector
> to div#flashhere:
> $('#flashere').append(<div style='position:absolute'>text node</div>")
>
> (It won't work with an object)
>
> My need (advertising related) is to use swfobject to write inside
> selectors; as it involves a lot of DOM scripting. I'm just not seeing
> how 2.x can simplify what i currently have.
>
>
> Best,
> AN
>
>
>
> On Feb 4, 11:55 pm, Aran Rhee <[email protected]> wrote:
> > Sorry, I misinterpreted your original question.
> >
> > You are correct, in that with SWFObejct 2.x the target element is
> completely
> > replaced. If you do not specify a new id, then it will inherit the id of
> the
> > target element. You can specify a new id in the attributes object if
> > desired.
> >
> > Just to understand what you are wanting to achieve (or the problem you
> are
> > having with the 2.x functionality) a bit better, are you looking for a
> way
> > to maintain the CSS styling etc which was on the target element? Or is
> there
> > something else which you are wanting to do?
> >
> > Aran
> >
> > On Fri, Feb 5, 2010 at 10:44 AM, anobre <[email protected]> wrote:
> > > Sry but read it again and didn't find any line which specifies how we
> > > can override swfO2 default behaviour of replacing vs appending
> > > (innerHTML) in the container element. Am i missing something?
> >
> > > SWFObject 2 replaces your entire alternative HTML content block,
> > > including the referenced HTML container element, for Flash content
> > > when enough JavaScript and Flash support is available, while SWFObject
> > > 1.5 only replaces the content inside the referenced HTML container.
> > > When you don't specify an id attribute, the object element will
> > > automatically inherit the id of the HTML container element of your
> > > alternative content.
> >
> > > On Feb 3, 2:50 am, Aran Rhee <[email protected]> wrote:
> > > > Have you read the docs?
> > >http://code.google.com/p/swfobject/wiki/documentation
> >
> > > > If you are looking for something familiar to 1.x markup, then read
> the 3
> > > > steps in the How to embed Flash Player content using SWFObject
> *dynamic
> > > > publishing *section.
> >
> > > > We also provide a bunch of links to tutorials (including video) here:
> > >http://code.google.com/p/swfobject/wiki/links
> >
> > > > I also suggest you use the online code generator to help you write
> this
> > > code
> > > > without errors:http://code.google.com/p/swfobject/wiki/generator
> >
> > > > We ask that all new users use the resources provided and try to get a
> > > proper
> > > > understanding of how to use SWFObject. If you are still having some
> > > specific
> > > > issues after going through all the of the above, feel free to post it
> to
> > > the
> > > > list...
> >
> > > > Aran
> >
> > > > On Wed, Feb 3, 2010 at 1:37 PM, anobre <[email protected]>
> wrote:
> > > > > Hi Guys,
> >
> > > > > I'm new to 2.xx version.
> > > > > How do i embed a swf inside a selector? (like method write() did in
> > > > > 1.x)?
> >
> > > > > Best,
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "SWFObject" group.
> > > > > To post to this group, send email to [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<swfobject%[email protected]>
> <swfobject%[email protected]<swfobject%[email protected]>
> >
> > > <swfobject%[email protected]<swfobject%[email protected]>
> <swfobject%[email protected]<swfobject%[email protected]>
> >
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/swfobject?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "SWFObject" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<swfobject%[email protected]>
> <swfobject%[email protected]<swfobject%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/swfobject?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "SWFObject" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<swfobject%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/swfobject?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"SWFObject" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/swfobject?hl=en.