all groups > flash data integration > june 2005 >
You're in the

flash data integration

group:

PHP and Flash MX Pro 2004 components


PHP and Flash MX Pro 2004 components SimonTheSwift
6/20/2005 9:27:43 PM
flash data integration: Hello 2 every1,

I am in a middle of developing a dynamical Web page using Flash as an
interface, PHP script on the server and an MS Access database.

I ran into a problem (luckily seems already solved, but still...) with getting
the retrieved data from the DB to Flash. I am using the XMLConnector, DataSet
and DataGrid components. I started out with sending a simple static XML from
the PHP script - using the echo() or print() functions (as described in some
tutorials). But Flash just wouldn't read it. I added a TextArea to see the
contents of the XMLConnector (using XMLConnector.results property). It was
having problems with formatting. For example, for some reasone there was a
"<datapacket />" string added at the end, it was not getting "<" and ">"
symbols properly, even when expressed using < and > constants.

Then I ran into one of the examples posted on the PhilFlash Web site
http://www.philflash.inway.fr/contactphp/contactphp.html (thanks to Philippe
Nomail's post "Flash data integration with PHP", posted 03/16/2004). It shows
how to use DOM XML functions in PHP. And it works.

So, my question is, how come that Flash (XMLConnector) does not get the data
from PHP when using the echo() or print() functions? Is it always better to
stick to DOM when communicating XML files?


Thanks,

Simon.
Re: PHP and Flash MX Pro 2004 components SimonTheSwift
6/22/2005 12:00:00 AM
Thanks, LuigiL, for answering,

I still have some doubts. I did the following: created a valid schema -
browser shows it ok and the XMLConnector component accepted it. I took the same
file, opened and read it in my PHP script and printed it out using either of
the two functions (echo() and print()). In my browser the output is fine, but
when I saw what the XMLConnector recieves, it's not exactly the same. The quote
character is represented by the HTML ' string. I think that this is the
problem. The echo() or print() functions simply do not send OR the XMLConnector
does not parse the XML data as it should.

Maybe I am doing something wrong on the PHP side. The fact is, that so far
only the DOM standard works. I am just not sure whether it is good to use it.
The PHP manual I have says something about the XML DOM extension being
experimental. I just don't want to create a Web page with code that would not
be compatible with future versions of PHP.


Thanks again,

Simon.
Re: PHP and Flash MX Pro 2004 components LuigiL
6/22/2005 12:00:00 AM
Re: PHP and Flash MX Pro 2004 components SimonTheSwift
6/22/2005 12:00:00 AM
Thanx a lot, LuigiL,

I got it to work now. I used the utf8_encode() function and Flash gets it
perfectly. It even works without using that function. I think my problem was in
binding and configuring the components - I created and configured them all from
the start and it works. Must have had some mistake before.

Do you personally think it's better to use the DOM Standard or just use echo()
and print()?


Thanks,

Simon.
Re: PHP and Flash MX Pro 2004 components LuigiL
6/22/2005 12:00:00 AM
Works both but my personal preference is print(). This 'feels' good because
somehow I have the idea that I'm having more control. But, it's just a matter
of preference. Good that you have solved the problem. Good luck with your app!
BTW. Just installed my new G5. Man, this thing rocks!!!
Re: PHP and Flash MX Pro 2004 components LuigiL
6/22/2005 8:18:23 AM
When it comes to receiving data from PHP (or other server side software) there
is no difference between the XML class or the XMLConnector other than with the
components you have a means of visually binding the data instead of doing it
all with code. Consider the print() and echo() functions in PHP as a means to
generate 'a temporary xml-file' to be parsed by Flash. If this temporary
xml-file is valid (which you can check by calling your php-script in a browser)
Flash will parse it correctly. There is one restriction when using databinding
with the XMLConnector: the xml datasource cannot have a node with both
attributes and a child text node.

AddThis Social Bookmark Button