Hi All,

I'm building a modular video application with a bunch of Flex
components and part of the requirement is to use javascript as a
controller to communicate between my data model and my flex component
views.

The first part of this task involves embedding components to specific
div tags in a html page. I've got this to work great but it's just
really really really slow - like 10 seconds slow to embed 7 swfs. I've
tested and the issue is to do with swfobject (possibly because of the
way i've coded it).

Here's my HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
        <head>
                <title>AMX JS Player</title>
                <meta http-equiv="Content-Type" content="text/html; 
charset=utf-8" /
>
                <script type="text/javascript" 
src="./html/swfobject/swfobject.js"></
script>
                <script type="text/javascript" src="./html/amxjs/player.js"></
script>
        </head>
        <body>
                <div id="AMXJSPlayer_Model">
                        <p>Model</p>
                </div>
                <div id="AMXJSPlayer_Category">
                        <p>Category View</p>
                </div>
                <div id="AMXJSPlayer_Video">
                        <p>Video View</p>
                </div>
                <div id="AMXJSPlayer_Meta">
                        <p>Meta View</p>
                </div>
                <div id="AMXJSPlayer_Latest">
                        <p>Latest View</p>
                </div>
                <div id="AMXJSPlayer_Programme">
                        <p>Programme View</p>
                </div>
                <div id="AMXJSPlayer_List">
                        <p>List View</p>
                </div>
        </body>
</html>

And here is the simple javascript i'm using in addition to
swfobject.js:

var FLASH_VERSION = "9.0.124";
var DIV_IDS = new Array("AMXJSPlayer_Model", "AMXJSPlayer_Category",
"AMXJSPlayer_Meta", "AMXJSPlayer_Video", "AMXJSPlayer_Latest",
"AMXJSPlayer_Programme", "AMXJSPlayer_List");
var moduleDivs = new Array();
var moduleSwfs = new Array();

if (swfobject.hasFlashPlayerVersion(FLASH_VERSION))
{
        swfobject.addDomLoadEvent(validateDivs);
}
else
{
        alert("No Flash Player or older version than is required!");
}

function validateDivs()
{
        for (var i=0; i<DIV_IDS.length; ++i)
        {
                var divId = DIV_IDS[i];
                var currentDiv = document.getElementById(divId);
                if(currentDiv)
                {
                        moduleDivs.push(currentDiv);
                }
                else
                {
                        //no div available
                }
        }
        for (var j=0; j<moduleDivs.length; ++j)
        {
                var validDiv = moduleDivs[j];
                initializeSwf(validDiv);
        }
}

function initializeSwf(divId)
{
        var divId = divId.id;
        var swfName = divId+".swf";
        var properties = { data:swfName, width:"100", height:"100"};
        var parameters = { menu:"false" };
        var theSwf = swfobject.createSWF(properties, parameters, divId);
        moduleSwfs.push(theSwf);
}

At first i thought it might be my flex swfs, so i created a
framework.swz RSL...no difference.
Then i decided to remove any trace of Flex and just published
actionscript only swf's so file size went from 100800 bytes to 600
bytes... still no difference

So it's defo something to do with swfobject. I also tried the static
embed approach but to be honest although it did work, it's a nightmare
to ensure our clients will copy the code exactly as required when
creating their own pages. Just adding a div with specific id to swap
out is the preferred option.

Anyone got any ideas what's happening in the background when i'm
calling 'createSwf' and is there any way to make things happen any
faster?

Cheers
Doug

-- 
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.

Reply via email to