View Full Version : resizing flash object problem

09-25-2008, 07:56 PM
Here is what I am trying to do.

I am trying to resize a flash file dynamically based on the information I grab from the object itself. My problem is not getting it to work, I have it working actually, but by itself.

My problem occurs when I have the objects loaded using AJAX. I can't post the entire code because of NDA agreements, but this one stumped me so I had to see if anyone had a better outlook on this than I do.

ok first this is how I am "injecting" the code into the page:

function getSimulator(content) {

var pContent, pHeader, pSimFile, pRevise;

pHeader = content.match(/<h2>(.*)<\/h2>/);
pRevise = content.match(/<p class="revised">(.*)<\/p>/);
pSimFile = content.match(/<SIMOBJECT>(.*)<\/SIMOBJECT>/);
pSimFile[0] = getDir() + "simulator/";

pSimURL = "http://" + getServerName() + getDir() + "/simulator/product.swf?feature="+pSimFile[1].replace(".swf","");

pContent = "<DIV id='debugDIV' style='display:none;'></DIV>" +
"<table border='0' cellpadding='0' cellspacing='0' style='margin-left:20px;'>"+
"<td id='featureHeading'>"+
"Simulator - " + pHeader[1] +
"</td>" +
"</tr>" +
"<tr>" +
"<td id='simwrapper' name='simwrapper'>"+
"<OBJECT CLASSID='CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000' ID='simulator' name='simObject' width='100%' height='100%'>"+
"<PARAM NAME='MOVIE' VALUE='" + pSimURL + "'>"+
"<PARAM NAME='BASE' VALUE='" + pSimFile[0] + "'>"+
"<PARAM NAME='MENU' VALUE='false'>"+
"<td class='revised'>"+
pRevise[1] +
"</td>" +
"</tr>" +
return pContent;

That basically takes the file ajax is pulling, detects the SIMOBJECT tag's and if they are there it then basically rewrites the content with the code for the flash embed.

Then after the code has been "written" to the page itself I call this function to grab the width and resize the flash embed.

function resizeFlash() {
var simulator = document.getElementById('simObject');
simulator.width = simulator.TGetProperty('/',8).value + "px";

The error I get is object required. However if I use an alert() before I specify the width it shows that the object does exist. So I am not sure what to do about this.

Like I said before. I can get this to work alone in it's own html file but when I introduce AJAX into the mix it screws it up.

Any thoughts or suggestions?

09-25-2008, 10:00 PM
When are you calling that function? Are you using window.onload? Have you tried it in Firefox? It may give you a better error message. Do you have a link to the page so we can see for ourselves?

09-25-2008, 10:45 PM
Unfortunately I cannot link to the page it is an internal web page (can only be viewed on a private network). I have not tried window.onload, but that wouldn't work using AJAX because the window has already loaded.

Also another downfall is that the website this is being used on when it was originally coded only supports IE 6+ (hey don't like at me, I didnt design it, although I would love to this internal website would be a gigantic overhaul, it consists of about 2 TB's of files/pages)

I can however post the code for when I am calling the function:

function loadpage(xmlHttp){
var pageTitle, pageContent;
if (xmlHttp.readyState == 4 && (xmlHttp.status==200 || window.location.href.indexOf("http")==-1)) {
//Extra coding was used for browser cross-compatibility
document.getElementById('showContent').innerHTML = "";
var showContentDiv = document.createElement('div');
pageContent = xmlHttp.responseText;
pContent = pageContent;

if (checkSimulator(pageContent))
pageContent = getSimulator(pageContent);

showContentDiv.innerHTML = pageContent;
xmlHttp = false;

As you can see, this function is called after the content has been added to the page content. The content shows up fine, it is parsing the xml/html file fine, and grabbing the correct flash file just fine. I just do not understand why it is telling me that it is not an object but when I check to see if it is an object with alert() it says it is.

I did view this page in firefox, it is telling me simulator is null . Which is what I said before (object required, meaning simulator wasnt being defined)