PDA

View Full Version : Putting SWF into PHP using XML!


Christam1
12-17-2008, 02:37 PM
Hey there, I have a PHP file, an SWF and an XML which contains all the information to go into the PHP.

The XML is as follows:

<polls>
<poll title="Who do you think should win Pop Icons 2009?">
<answers>
<answer>
<name>Michael</name>
<tally>0</tally> <image>www.clipart.com/test1.jpg</image>
<flash>songs/1.swf</flash>
</answer>
<answer>
<name>George</name>
<tally>0</tally> <image>www.clipart.com/test2.jpg</image>
<flash>songs/2.swf</flash>
</answer>


So far the PHP code has been working correctly to display a different name and image in each cell in a table. However, when I've tried to insert the code for flash I get nothing now! Here is what I have so far, can anybody see what could be wrong with just the flash part to make the whole thing stop working? Here is the PHP code I have including the non-working flash part on the last few lines..

for ($i = 0; $i < 4; $i++) {
echo "<td>";
echo "<input type=\"radio\" name=\"vote\" value=\"" . $polls->poll[$pid]->answers->answer[$i]->name . "\" />" . $polls->poll[$pid]->answers->answer[$i]->name.
(isset($polls->poll[$pid]->answers->answer[$i]->image)?
'<br/><img src="' . $polls->poll[$pid]->answers->answer[$i]->image . '">'
:'').

(isset($polls->poll[$pid]->answers->answer[$i]->flash)?
'<br/><object width="100" height="30">'
'<br/><param name="movie" value="'
. $polls->poll[$pid]->answers->answer[$i]->flash . '">'
'<br/><embed src="' . $polls->poll[$pid]->answers->answer[$i]->flash . '">'
'<br/></embed>'
'<br/></object>'

:'').

"\n";
}
}


Thanks a lot!
Chris

CyanBlue
12-17-2008, 02:55 PM
Howdy and Welcome... :)

What do you get if you do the view source with that PHP script???

Oh, I have moved the thread to this forum which fits better for your question...

Christam1
12-17-2008, 03:05 PM
Hey, thanks for the response and for guiding my thread in the right place!

Unfortunatly I'm just getting blank screen before, but prior to adding the last few lines to insert the SWF file it was working fine!

Cheers
Chris

jasonJ
12-17-2008, 03:07 PM
Some quotes are probably messed up. Try this code in your for loop:

$name = $polls->poll[$pid]->answers->answer[$i]->name;
$image = $polls->poll[$pid]->answers->answer[$i]->image;
$flash = $polls->poll[$pid]->answers->answer[$i]->flash;

$embedImg = "<br /><img src='{$image}' />";

$embedFlash = "<object width='100' height='30'>
<param name='movie' value='{$flash}'>
<embed src='{$flash}'></embed>
</object>";

echo "<input type='radio' name='vote' value='{$name}' />" . $name;
echo !empty($image) ? $embedImg : '';
echo !empty($flash) ? $embedFlash : '';

yell0wdart
12-17-2008, 03:36 PM
What is the PHP outputting? If your flash movie isn't showing up, then I'd gather that something isn't right with the markup that's being sent to the page.

Christam1
12-17-2008, 03:46 PM
Some quotes are probably messed up. Try this code in your for loop:

Thanks for the replies everyone, and Jason that seems to work well :) At least, the flash files display but for some reason the sound linked to from each SWF does not play when on this PHP (they play when opened up singularly in the browser!) Anyone have any ideas why this might happen? I'm using the following on a frame inside a movieclip on the timeline!

stop();
newTune = new Sound (soundLoader);
newTune.loadSound("3.mp3", true);


Thanks again :)

Christam1
12-17-2008, 03:50 PM
Ignore that problem in my last reply! I worked that bit out was just a simple change to the folder the SWF was aiming up to pick up the MP3 :)