8 Replies Latest reply on Apr 28, 2013 6:37 PM by kglad

    jpeg uploader need help!

    teeronline Level 1

      please test my site first, http://www.dcphonecases.com/test04/models/tempt.html,

       

      it's working as if you upload an image it will show there, notice it does 4 things, request you to browse your harddrive for image file, upload it, when it uploaded it say success, and the file name will show in the dynamic text box at the bottom.

       

      -the script is written in as2

       

      my problem is on my main site, which is written in *as3, I loaded this tempt.swf to there, while it still let you browse file and then upload, and then it called it success and eventually dynamic text box shows the file name, but the image itself disappear,

       

      The next thing I thought was the as3 vs as2 thing, but then I created a simple as3 swf that do nothing but just load tempt.swf on stage, it works! so evidently as2 clip could stand its own on a as3 main page.

       

      Can anyone think of a reason why? I put the as2 code in here, it isn't long.  

       

      import flash.net.FileReference;

       

      var fileRef:FileReference = new FileReference();

       

      var oListener:Object = new Object();

       

      fileRef.addListener(oListener);

       

      oListener.onSelect = function(fileRef:FileReference):Void {

          tData.text = "File Name: " + fileRef.name;

      }

      oListener.onOpen = function():Void {

          //tMessage.text = "Starting Upload ..." + newline;

      }

      oListener.onProgress = function(fileProg:FileReference, nBytesUploaded:Number, nBytesTotal:Number):Void {

          //tMessage.text == "Uploading " + nBytesUploaded + " bytes of " + nBytesTotal + newline;

          loadBar.gotoAndPlay(2);                    //start loading bar

      }

      oListener.onComplete = function():Void {

          //tMessage.text += "File Uploaded!";              

          loadImage(fileRef.name);

          loadBar.gotoAndPlay(32);               //instruct the loading bar to say upload successed!

      }

       

      tBrowse.onPress = function() {

          browseFiles();

      }

      function browseFiles(): Void {

          fileRef.browse();

      }

       

      tUpload.onPress = function() {

          uploadFile();

      }

      function uploadFile():Void {

          fileRef.upload("simplefileupload.php");                         // use this php for uploading image

      }

      function loadImage(imageName) {

          avatarContainer.avatarHeadOuter.avatarHead.loadMovie(imageName);          //instance name for the movie clip

          stats.text = imageName;                                                  // stats  is the dynamic text field

         

          scaleDown.onPress = function() {                              // all the below is for moving around the uploaded image;

              avatarContainer.avatarHeadOuter._xscale -= 5;

              avatarContainer.avatarHeadOuter._yscale -= 5;

          }

          scaleUp.onPress = function() {

              avatarContainer.avatarHeadOuter._xscale += 5;

              avatarContainer.avatarHeadOuter._yscale += 5;

          }

          xplus.onPress = function() {

              avatarContainer.avatarHeadOuter._x += 5;

          }

          xminus.onPress = function() {

              avatarContainer.avatarHeadOuter._x -= 5;

          }

          yplus.onPress = function() {

              avatarContainer.avatarHeadOuter._y += 5;

          }

          yminus.onPress = function() {

              avatarContainer.avatarHeadOuter._y -= 5;

          }

          rotateLeft.onPress = function() {

              avatarContainer.avatarHeadOuter._rotation -= 90;

          }

         

         

      }

        • 1. Re: jpeg uploader need help!
          teeronline Level 1

          When loaded to the main site, after you choose the image file, when the image uploaded it will still instruct the 'loading bar' to stop at where it say 'loading success', which indicates oListener.onComplete  was finished so the image gotta be uploaded already, but for misterious reasons it doesn't show it, and I need to know why..

          • 2. Re: jpeg uploader need help!
            kglad Adobe Community Professional & MVP

            i don't see a problem in that code.

             

            of course, it's not clear what your doing in the loading file or the php file.

             

            what's your load method look like and whats the site's url?

            1 person found this helpful
            • 3. Re: jpeg uploader need help!
              teeronline Level 1

              hi Kglad, for many reasons site's url can't be post.

               

              this is what I used to call 'tempt.swf' in the site. and this script is called on frame 10.

               

              tempt.swf will loaded into main, and I can upload jpg and it would say 'upload completed' just like the above sample. but it wouldnt show the uploaded jpg..

               

              stop();

               

              var newLoader3:Loader = new Loader();

               

              butt.addEventListener(MouseEvent.CLICK, clipClick,false, 0, true);

               

              function clipClick(e:Event):void {
                                             
                    var fileRequest3:URLRequest = new URLRequest("models/tempt.swf");
                                             
                  newLoader3.load(fileRequest3);
                  newLoader3.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);
              }

               

              function onLoaded(evt:Event):void{
                  subMc.addChild(newLoader3);          
                  subMc.removeChild(subMc.swf1);    //subMc is pre-existed mc with an empty mc inside 'swf1'
                  //mc.removeChild(mc.mc1);
                  //jpgDatGenerate(mc)
              }

              • 4. Re: jpeg uploader need help!
                kglad Adobe Community Professional & MVP

                i don't see a problem there either (though     subMc.removeChild(subMc.swf1);    //subMc is pre-existed mc with an empty mc inside 'swf1' doesn't make sense).

                1 person found this helpful
                • 5. Re: jpeg uploader need help!
                  teeronline Level 1

                  hi kglad,

                   

                  thanks for reply,  what I meant was subMc is a mc on stage, and inside there is another mc named 'swf1',

                   

                  hmmm I found out the problem, but it's pretty insane..

                   

                  function clipClick(e:Event):void {
                                                 
                        var fileRequest3:URLRequest = new URLRequest("models/tempt.swf"); << problem is tempt.swf is inside a folder (??)
                                                 
                      newLoader3.load(fileRequest3);
                      newLoader3.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded );
                  }

                   

                  when I put tempt.swf in the same directory as main movie, changed "URLRequest("models/tempt.swf");" to "URLRequest("tempt.swf");"  , THEN the stupid jpeg finally show itself.

                   

                  no wonder ppl moving over to html5 lol

                  • 6. Re: jpeg uploader need help!
                    kglad Adobe Community Professional & MVP

                    that's not a flash error.  that's a coder (ie, your) error: the path to the swf is relative to the main swf's embedding html.

                     

                    you'll have even more problems with html5.  at least, flash player generates an error message indicating your swf was not found.

                    1 person found this helpful
                    • 7. Re: jpeg uploader need help!
                      teeronline Level 1

                      hi Kglad, thanks for reply

                       

                      turns out your absolutely right!! I think the problem was in the php file (

                      function uploadFile():Void {

                          fileRef.upload("simplefileupload.php");    <<

                      }

                      )

                       

                      becasue the path in the php was directed to the /models/ , so the jpeg is uploaded there, but the main movie was trying to pick up the jpeg from current directory and it grabs nothing!

                       

                      I spent almost whole day on this crap... I could have tested and checked where actually the jpg uploaded to on server so I know something wrong with the paths..

                       

                      thank you

                      • 8. Re: jpeg uploader need help!
                        kglad Adobe Community Professional & MVP

                        you're welcome.