How to get vars from PHP into Flash

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jiwas78
    New Member
    • Jun 2008
    • 6

    How to get vars from PHP into Flash

    Hey there guys,
    After some research into PHP and Actionscript, I think I have come close to doing what I want to do. Except now I'm stuck.

    Here is what I have in my header.php file:

    <?php
    $c_page = $_SERVER['PHP_SELF'];
    $c_page = basename($c_pag e, ".php");
    ?>

    So I have the current file name of the php page stored in a variable called $c_page. Right?

    I want to pass it on to a single Flash file, which looks like this:

    <object align="middle">
    <param name="quality" value="high" />
    <param name="movie" value="swf/index.swf?<? echo "cPage=$c_page" ; ?>" />
    <embed src="swf/index.swf?<? echo "cPage=$c_page" ; ?>" quality="high" width="780" height="440" align="middle"> </embed>
    </object>

    Now I want to dynamically load a different background image depending on which page the swf file is in.

    But when I add this:

    _root.bgHostAni m_MC.bgHost_MC. loadMovie('../images/'+cPage+'Bg.jpg ');

    to the parent of the movieclip that I want to load the image into, it won't recognise cPage as a variable and comes back as undefined.

    Can anyone help?

    Cheers.
  • jiwas78
    New Member
    • Jun 2008
    • 6

    #2
    Also, in case this helps..

    When I go to preview the swf, Flash gives me an error:

    Error opening URL 'file:///....images/undefinedBg.jpg '

    Which I understand because flash needs to get the data from the php file.

    So I then refresh my browser. But the swf still file doesn't find the image.

    It's called indexBg.jpg so it should work with the bit of actionscript I have but I still don't get it..

    Any help much appreciated

    Comment

    • ssouhrada
      New Member
      • Jun 2008
      • 12

      #3
      Hello,

      Passing variables to flash is not too difficult. Based on the code you put up their I think you are just missing a few lines to have it recognize the variable (flashvar). See this link for more information.

      http://kb.adobe.com/selfservice/viewContent.do? externalId=tn_1 6417


      Thanks

      Comment

      • jiwas78
        New Member
        • Jun 2008
        • 6

        #4
        Thanks. But I think I sorted it out by using an absolute path. Like so..

        Code:
        _root.bgHostAnim_MC.bgHost_MC.loadMovie("http://localhost/hopscotch/images/"+cPage+"Bg.jpg");
        One thing I'm still trying to figure out is how Flash treats relative paths. Are they relative to where the SWF is or relative to where the .php or .html that it's embedded in is.. I've tried both and I still don't know. hmm..

        Comment

        Working...