A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Change the EMBED SRC through JAVASCRIPT ?

  1. #1
    Member
    Join Date
    Oct 2003
    Location
    Lille (France)
    Posts
    36

    Change the EMBED SRC through JAVASCRIPT ?

    Hye,
    I want to change a Flash *.swf (or other embed element) SRC with a javascript link such as this one : <a href="#" onClick="document.images['image'].src='fileName'">

    How to? (here it is images relative, how to get it to work on a embed flash ?)

    1001 thx !

  2. #2
    first you can create a javascript function

    code:

    function changeEmbedSrc(id, newsrc){
    elem = document.getElementById(id);
    elem.src = newsrc;
    }



    then, on your embed give it a unique ID

    Code:
    <embed ... id="uniqueID1" .../>
    and on the link you want to change the source
    Code:
    <a href="javascript:void;" onclick="changeEmbedSrc('uniqueID1','../newsrc/file.swf');">linky</a>
    it should work, but I haven't tested it at all. If it does work, then it will only be on more modern browsers

  3. #3
    Member
    Join Date
    Oct 2003
    Location
    Lille (France)
    Posts
    36
    Thx... I tried myself with this expression. COuld do advise me about it ?

    Code:
    <EMBED src="" width=400 height=250 NAME="myEmbedName" >
    <a href="#" onClick="document.embeds['myEmbedName'].src='changed.swf'"> here </a>

  4. #4
    Well, I tried it out. Looks like it can't be done the way I proposed, sorry. Maybe someone else knows how.

    But here's what you could do, you could have the swf file load the movie dynamically via loadMovie, then use this

    http://www.macromedia.com/support/fl...cript_comm.htm

    to change the variable of what is to be loaded, when the variable changes, you load the new movie into the swf. This should work instead of changing the HTML, you change variables within the swf

  5. #5
    Member
    Join Date
    Oct 2003
    Location
    Lille (France)
    Posts
    36
    OK I'll read it, good idea

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center