开发者

Load dynamic swf generated by Flex 3 in a div

I am trying to load the dynamic SWF file which has 100% width and h开发者_StackOverfloweight ,generatd by my flex 3 in a div. using Jquery load() function. The div wherein i am trying to load is visible for sometime but after that my SWF comes out of div and takes whole viewport area to display the SWF. I have tried to provide fixed height and width to div but no luck. I want to load that SWF file in that particular div only. Could anybody please help me with this.


Struture is very simple

$(#divID).load('sample.swf');

> <div id="divID"
> style="height:400px;height:400px;">
> &nbsp; </div>

where sample.swf is generating dynamically and has 100% height and width.


I would be very surprised if this worked at all. AFAIK, a flash/flex object needs to be inserted in the DOM in a specific way (using <embed> or <object>).

A very nice (and free) javascript component that does everything you need is flashembed:

http://flowplayer.org/tools/flashembed.html


To load the generated swf file into a certain div in your page instead of occupying the whole page, follow the three steps provided bellow. But first the reason for this behavior is that the generated "AC_OETags.js" uses "document.write()" which means printing the content directly to the page. In this solution we will alter this behavior (simply by not using document.write) but using functions returns and a JQuery call instead.

  1. In AC_OETags.js change the function AC_Generateobj() as follows:

    [Last line of code] : replace document.write(str); with return str;
    
  2. In AC_OETags.js change the function AC_FL_RunContent() as follows:

    [Last line of code] : replace AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs); with return AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
    
  3. So now both functions will return the results instead of writing to the page. The last step is to assign the return of the AC_FL_RunContent call to a variable and append it to the div in your html using JQuery:

    var mediaContent = AC_FL_RunContent( ... flash required parameters... );
    $('#YOUR_DIV_ID').replaceWith(mediaContent);
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜