Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6621927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:20:11+00:00 2026-05-25T21:20:11+00:00

I have a javascript script that uses SWFobject to embed a flash player. When

  • 0

I have a javascript script that uses SWFobject to embed a flash player. When i got to embed the flash player with

swfobject.embedSWF(..)

i get an error reading that swfobject is undefined. I believe this is happening because our website caches the javascript for my application but doesn’t cache the swfobject.js file, so myApp.js, which calls swfobject.embedSWF(..) loads long before swfobject.js. I currently can’t change what’s being cached, so i came up with this work around:

while(!$(that.mediaPlayer).find('#'+that.playerID)[0]){
     console.log(that.playerID+' not defined');
     that.embedFlashPlayer(1,1);
}

...

this.embedFlashPlayer = function (width, height){
    var that = this;
    var playerID =  that.playerID;
    var server = document.URL.replace(/^.*\/\//,'').replace(/\..*$/,'');
    var flashvars = {};
    var flashSrc = "/flash/AS3MediaPlayer.swf?server"+server+"&playerID="+playerID;

    //parameters
    var params = {};
    params.movie = flashSrc;
    params.quality = "high";
    params.play = "true";
    params.LOOP = "false";
    params.wmode = "transparent";

    //attributes
    var attr = {};
    attr.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
    attr.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0";
    attr.width = "" + width;
    attr.height = "" + height;
    attr.id = playerID;
    //console.log("embedding flash object with id "+playerID);

    //command to embed flash object
     try{
           swfobject.embedSWF(flashSrc, "no-flash", width, height,"9.0.0","",flashvars,params);
     }catch(err){
      // I DON'T KNOW WHAT TO DO HERE
     }

     return true;
}

My code checks to see if the flash object has been written. If it hasn’t, it calls embed this.embedFlashPlayer() repeatedly in a while loop until the the div containing the swf can be found. The trouble is that this just loops forever. Any suggestion on what i can do in the try-catch block if swfobject is undefined? I am 90% sure this is because my script loads faster and is running the embedSwfObject command before the library has loaded, but i may be wrong. My script runs in $(function(){…}) command. Any theories, suggestions, ideas as to how i can resolve this would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:20:12+00:00Added an answer on May 25, 2026 at 9:20 pm

    while …? Use window.setInterval:

    ...
        var interval = window.setInterval(function(){
            //Code to check whether the object is ready or not.
            if($(that.mediaPlayer).find('#'+that.playerID).length){
                 clearInterval(interval);
            }
        }, 100); //Each 100ms = 10 times a second.
    ...
    

    You’re trying to use while for polling. setInterval is usually used instead of while, because (as you may have noticed), while causes the browser to “hang”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that uses some css/javascript tabs, they work on my
i have a dialog box that opens on pageload for a site. script type=text/javascript>
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have to maintain a server-side script written in JScript (NOT Javascript) that needs
I am currently working on rails3 application that uses jQuery. I have a javascript
I have a rotating slide show I'm working on that uses Javascript. I use
I have some code that uses JavaScript templates to create some HTML, including some
I have a shell script that creates Firefox profiles and then uses them to
I have a script that uses jQuery and CSS to position something at the
I have a script that uses jQuery to POST data through AJAX to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.