views:

404

answers:

2

Here is part 1 of our problem (Loading a dynamically generated XML file as PHP in Flash).

Now we were able to get Flash to read the XML file, but we can only see the Flash render correctly when tested(test movie) from the actual Flash program. However, when we upload our files online to preview the Flash does not render correctly, missing some vital information(thumbnails, titles, video etc..).

alt text

Here is a link to the Flash file using a manually created XML file (The Flash renders correctly): http://www.gaban.com/stackoverflow/TEN_xml.html

Here is the path to the manually created XML file:
http://dev.touchstorm.com/ten_hpn_admin2/client_user2.xml

Now here is the link to the Flash file using the PHP generated XML file (Renders incomplete): http://www.gaban.com/stackoverflow/TEN_php.html

Path to the PHP generated file (exactly the same as the manually created one): http://dev.touchstorm.com/ten_hpn_admin2/client_user.php?id=2



Additional information:

The SWF file exists on Domain 1 The XML & PHP file both exists on Domain 2 And the HTML file with the embed code lies on Domain 3

Wondering if this could be a crossdomain issue? We have one of those files in place on Domain 1 & 2 where we have access too, however for Domain 3 we can't have a crossdomain.xml file there.

Here is the PHP code:

$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString("\t");
$xml->startDocument();
$xml->startElement('data');
$xml->startElement('config');
    $xml->startElement('hex');
        $xml->writeCData('0x' . $widget_profile['background_color']);
    $xml->endElement();
    $xml->startElement('width');
        $xml->writeCData($widget_profile['width']);
    $xml->endElement();
    $xml->startElement('height');
        $xml->writeCData($widget_profile['height']);
    $xml->endElement();
    $xml->startElement('fullscreen');
        $xml->writeCData('false');
    $xml->endElement();
    $xml->startElement('special');
        $xml->writeCData('false');
    $xml->endElement();
    $xml->startElement('specialName');
        $xml->writeCData('Tools & Offers');
    $xml->endElement();
    $xml->startElement('specialLink');
        $xml->writeCData('http://bettycrocker.com');
    $xml->endElement();
    $xml->startElement('client');
        $xml->writeCData($widget_profile['site_url']);
    $xml->endElement();
$xml->endElement();

if (count($widget_content) > 0) {
    foreach ($widget_content as $tab) {
        $xml->startElement('tab');
        $xml->writeAttribute('id', $tab['tabname']);

        if (count($tab['video']) > 0) {
            foreach ($tab['video'] as $video) { 
                $video_sql = "select VID, flvdoname, title
                              from video 
                              where VID='" . $video . "'";

                $video_result = $howdini->query($video_sql);

                if ($video_result->rowCount() > 0) {
                    foreach ($video_result as $video_row) {

                        $video_row['flvdoname'] = substr($video_row['flvdoname'], 35, -4);

                        $xml->startElement('vid');
                        $xml->writeAttribute('flv', $video_row['flvdoname']);
                        $xml->writeAttribute('thumb', 'http://www.howdini.com/thumb/' . $video_row['VID'] . '.jpg');
                        $xml->writeAttribute('title', $video_row['title']);
                        $xml->endElement();
                    }
                }

            }
        }

        $xml->endElement();
    }
}
$xml->endElement();
$xml->endDocument();
header('Content-Type: text/xml; charset=UTF-8');
echo $xml->flush();

Thanks in advance for any answers! EDIT: I have included the change and now Firebug sees the XML. Now it's just not seeing the swf file but I can see the swf file in other parts of the page.

+1  A: 

Not a full solution, but just a data point (because encoding issues suck). When I downloaded your XML via the static file and PHP file and diffed them, I got the following results

% diff php.xml static.xml
1c1
< <?xml version="1.0"?>
---
> <?xml version="1.0"?>
10a11
>
19a21
>

Your static file has an extra "non-ASCII" character at the start of it.

My guess is your static XML file has a UTF-8 BOM that PHP generated file doesn't, and that your flash movie is expecting a UTF-8 file. I'd try generating a BOM with your PHP XML file and seeing it it helps, or fiddling with your server's encoding settings.

Try changing you PHP so it outputs the following header (matching the web page the movie is embedded in).

header('Content-Type: text/html; charset=UTF-8') 
Alan Storm
The weird thing is that if I open up the Flash IDE and run the swf file from there everything works as its supposed to.
AdonisSMU
That says encoding again to me. Try changing you PHP so it outputs the following header (matching the web page the movie is embedded in). header('Content-Type: text/html; charset=UTF-8')
Alan Storm
Thanks Alan that actually helped alot. Now my XML file is loading up exactly how it's supposed to. Before it wasn't showing my XML file loading up correctly. Now it is showing my XML is loading correctly. I didn't have the charset=UTF-8 part in the header. Now I see a partially rendered flash file but for some reason my Firebug isn't showing that the swf file was loaded.
AdonisSMU
A: 

I guess that was the answer. I needed to add the charset=UTF-8 into my php. Now everything seems to be working as planned.

AdonisSMU