A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Javascript SetVariable problem

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    5
    Hi,

    I need to do this simple thing- set a variable in a flash movie from JS, but the silly code doesn't wanna work. Here is the javascript code snippet:

    ..
    function setModuleCount()
    {
    window.littlemovie.SetVariable("moduleCount", "10");

    }
    ..

    and the flash code is:

    ..
    var moduleCount;
    getURL("javascript:setModuleCount();");
    ..

    But after that, I have verified that moduleCount does NOT get the value of 10 as it should get. What is missing? The flash code is written in a layer of a frame, and the <object> had id set correctly to "littlemovie". I've even tried to, within the setModuleCount function call alert(window.littlemovie.IsPlaying())) and that works..

    /puzzled David

  2. #2
    Member
    Join Date
    Jan 2002
    Posts
    50
    did you add the object id(IE) or embed name + swfLiveconnect var(netscape) to the html?

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Posts
    5
    Yep, I've done that, object ID is set to the proper moviename im calling in the javascript function

  4. #4
    Member
    Join Date
    Jan 2002
    Posts
    50
    actually i think the call should be:
    window.document.littlemovie.SetVariable("moduleCou nt", "10");

  5. #5
    Senior Member
    Join Date
    Oct 2001
    Posts
    135

    did you get it to work ?

    hi!
    I am looking for a similar use. Could you get this to work ?
    if so, please let me know.
    thanks
    mav

  6. #6
    Junior Member
    Join Date
    Jun 2002
    Posts
    5
    Maven5,

    I got it to work, it was kind of weird. The call to SetVariable did work, only that I used the variable in my Flash movie too quickly. That may sound strange and it is, but it seems like it takes some time for the SetVariable call to complete, so before I use the variable in the Flash code, I simply make a small loop between two frames, takes half a second or something, and then continue and the variable is set! Very very strange and even more ugly, but it was the only way I could go around the problem.

    Good luck

    /David

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