HELP w/ PHP and XML image gallery

Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default HELP w/ PHP and XML image gallery

    Hi, I am trying to put together a product description page in Flash. Each
    product will have some text fields and also some pictures. So, the issue is to
    combine a thumbnail gallery with lots of data. Just to get an idea of how I
    imagine it have a look at this template: ;

    // read xml and display when loaded
    moXML = new XML();
    moXML.ignoreWhite = true;
    moXML.onLoad = makeArray;
    moXML.load("test.xml");
    stop();


    but it won't load the test.xml file that reads like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <resultset>
    <ship>
    <id>1</id>
    <category>sales</category>
    <name>NALANI</name>
    <notes>Some notes</notes>
    <loa>36'36</loa>
    <builder>HEYSEN</builder>
    <engines>2 x 680 MAN</engines>
    <year>1996</year>
    <cabincount>4</cabincount>
    <speedcruise>27</speedcruise>
    <speedmax>32</speedmax>
    <askingprice>30000</askingprice>
    <askingcurrency>EUR</askingcurrency>
    <numguests>6</numguests>
    <propellant>motor</propellant>
    <charterlow>500</charterlow>
    <charterhigh>1500</charterhigh>
    <chartercurrency></chartercurrency>
    <beam>11</beam>
    <draft>12</draft>
    <hull></hull>
    <consumption>255</consumption>
    <fuelcapacity>16000</fuelcapacity>
    <watercapacity>2000</watercapacity>
    <watermaker>yes</watermaker>
    <generator>SOME GENERATORS</generator>
    <aircon>yes</aircon>
    <crew>6</crew>
    <flag>Greek</flag>
    <designer>SOME</designer>
    <location>GREECE</location>
    <changed>20050718015506</changed>
    <pix>
    <pic>
    <id>5</id>
    <path>1.jpg</path>
    <caption>General view of the deck</caption>
    <category>DECK</category>
    <sortnumber>1</sortnumber>
    <shipid>1</shipid>
    <changed>20050722192904</changed>
    </pic>
    <pic>
    <id>6</id>
    <path>4.jpg</path>
    <caption>Master bedroom</caption>
    <category>MASTER BEDROOM</category>
    <sortnumber>2</sortnumber>
    <shipid>1</shipid>
    <changed>20050722192912</changed>
    </pic>
    </pix>
    </ship>
    </resultset>


    Can anyone see the error? Goes without saying that the appropriate Dynamic
    Text fields have been created in the movie with corresponding names (ie, notes,
    builder loa, etc)
    If worse comes to worst I am going to retrieve all these data using plain PHP
    (without the Flash) and use the Flash just for the images.

    tia

    crifty Guest

  2. Similar Questions and Discussions

    1. image gallery
      Hi, I have this image gallery that will be updated offten. http://www.picturethisgalleries.com/artist.htm Is the a coldfusion database that i...
    2. dynamic image gallery
      I'm trying to create a dynamic image gallery that is updated from a database, i managed to create a simple mysql database using phpmy admin, so I...
    3. CSS: Help with image gallery...
      Hi, I have buitl my photo gallery here: http://www.distanceclothing.com/new/gallery.html I'm going to put a menu on the left in plain html...
    4. Image Gallery with Content - PLEASE HELP.
      Hello, I'm desperately looking for a real good template that has a great image viewer that also displays content like the imagepilot at scalado.....
    5. Slider Nav and Image Gallery
      There must be a way to do this... I seem to be able to do one or the other, but not be able to combine both. The Goal: I want to have a slider at...
  3. #2

    Default Re: HELP w/ PHP and XML image gallery

    First of all: did you validate your xml? Call the file in IE and check if any
    errors are reported.
    2. The actionscript you found is part of a class file. The function 'Ship'
    looks like a constructor function so your class file should be Ship.as
    How did you implement it?
    3. When a new Ship instance is created, an array gets populated with values
    with this line in the code:
    articles.push(thisShip);
    but you don't use the array 'articles'.
    5. I don't see any traces. Did you check any of the coding with trace actions?

    LuigiL Guest

  4. #3

    Default Re: HELP w/ PHP and XML image gallery

    OK, I simplified the actionscript down to the basics. As a matter of fact, I am
    using plain PHP for the data and I only use Flash for the image gallery. The
    problem is that the XML file is dynamic, it is called xml.php. You can see the
    code at the end of the post.

    The problem is that I must call this xml.php like this:

    myPhoto.load("xml.php?id=$id");

    but Flash returns an error opening the file.

    Any ideas how I could make this work?

    Also, ideally I would like to create thumbnails on the fly using phpThumb.php
    like this:

    thmb="phpThumb.php?src=uploads/<?php print $picture->contents['path'];
    ?>%&w=50"

    but this doesn't work either. Is it a problem of calling Flash files from
    Flash?

    Here is the attached code for the xml.php file:



    <?php
    header('Content-Type: text/xml; charset=UTF-8');
    print "<?xml version='1.0' encoding='UTF-8' ?>";
    // render search result as xml

    require_once('admin/SafeSQL.class.php');
    require_once('admin/inc_db.php');
    require_once('admin/settings.php');
    db_marine_connect ();

    print "<pix>\n";

    $id = $_REQUEST['id'];
    if ( $id >= 1 ) {

    // print information on pix:

    $searchpic = new Picture;
    $searchpic->contents['shipid'] = $id;
    $unsafe_query = $searchpic->search_query_string( );
    $pixresult = fetch_by_search ( $unsafe_query );
    while ($pixline = mysql_fetch_array($pixresult, MYSQL_ASSOC)) {
    $picture = new Picture;
    $picture->load_from_table( $pixline );
    ?>
    <pic title="<?php print $picture->contents['caption']; ?>" main="uploads/<?php
    print $picture->contents['path']; ?>" thmb="uploads/thumbs/<?php print
    urlencode($picture->contents['path']); ?>"/>
    <?php
    }

    // end of listed pix
    }
    print "</pix>\n";
    ?>

    crifty Guest

  5. #4

    Default Re: HELP w/ PHP and XML image gallery

    myPhoto.load("xml.php?id=$id");
    With this line you are telling Flash to call a php-file like this:
    xml.php?id=&id
    meaning: &id doesn't get 'translated' into an actual number.
    Variables are not declared with a $ sign in Flash, so Flash won't know what to
    do.
    If you want to send an id to the php-file:
    myPhoto.id="1";
    myPhoto.load("xml.php?id=" + myPhoto.id);

    You cannot execute php-code from within Flash. When you echo the XML to Flash
    you can 'include' a path to the thumb.
    <picture>
    <data id="0" fullsize="picture0.jpg" thumb="thumbs/picture0.jpg" />
    </picture>


    LuigiL Guest

  6. #5

    Default Re: HELP w/ PHP and XML image gallery

    Thanks for the reply, I still can't make it work though. What I did was to
    create a FlashVars param called 'myPhoto' and embed it. This is the code:
    <param name="movie" value="brokerage.swf" />
    <param name=FlashVars VALUE="myPhoto.id=<?php print $id;?>">
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <embed src="brokerage.swf" FlashVars="myPhoto.id=<?php print $id;?>"
    width="570" height="400" quality="high"
    pluginspage="http://www.macromedia.com/go/getflashplayer"
    type="application/x-shockwave-flash" wmode="transparent"></embed>
    As you can see the id -supposedly- passed to the Flash. Based on your
    suggestion, I have written at the end of the action script:
    myPhoto.load("xml.php?id=" + myPhoto.id);
    But still no go. Do I have to declare the use of myPhoto.id somewhere else in
    the action script as well? And another thing is that I am not sure that
    FlashVars is the appropriate way for a dynamically generated page. Will the
    movie refresh each time is run or will it show the same $id pics at any
    sequential results? I read somewhere that FlashVars is loaded only the first
    time a movie is run.

    crifty Guest

  7. #6

    Default Re: HELP w/ PHP and XML image gallery

    Use:
    <param name=FlashVars VALUE="myPhoto=<?php print $id; ?>">
    You now have a variable (of datatype string) available in Flash called id and
    it holds the value echoed by PHP.
    myPhoto.load("xml.php?id="+myPhoto);


    LuigiL Guest

  8. #7

    Default Re: HELP w/ PHP and XML image gallery

    Again thanks for the reply... I tried it but still no go. It seems that even if
    the id is passed to the Flash movie OK, the dynamically generated xml file is
    not good enough for the Flash to work.

    I suppose that I must find another solution where a normal XML file will be
    written before the Flash is loaded, so the xml file called will be a plain
    foo.xml.

    Thanks anyway!!

    crifty Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139