reparenting original div with swfobject using jquery append

198 views
Skip to first unread message

Ante Predovic

unread,
Apr 5, 2012, 12:07:04 PM4/5/12
to swfo...@googlegroups.com
I am using swfobject embed swf method and all works well.

I have this in head:


           var flashvars = {};
            var params = {};
            var attributes = {};
            attributes.id = "flashPreview";
            params.quality = "high";
            params.scale = "noscale";
            params.salign = "tl";
            params.wmode = "transparent";
            params.bgcolor = "#111";
            params.devicefont = "false";
            params.allowfullscreen = "true";
            params.allowscriptaccess = "always";
            swfobject.embedSWF("preview.swf", "flashPreview", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

I have a div in the body:

<div id="flashPreview">
                     <a href="http://www.adobe.com/go/getflashplayer">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                     </a>
                 </div>

I also have some functions in my flash and I use External Interface to communicate with jquery which works fine as well.

The problem comes when I take this div I used for embedding swf, and reparent that div to another element in the dom.

After that my flash methods I call from jquery are not recognized any more.

Aran Rhee

unread,
Apr 5, 2012, 12:26:29 PM4/5/12
to swfo...@googlegroups.com
I am not really sure how you are reparenting etc, so I can't comment directly. How are you referencing the dom element?

You can do a check that it exists and the method is available with something like:

var obj = document.getElementById("flashPreview");
if (obj && typeof obj.myExternalInterfaceMethod != "undefined") 
{
obj. myExternalInterfaceMethod("foo");
}

I have never tried to re-parent a swf and then call EI methods on it, so I am unsure if this breaks something. If it is failing, I wonder if you might need to re-init the addCallBack() methods (maybe the connection gets broken when reparenting?)

Two things I can think to do:

1) destroy and re-embed the swf after re-parenting
2) There is some code in this article which does some availibility checking (on a timer etc). It could re-connect and broken addCallBacks after the reparenting has happened ( http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cb1.html )


Aran


--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/MZVejkmbh-EJ.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.

Reply all
Reply to author
Forward
0 new messages