7 Replies Latest reply on May 6, 2010 2:32 PM by kglad

    Help : Code error

    Ron Colmen Level 2

      This is my code to impot an image + some data from a db. I'm unable to pull the data or the image (nothing appears).

       

      1. What am I doing wrong here? or is the issue is elseware? (I'm PUBLISHING this to Flash Player 9 and AS2.0

      2. How can I code this without using the XMLParser?

       

       

      import gs.dataTransfer.XMLParser;

      fw_btn.onPress = function () {

      var fruit_tx = _root.sendfruit.text;
      XMLParser.load("fruitdata.php?fname="+fruit_tx, onFinish);

      }

       

      function onFinish($success:Boolean, $results:Object, $xml:XML):Void {

         if ($success) {

        cherry.text += $results.cherry[0].value;

        lemon.text += $results.lemon[0].value;

       

        var fruitimge_mcl:MovieClipLoader = new MovieClipLoader();

        var mclListener:Object = new Object();

       

        mclListener.onLoadStart = function(target_mc:MovieClip) {

         trace("onLoadStart");

        };

        mclListener.onLoadComplete = function(target_mc:MovieClip) {

         trace("onLoadComplete");

        };

        mclListener.onLoadInit = function(target_mc:MovieClip) {

         trace("onLoadInit");

        };

       

        fruitimg_mcl.addListener(mclListener);

        fruitimg_mcl.loadClip($results.fruitimg[0].value, fruitimg);

      }

        • 1. Re: Help : Code error
          kglad Adobe Community Professional & MVP

          your error can't be identified unless someone is familiar with that XMLParser class.

           

          but to answer your 2nd question, you can just use the xml class to load the xml data:

           

           

          var xml:XML=new XML();

          xml.ignoreWhite=true;
          xml.load("fruitdata.php?fname="+fruit_tx);

           

           

          xml.onData=function(src){

          trace(src);

          //parse your xml here

          }

          • 2. Re: Help : Code error
            Ron Colmen Level 2

            Thanks.

             

            As you see I'm sending some text from flash to php and then calling for the results. But it's not doing the job for me.

             

            color.text="";
            season.text="";

            var senderLoad:LoadVars = new LoadVars();
            var receiveLoad:LoadVars = new LoadVars();

             

            senderLoad.pullco = _root.fruit.text;
            senderLoad.sendAndLoad("http://www.abcnet.com/fruitshop/abc.php",receiveLoad, "POST"};

            receiveLoad.onData = function(src) {
               var a:Array=src.split(",,");
               color.text=a[0];
               season.text=a[1];
              };

             

            php

            $SomeVar = $_POST['pullco'];
            $query = "SELECT * FROM mylist WHERE pin = '".$SomeVar."'";
            $results = mysql_query($query);
            while($line = mysql_fetch_array($results))
            {
            echo $line["company"].",,";
            echo $line["address "].",,";

            }
            mysql_close($link);

            ?>

            • 3. Re: Help : Code error
              kglad Adobe Community Professional & MVP

              use the trace() function to see what's being returned from your php file (including error messages) and use the trace() function to see if you're sending the data you think you are sending.

              • 4. Re: Help : Code error
                Ron Colmen Level 2

                It pulls the data successfully. But how do I pull the image? The path is stored in the db and I have a empty mc on stage.

                • 5. Re: Help : Code error
                  kglad Adobe Community Professional & MVP

                  use the trace() function to pinpoint where the error is occuring.

                  • 6. Re: Help : Code error
                    Ron Colmen Level 2

                    I mean how to code it.

                     

                    php

                    {
                    echo $line["color"].",,";
                    echo $line["season "].",,";

                    echo $line["image"].",,";

                    }

                     

                    AS

                       color.text=a[0];
                       season.text=a[1];

                      image=a[2];

                      };

                    • 7. Re: Help : Code error
                      kglad Adobe Community Professional & MVP

                      if image contains the correct path/file name, you would use something like:

                       

                       

                      var this.createEmptyMovieClip("target_mc",this.getNextHighestDepth())

                      target_mc.loadMovie(image);