www.webdeveloper.com
Results 1 to 15 of 16

Thread: fortune cookie nightmare; putting PHP text on top of Flash video

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    23

    Question fortune cookie nightmare; putting PHP text on top of Flash video

    I have made a Flash video of a fortune cookie and at the end the white piece of paper is supposed to display a different fortune every time. I've used PHP cases for that. It doesn't work.

    Right now I am just trying to display any PHP text on top of the Flash video.

    Code:
    <?php
    
    
    echo '<div style="position:absolute; top: 280px; z-index:5; width: 350px; color: yellow">';
    echo 'the';
    echo '</div>';
    
    ?>-->
    the 5 is to be sure it's above the movie layer, which has a smaller index
    none of it works. I don't know if the 'the' is behind the movie or heading graphic or anything. Sorry I can't show the actual site. It's on my computer. If that would help, I can upload it and graphic and video.

    The complete code (for those of you with a lot of time on your hands) is below:


    HTML Code:
    <html>
    <head><title></title>
    <style type="text/css">
    
    body {
    	background-color: black;
    	color: black;
    	text-align: center;
    	font-size: 17px;
    }
    
    #center_wrapper {
    	margin-right: auto;
    	margin-left:auto;
    	width: 720px;
    } 
    
    #center_wrapper2 {
    	margin-right: auto;
    	margin-left: auto;
    	width: 350px;
    	display: block;
    }
    
    
    </style>
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    </head>
    
    <body>
    <div id="center_wrapper">
    
    
    
    <img src="fortune_title.gif" style="position: relative; top: 30px" />
    
    
    <div id="flash" style="position:absolute; top: 100px; z-index:0">
    
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="720" height="480" id="FLVPlayer">
      <param name="movie" value="FLVPlayer_Progressive.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="scale" value="noscale" />
      <param name="salign" value="lt" />
      <param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_1&amp;streamName=cookie&amp;autoPlay=true&amp;autoRewind=true" />
      <param name="swfversion" value="8,0,0,0" />
      <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. -->
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="FLVPlayer_Progressive.swf" width="720" height="480">
        <!--<![endif]-->
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="scale" value="noscale" />
        <param name="salign" value="lt" />
        <param name="FlashVars" value="&amp;MM_ComponentVersion=1&amp;skinName=Clear_Skin_1&amp;streamName=cookie&amp;autoPlay=true&amp;autoRewind=true" />
        <param name="swfversion" value="8,0,0,0" />
        <param name="expressinstall" value="Scripts/expressInstall.swf" />
        <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
        <div>
          <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
          <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
        </div>
        <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
    
    </div>
    </div>
    
    
    
    
    <!--<?php
    
    
    $rint = rand(1, 24);
    switch($rint) {
     case 1: $st = "I bet you can't eat another."; break;
     case 2: $st = "Now would be a good time to get your head out of your ass."; break;
     case 3: $st = "Wow.  Good luck with that one."; break;
     case 4: $st = "If you eat too many fortune cookies, you'll get fat (like Buddha) and wise (like Buddha)."; break;
     case 5: $st = "I'm a cryptic fact instead of a fortune."; break;
     case 6: $st = "Fortune cookies are b*ll****."; break;
     case 7: $st = "You will lose only two fingers in an accident that involves a dingo and a rabid rabbit."; break;
     case 8: $st = "The only way to win the lotto is by not playing it.  Here is your lotto number: 16-20-22-32-37."; break;
     case 9: $st = "You ate my fortune cookie."; break;
     case 10: $st = "Your future self will be a millipede.  It's karma, b*tch."; break;
     case 11: $st = "Girlfriend, don't you wear that shirt again."; break;
     case 12: $st = "Honesty is unbecoming of you."; break;
     case 13: $st = "Your death will involve a fire hydrant and a pair of high-heeled shoes."; break;
     case 14: $st = "Your love of peanut butter will be your undoing."; break;
     case 15: $st = "Hey, you're not supposed to choose this fortune cookie!"; break;
     case 16: $st = "Somebody will confuse you with Sandra Bullock, <br />and you will spend the rest of the day<br /> trying to figure out how that happened."; break;
     case 17: $st = "Atitudes are contagious-you can get them from holding hands."; break;
     case 18: $st = "You are a terrible, terrible person and should be thoroughly ashamed."; break;
     case 19: $st = "Dude, I've seen you dance, and dude, you shouldn't dance in public.";break;
     case 20: $st = "Despite the fact that you've always thought your favorite color was pink, it is actually green.  Good to know."; break;
     case 21: $st = "You are awesome like cheesecake."; break;
     case 22: $st = "If you don't have everything you want, try marrying into a large family so you'll get more presents at Christmas."; break;
     case 23: $st = "You are contemplateive and analytical.  While that sounds like a good thing, it actually means you're a nerd."; break;
     case 24: $st = "Watch Reno911 on Comedy Central on Wednesdays at 9:30pm. <br> It's way funnier than this fortune cookie gig."; break;
    }
    
    ?>
    
    <div id="center_wrapper2">
    
    <?php
    
    
    echo '<div style="position:absolute; top: 280px; z-index:5; width: 350px; color: yellow;">';
    echo 'the';
    echo '</div>';
    
    ?>-->
    
    </div>
    
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FLVPlayer");
    //-->
    </script>
    </div>
    
    </body>
    
    </html>
    I didn't really know when I was embedding the Flash video either.

    Is PHP even the right thing to make this work? Is what I'm trying to do even possible?

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    Why don't you send the variables to flash and have it display the text?

  3. #3
    Join Date
    Jun 2009
    Posts
    23

    *confusion*

    Because I have no idea what that means. Are you suggesting I get a book on ActionScript? I don't want a different video per each fortune. Do you mean I can randomly choose a phrase and display it using actionscript?

    It would be cool if I could make the play button be on the movie. I think that's very simple actionscript, right? I wouldn't know how to make the player not show up.

  4. #4
    Join Date
    Jan 2009
    Posts
    3,346
    You can send values to the flash element through flashvars. Then in the flash file use a little bit of actionscript to put that text into your textfield. That way you can just use the one video for all texts and you could even change the text without having to touch the flash file.

  5. #5
    Join Date
    Jun 2009
    Posts
    23
    Do you know of any good resources or tutorials for doing this? I kinda get what you're saying, but I have no idea how to implement it. Thanks for giving me some good basics for further investigation, though.

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346

  7. #7
    Join Date
    Jun 2009
    Posts
    23
    Well, I never got it to display, so I don't know if it ever changed randomly. :nP I just realized that. Does Flash have code for randomly selecting something? I also have to time the appearance of the fortune so it is right when the cookie opens, which I can do by adding a keyframe. Could I just make lots of mini movies of different fortunes when the fortune is displayed? And put one of those mini-fortune movies after the opening the fortune movie? Can Flash do that? I can make the mini-movies. I just don't know how to go about randomly selected one of them and playing it after the opening cookie movie.

  8. #8
    Join Date
    Jan 2009
    Posts
    3,346
    You can make mini movies but it would be easier to make one animation and use a textfield with an instance name so you can add the text dynamically. Very similar to the way PHP works in fact.

  9. #9
    Join Date
    Jun 2009
    Posts
    23
    Okay, so I'm taking this one step at a time, and I'm just trying to put text on my video clip (.flv) embedded in my Flash viewer thingy in Flash. On the last frame, I put a keyframe and wrote:

    myTextField.text = "Hello World";

    this.createTextField("my_txt", 30, 30, 30, 100, 21);
    my_txt.text = "the";

    stop();

    The stop(); works, the myTextField doesn't, and neither does the "the". I'm going off of http://livedocs.adobe.com/flash/9.0/...=00000887.html and one of the links.

    It seems like it should be so simple.

  10. #10
    Join Date
    Jan 2009
    Posts
    3,346
    Are you creating a flash for actionscript 2 or actionscript 3? Flash 9 or better supports actionscript 3.

  11. #11
    Join Date
    Jun 2009
    Posts
    23
    I have Adobe Flash CS4. It's not showing up within the program.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles