PHP vars in flash

Discussion in 'Web Design and Development' started by Me1000, Oct 11, 2006.

  1. Me1000 macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #1
    ok on my PHP page a car will be difined

    for example the URL would be
    somesite.com/page.php?movie=4

    then i will code it so that the var will mean something,

    then the var will turn into something important

    $var='somesite.com/movies/'.$movie.'.flv' ;
    translating into
    $var='somesite.com/movies/4.flv' ;

    heres where the flash movie comes in...

    when i have a video playback in my SWF file the location of the flash video file (the FLV file) needs to be $var

    I hope im making since.

    anyway,
    How to I transfer that var over to the flash movie?


    Thanks
     
  2. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #2
    Just pass the variables into flash eg

    PHP:
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="multitxt" align="middle">
      <param name="allowScriptAccess" value="sameDomain" />
      <param name="swliveconnect" value="true" />
      <param name="menu" value="false" />
      <param name="movie" value="example.swf" />
      <param name="quality" value="high" />
      <param name="bgcolor" value="#ffffff" />
      <param name="FlashVars" value="var=<?php echo $var ?>" />
      <embed src="example.swf" quality="high" bgcolor="#ffffff" menu="false" width="100%" height="100%" name="multitxt" align="middle" allowscriptaccess="sameDomain" swliveconnect="true" FlashVars="var=<?php echo $var ?>" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>

    The important lines are

    <param name="FlashVars" value="var=<?php echo $var ?>" />

    and

    FlashVars="var=<?php echo $var ?>"
     
  3. Me1000 thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #3
    How will that display...

    How do i use the var in flash?
     
  4. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #4
    In actionscript, it will be available as var as well, in _level0
    try doing a trace with the variable _root.var

    <param name="FlashVars" value="var=<?php echo $var ?>" />

    FlashVars="var=<?php echo $var ?>"
     
  5. Me1000 thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #5
    Ok

    Thank you,

    I dont really need it in action script though.
    in my Perimeters menu of my video player I need to know what to set the content path to.

    (see screenshot for a visual)

    Thanks again,
    I really appreciate it!
     

    Attached Files:

  6. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #6
    I'm not too sure this will this be the best way but you may need to dynamically load your flv through actionscript

    Try this

    In here it would be
    Code:
    var connection_nc:NetConnection = new NetConnection();
    connection_nc.connect(null);
    var stream_ns:NetStream = new NetStream(connection_nc);
    stream_ns.setBufferTime(3);
    video1_video.attachVideo(stream_ns);
    stream_ns.play(_root.var);
    EDIT: typo and I wouldn't recommend using the variable name as var as it is a reserved word
     
  7. Me1000 thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #7
    ok heres my exact php code..

    PHP:
    <?

    $url 'http://www.scifisite.net/media/'.$vid.'.flv'

    ?>

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600" id="multitxt" align="middle"> 
      <param name="allowScriptAccess" value="sameDomain" /> 
      <param name="swliveconnect" value="true" /> 
      <param name="menu" value="false" /> 
      <param name="movie" value="media/player.swf" /> 
      <param name="quality" value="high" /> 
      <param name="bgcolor" value="#ffffff" /> 
      <param name="FlashVars" value="var=<?php echo $url ?>" /> 
      <embed src="media/player.swf" quality="high" bgcolor="#ffffff" menu="false" width="800" height="600" name="multitxt" align="middle" allowscriptaccess="sameDomain" swliveconnect="true" FlashVars="var=<?php echo $url ?>" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> 
    </object>

    and here is my flash script...

    Code:
    var connection_nc:NetConnection = new NetConnection();
    connection_nc.connect(null);
    var stream_ns:NetStream = new NetStream(connection_nc);
    stream_ns.setBufferTime(3);
    video1_video.attachVideo(stream_ns);
    stream_ns.play(_root.var);
    The playback things, instant name is video1_video

    and it doesnt work :eek:

    for example if you goto payer.php?vid=1 then it never loads! although the file does exists
     
  8. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #8
    I don't have a flv server, so I can't really test it out for you, but try rename "var" as another name as "var" is a reserved word in actionscript.
     
  9. Me1000 thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #9
    here
    <param name="FlashVars" value="var=<?php echo $url ?>" />
    and here
    stream_ns.play(_root.var);

    ???

    EDIT: ok well i did that, and it is still not working.
    I think my problem is in the SWF/FLA file.

    do you think you could make one up real fast and send it to me?
    If its not too much trouble! :eek:
     
  10. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #10
    I don't have a flv streaming server, so I cannot demostrate the flv version, but here's something together with that showing loading a img from the variable, if you see in my html, I actually push in 2 variables.
     

    Attached Files:

    • fla.zip
      File size:
      155.9 KB
      Views:
      134
  11. chezaday macrumors newbie

    Joined:
    Oct 23, 2006
    #11
    I need to do the same thing. Did you ever get this working? If so let me know what you did.

    Also I don't think it matters if you have a FLV streaming server or not.
    You should be able to use the Flash Video Player component and tell it where to find the flv file on your server and it will play it.
     

Share This Page