Class code: problem with $this...
Posted: Wed Jun 28, 2006 6:08 pm
Hi guys,
I have written a class that should display a table containing Flash elements and images for a game framework, but am getting no output for the elements using this code:
Here's the function code for the display table:
If I instantiate the class using the first bit of code, I can output info by using:
but it fails if I use $this->title_image
Why would that be?
Thanks in advance!
I have written a class that should display a table containing Flash elements and images for a game framework, but am getting no output for the elements using this code:
Code: Select all
$game = new Game;
$game->title_image = "playgame_r1_c1.gif"; // etc...Code: Select all
function table() { // Make the table for the game to display in
function display_Title() { // output the title image
echo "<img src = \"images/" . $this->title_image . "\" width = \"310\" height = \"104\" alt = \"Title image\">\n";
}
function set_Credits() {
if(!isset($_SESSION['credits_left'])) {
$_SESSION['credits_left'] == 3;
}
// create the Flash object
echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"190\" height=\"104\">";
echo "<param name=\"movie\" value=\"flash/credits.swf?credits=" . $this->credits_left . "\">";
echo "<param name=\"quality\" value=\"high\">";
echo "<embed src=\"flash/credits.swf?credits=" . $this->credits_left . "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"190\" height=\"104\"></embed>";
echo "</object> ";
}
function play_Image() {
echo $this->play_image;
}
function gamble_Image() {
echo "<img src = \"" . $this->gamble_image . "\">";
}
function intro_Movie() {
echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"500\" height=\"236\">";
echo "<param name=\"movie\" value=\"flash/intro.swf?" . $this->game_explanation . "\">";
echo "<param name=\"quality\" value=\"high\">";
echo "<param name=\"LOOP\" value=\"false\">";
echo "<embed src=\"flash/intro.swf?" . $this->game_explanation . "\" width=\"500\" height=\"236\" loop=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\">";
echo "</embed>";
echo "</object>";
}
echo "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\">
<tr>
<td><img src=\"images/spacer.gif\" width=\"310\" height=\"1\" border=\"0\" alt=\"\"></td>
<td><img src=\"images/spacer.gif\" width=\"190\" height=\"1\" border=\"0\" alt=\"\"></td>
<td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\"></td>
</tr>
<tr>
<td bgcolor=\"#009900\">"; display_Title(); echo "</td>
<td bgcolor=\"#009900\">"; set_Credits(); echo "<div align=\"center\">
</div></td>
<td><img src=\"images/spacer.gif\" width=\"1\" height=\"104\" border=\"0\" alt=\"\"></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"#009900\">"; intro_Movie(); echo "</td>
<td><img src=\"images/spacer.gif\" width=\"1\" height=\"236\" border=\"0\" alt=\"\"></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"#009900\">"; play_Image(); gamble_Image(); echo "<div align=\"center\"></div></td>
<td><img src=\"images/spacer.gif\" width=\"1\" height=\"60\" border=\"0\" alt=\"\"></td>
</tr>
</table>";
}Code: Select all
echo $game->title_image; // etc...Why would that be?
Thanks in advance!