SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast Zero G's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing Values From HTML

    Hey,
    I want to use a flash move as a sound player. I need to have about 5 to 10 instances of the movie per page and want to know if there is any way to specify what sound clip that a specific instance of this flash movie will play in the HTML?

  2. #2
    SitePoint Zealot webQS's Avatar
    Join Date
    Oct 2002
    Location
    Sydney : Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Sure, there are these ways -

    1. Append variables to the filename of the movie in the object and embed tags.
    e.g index.swf?musicloop=3.mp3

    In ActionScript this will be available as _root.musicloop
    This is Flash Player 5 and 6 compatible

    2. Use the flashVars parameter
    MM technote
    http://www.macromedia.com/support/fl.../flashvars.htm


    HTH
    James

  3. #3
    SitePoint Member d3m's Avatar
    Join Date
    May 2003
    Location
    RO
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by webQS
    Hey,

    Sure, there are these ways -

    1. Append variables to the filename of the movie in the object and embed tags.
    e.g index.swf?musicloop=3.mp3

    In ActionScript this will be available as _root.musicloop
    This is Flash Player 5 and 6 compatible

    2. Use the flashVars parameter

    What about sending variables from flash to html or php???? how to write them to disk in a text file (for example i have the msg variable and i want to save it to msg.txt. How do i do that???)

  4. #4
    SitePoint Zealot webQS's Avatar
    Join Date
    Oct 2002
    Location
    Sydney : Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey

    Writing to a text file using Flash and PHP would involve using loadVars (or loadVariables) to send the required variables to a script.

    myVars = new LoadVars();
    myVars.msg = "hello world";
    myVars.sendAndLoad("script.php", receivingObject, POST);

    Then use the php filesystem functions to write to the text file.
    On a successful write, send a variable from PHP back to Flash
    e.g echo "&result=ok";
    Which will turn up in "receivingObject" as receivingObject.result

    Sending to HTML requires the use of Javascript and possibly some fscommands. Bear in mind this doesn't work on IE for Mac.

    HTH
    james

    Quote Originally Posted by d3m
    What about sending variables from flash to html or php???? how to write them to disk in a text file (for example i have the msg variable and i want to save it to msg.txt. How do i do that???)

  5. #5
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    WebQS, in the sendAndLoad method, don't you have to specify the transfer method in quotes?

    ie

    "POST"

    or

    "GET"

    otherwise it looks for a variable with that name. Am I mistaken?

  6. #6
    SitePoint Zealot webQS's Avatar
    Join Date
    Oct 2002
    Location
    Sydney : Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aaron -

    Not sure, the manual has this

    loadVariables("http://www.mySite.com/scripts/high_score.php", _root.scoreClip, GET);

    but it also recommends something like this, as does Moock's book.

    loadVariables("http://www.mySite.com/scripts/high_score.php", _root.scoreClip, "GET");

    Maybe I'll do a test script and check my log files to see how the document loaded was handled by the server.

    cheers
    James

  7. #7
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Cool, let me know how it goes. The book I'm using only showed the quotes around it. I guess flash's inate AS script processer would know that either a GET or POST can be there, so maybe it doesn't need quotes.. *shrugs*


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
  •