A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: flash cs4:flash is not loading the PHP dynamically generated XML

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    4

    Question flash cs4:flash is not loading the PHP dynamically generated XML

    Hi,

    I'm trying to get flash to load PHP dynamically generated XML. The flash file should display jpg images of the thumbnails in the XML file. However when I new_release.swf is not displaying any images.

    Does anyone know what mistake i'm making?

    The following is my flash file:
    new_release.fla
    Code:
    function loadXML(loaded) { 
    if (loaded) { 
    xmlNode = this.firstChild; 
    
    thumbnails = []; 
    total = xmlNode.childNodes.length; 
    for (i=0; i<total; i++) { 
    
    //thumbnails[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; 
    thumbnails[i] = xmlNode.childNodes[i].firstChild.nodeValue;
    message("hello");
    thumbnails_fn(i); 
    } 
    
    } else { 
    content = "file not loaded!"; 
    } 
    } 
    xmlData = new XML(); 
    xmlData.ignoreWhite = true;
    xmlData.load("index_test_new.php"); 
    xmlData.onLoad = loadXML; 
    
    
    function thumbNailScroller() { 
    // thumbnail code! 
    this.createEmptyMovieClip("tscroller", 1000); 
    scroll_speed = 10; 
    tscroller.onEnterFrame = function() { 
    if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) { 
    if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) { 
    thumbnail_mc._x -= scroll_speed; 
    } else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) { 
    thumbnail_mc._x += scroll_speed; 
    } 
    } else { 
    delete tscroller.onEnterFrame; 
    } 
    }; 
    } 
      
    function thumbnails_fn(k) { 
    thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth()); 
    tlistener = new Object(); 
    tlistener.onLoadInit = function(target_mc) { 
    target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width+5)*k; 
    target_mc.pictureValue = k; 
    target_mc.onRelease = function() { 
    p = this.pictureValue-1; 
    nextImage(); 
    }; 
    target_mc.onRollOver = function() { 
    this._alpha = 50; 
    thumbNailScroller(); 
    }; 
    target_mc.onRollOut = function() { 
    this._alpha = 100; 
    }; 
    }; 
    image_mcl = new MovieClipLoader(); 
    image_mcl.addListener(tlistener); 
    image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k); 
    }
    my php file:index_test_new.php
    PHP Code:
    <?php
    header
    ('Content-Type: application/xml');

        include(
    "c:\bookstore\db.php"); 
     
    $cxn = @ConnectToDb($server$user$pass$database);  
    $table_id 'books';
            
    $sql "select title, date_format( pub_date, '%d %M %Y' ) as f_pub_date " .
                        
    "from $table_id where MONTH(pub_date)= MONTH(CURRENT_DATE) and YEAR(pub_date) = YEAR(CURRENT_DATE) ".
                                    
    "order by f_pub_date desc";
                                    
                                    
                                    
            
            
    $result mysql_query($sql) or die(mysql_error());

    if (
    mysql_num_rows($result)>0)
         { 
    $doc = new DomDocument('1.0');
         
           
    /*$root = $doc->createElement('root');
           $root = $doc->appendChild($root);*/
           
           
    $root $doc->createElement($table_id);
           
    $root $doc->appendChild($root);
            
            while (
    $row mysql_fetch_assoc($result))
            {   
    $child $doc->createElement('thumbnail');
                
    $child $root->appendChild($child);
               
                
    $title_str str_replace(' ','_',trim(strtolower($row["title"])));
                             
                
    $pos strpos($title_str,'/');
                             
                if (
    $pos === false){
                    
    $fileName $title_str.'_sm'.'.jpg'
           
                    if(
    file_exists($fileName))
                          { 
    $value $doc->createTextNode($fileName);
                           
    $value $child->appendChild($value);
                            }
    //if
                    
    else
                          {
    $fileName $title_str.'_sm'.'.gif';
                        if(
    file_exists($fileName)){ 
                               
    $value $doc->createTextNode($fileName);
                               
    $value $doc->appendChild($value);
                             }
    //if
                         
    }//else
                   
    }//if
                    
            
                
    else{
                    
    $title_str2 str_replace('/','_',$title_str2);
                    
    $fileName $title_str2.'_sm'.'.jpg'
                     if(
    file_exists($fileName))
                          { 
    $value $doc->createTextNode($fileName);
                           
    $value $doc->appendChild($value);
                            }
                    else
                          {
    $fileName $title_str2.'_sm'.'.gif';
                        if(
    file_exists($fileName)){ 
                               
    $value $doc->createTextNode($fileName);
                               
    $value $doc->appendChild($value);
                            }
    //if
                         
    }//else
                    
    }//else
              
            
    }//end while
            
        
         
    $xml_string $doc->saveXML();
         echo 
    $xml_string;
              
                 
         }
    //END IF STMT
    XML generated by index_test_new.php
    <?xml version="1.0" ?>
    - <books>
    <thumbnail>basic_cooking_sm.jpg</thumbnail>
    <thumbnail>dessert_recipes_sm.jpg</thumbnail>
    </books>

    i'm not able to get rid of that hypen in red above.

    thanks a lot in advance

  2. #2
    Junior Member
    Join Date
    May 2010
    Posts
    2
    is he loading the xml? or does he load text and not the images for example.

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    4
    Quote Originally Posted by joelie89 View Post
    is he loading the xml? or does he load text and not the images for example.
    I don't understand what u mean.
    The flash swf is not loading anything (it is supposed to load images) from the dynamic xml created by php.

    when I debug new_release, this.firstChild is null and total is undefined. The breakpoint doesn't go into the for loop.

    Actionscript Code:
    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;

    thumbnails = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    ......

  4. #4
    Junior Member
    Join Date
    May 2010
    Posts
    4

    Unhappy

    ok, i found that when I run the swf file with ordinary xml file, the images are getting loaded. But nothing is getting loaded with php file. Please help!

    thank you.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center