A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Substitute JavaScript for ActionScript

  1. #1
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55

    Substitute JavaScript for ActionScript

    Hello,

    Right now i have a swf that recieves parameters from a snippet of javascript in an index.html file.

    <script type="text/javascript">
    var flashMap = new SWFObject("main_map.swf", "main", "100%", "100%", "7.0.22", "#FFFFFF", true)
    flashMap.addParam("wmode", "transparent");
    flashMap.addParam("base", "./");
    flashMap.addParam("align", "left");
    flashMap.addParam("scale", "showall");

    flashMap.addVariable("interfacedata", "skins/default/interface.txt")
    flashMap.addVariable("mapdata", "flashdata.txt")
    flashMap.addVariable("stateneedloaded", "")

    flashMap.write("flash map container")
    </script>

    The first part is to embed the swf into a div, and the second part passes paramters to main_map.swf. This works fine as long as main_map.swf is the parent file. I'd like to actually embed this main_map.swf into a parent swf file which contains the rest of my layout.

    The parent swf is called importMap.swf

    it imports main_map.swf with :

    loadMovie("main_map.swf", "_level2");

    however, when i try and put importMap.swf into the index file, the paramter for "mapdata" is no longer being sent to main_map.swf

    var flashMap = new SWFObject("importMap.swf", "main", "100%", "100%", "7.0.22", "#FFFFFF", true)

    I've tried declaring global variables for the paramters in importMap with:

    mapdata = flashdata.txt;

    but it still doesn't pass properly.

    Any ideas?

  2. #2
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    also the question could be posed can the addVariable method in the SWFObject be altered to pass variables to specific movieClips in the parent SWF file?

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    will your project allow you to pass the variables with the loadMovie command

    vars = "mov2.swf?var1=this&var2=that&";
    loadMovieNum(vars,2);

    test in the browser as appended variables will not work in authoring environment

  4. #4
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    Quote Originally Posted by a_modified_dog
    will your project allow you to pass the variables with the loadMovie command

    vars = "mov2.swf?var1=this&var2=that&";
    loadMovieNum(vars,2);

    test in the browser as appended variables will not work in authoring environment
    seems to be accepting the variables, but it doesn't know where to look for the file. Is it because i haven't defined flashMap.addParam("base", "./");

    What would the actionscript equivilent of that be ?

    also how would i format an empty variable like flashMap.addVariable("stateneedloaded", "")

    vars = "main_map.swf?mapdata=flashdata.txt&interfacedata= skins/default/interface.txt&";
    loadMovieNum(vars,2);

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    1) - not sure about where to look for file, which file ?
    note that all paths to files are relative to the html file that contains the swf

    2) can you pass the variable as - &stateneedloaded=0&

  6. #6
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    ok well it seems to be playing my child clip now. But the child clip seem to hang.

    Here's the child clip playing by itself.

    http://sfdnb.homelinux.com/~Jack/

    Here it is when it's loaded by importMap:
    http://sfdnb.homelinux.com/~Jack/jacks.html

    The actionScript:
    vars = "main_map.swf?interfacedata=skins/default/interface.txt&mapdata=//Users/Jack/Sites/flashdata.txt&stateneedloaded=0&";
    loadMovieNum(vars,2);


    Here's the kicker - i have to include

    flashMap.addVariable("mapdata", "flashdata.txt")

    in the Javascript still or it wont load at all, if i remove any part of the actionscript it fails too.
    Last edited by paragonc; 02-17-2007 at 07:25 PM.

  7. #7
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    Here's an example of the importMap.swf file without the JS variables:
    http://sfdnb.homelinux.com/~Jack/jacks2.html

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    have you tried using the absolute URL -
    http://www.domain/Users/Jack/Sites/flashdata.txt

    rather than the relative URL -
    //Users/Jack/Sites/flashdata.txt

  9. #9
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55
    ya when i do that it just displays the .txt file

    http://sfdnb.homelinux.com/~Jack/jacks.html is an example of it working with:

    vars = "main_map.swf?interfacedata=skins/default/interface.txt&mapdata=//Users/Jack/Sites/flashdata.txt&stateneedloaded=0&";
    loadMovieNum(vars,2);

    and it starts to load - doesn't get any file missing errors, but then the application itself simply hangs

  10. #10
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    sorry, but i am plumb out of ideas on this one,
    it might be worth a try posting this to the Scripting and Backend Forum

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