flash actionscript:
I'm trying to load an external image using the moviecliploader class and the loadclip() method but it wont work with a php page that returns an image. Is this because the file must have certain extentions in order for flash to process them? I know the .php returns an image and the correct http headers so whats the problem? If i replace the code to just use a .jpg file (to test) it works fine so i'm pretty sure there isn't anything wrong with the code.
calling the php page may return the name of your jpg, but it doesn't return the jpg. you should use loadVariables or the loadVars() class to call you php page and load the name of your jpg. you can then use the moviecliploader class or loadMovie() or loadMovieNum() to load the jpg.
no no, the php page actually returns just the image. The image isn't stored as a .jpg file on the remote machine, its stored in a mySQL database. Therefore, when "thumbs.php?file=1" is called it pulls 1.jpg out of the database and actually returns just that image to browser, precluded by the appropriate http header (image/jpeg)
if i rename a jpeg image file to a file with a php extension, flash has no trouble loading it with the moviecliploader() class (or using loadMovie() ). how does flash know you're NOT trying to load the php file? why would it execute the code when you use loadClip() to access it?
thats very interesting, i hadn't thought of trying that. The difference is it should see it exactly as a .jpg file named .php b/c the file is interpreted by the php engine before flash ever see's it. It must be aproblem with headers then. Do you know how flash identifies files as .jpg if not by extension? does it use the http protocol headers? or does it simply read the file?
i have no idea what flash looks for to determine if a target file is able to be displayed in the flash player or whether it evaluates a loading file, at all. but i'd be surprised if your php file simply acted as a pointer to your jpg. my guess is that it must execute its code and that code does something (whether it returns a jpg or not, i can't say). but even if it presents a jpg after executing, i can't see how loadClip would work. you're asking it to cause the execution of your php file (not to dl it) and you expect flash to dl whatever the php file presents. you'd be more likely to be successful if you use getURL() and pointed to your php file. that has more chance of success than using loadMovie or the moviecliploader.
Here is a copy of the php file so you can see what it does. Since the flash movie loads the movie clip from the loadClip() method at runtime it essentially works the same way a browser does right? It requests the page "thumbs.php" from the source machine, the source machine finds "thumbs.php", parses the file (see below) and sends the result back to the client machine. As you can see in the file below, the only thing the php does is sends to the "browser" (flash plugin) a http header (image/jpeg), the same way it would to IE or Netscape, and then simply echos the jpeg data. Now this page displays fine when viewed from IE or Netscape so i know there isn't anything wrong with the script unless there is some kind of added mechanism flash uses to check to see if the files are jpegs (besides the http header). It may do this for security reasons, etc. P.S. 'db.inc' includes $hostname, $username, $password, etc. <?php include 'db.inc'; $file = clean($_GET["file"], 4); $file = rtrim($file, ".jpg"); if (empty($file)) exit; if (!($connection = @ mysql_pconnect($hostName, $username, $password))) showerror(); if (!mysql_select_db("jazd", $connection)) showerror(); $query = "SELECT mimeType, thumb FROM images WHERE id = $file"; if (!($result = @ mysql_query ($query,$connection))) showerror(); $data = @ mysql_fetch_array($result); if (!empty($data["thumb"])) { // Output the MIME header header("Content-Type: {$data["mimeType"]}"); // Output the image echo $data["thumb"]; } ?>
Nevermind, I'm an idiot. The whole process actually works fine. It seems the original images were saved as progressive jpegs. Once i batched them in photoshop and reuploaded them to the remote machine, flash will load them with no problem. imageLoader_mcl.loadClip("../php/thumb.php?file="+imageNum, "thumb_"+targetNum); works just fine. thanks for the help tho!
Don't see what you're looking for? Try a search.
|