SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can you make a .js file load DYNAMICALLY load an object?

    ok due to the new lawsuit with MS i need to use a JS file to embed my flash to prevent it being deactivated. i got it to work with this .js file containing:
    Code:
    var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    if(hasRightVersion) {  // if we've detected an acceptable version
        var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
        + 'width="790" height="457"'
        + 'codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
        + '<param name="movie" value="ringSlide.swf" /><param NAME="wmode" VALUE="opaque" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
        + '<embed src="ringSlide.swf" quality="high" bgcolor="#ffffff" wmode="opaque"'
        + 'width="790" height="457" name="ringSlide29" align="middle"'
        + 'play="true"'
        + 'loop="false"'
        + 'quality="high"'
        + 'allowScriptAccess="sameDomain"'
        + 'type="application/x-shockwave-flash"'
        + 'pluginspage="https://www.macromedia.com/go/getflashplayer">'
        + '<\/embed>'
        + '<\/object>';
        document.write(oeTags);   // embed the flash movie
      } else {  // flash is too old or we can't detect the plugin
       window.open("indexOLD2.php", "_self");
      }
    and putting this in the actual page:
    Code:
    <script src="ringslide.js"></script>
    but i dont want to recreate that js page for everypage that uses flash so is there a way i can have ringslide.swf as a variable and use the same .js page for everypage but pass a variable for it to load which .swf file?? if so can someone explain to me how to do that?
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Location
    Lucknow, UP, India
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you will have to change you code a bit to make it dynamic

    1) replace all "ringSlide.swf" with a variable, say flashFile.
    2) on the page where you include it, do following...
    Code:
    <script>
    //define flash file where you include it...
    flashFile = 'ringSlide_1.swf';
    </script>
    <script> src="loadFlash.js"></script>
    simple enough!
    Who the hell is "General Failure"
    and why is he reading my hard disk???

  3. #3
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes thank you that is EXACTLY what i was looking for i just didnt know exactly how to write it.
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •