A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: load an image into the movie?

  1. #1
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549

    load an image into the movie?

    I'm trying to make a project that will take an image that the user loads into the movie and make it into puzzle pieces that can be put together.

    I think I can figure out how to make the puzzle pieces and do all that stuff once the user chooses the image, but I can't figure out how to load an image file into the movie. Is it even possible?

    I guess loading an image file from a website is probably the best way to go, but I'm not really sure.

    Thanks

    ~Zippy Dee
    Ted Newman
    Last edited by ZippyDee; 06-19-2008 at 06:24 PM.
    Z¡µµ¥ D££

    Soup In A Box

  2. #2
    3DFA hobby scripter LewxX²'s Avatar
    Join Date
    Jul 2006
    Location
    Germany, Karlsruhe
    Posts
    198
    You could use this php script to upload a picture and bring the filename to your swf file in variable: fname

    PHP Code:
    <div align="center">
    <?php
    if($_POST["submit"] == "Upload"){
        
    $max_byte_size     200000;    // 200 KB
        
    $allowed_types     "(jpg|jpeg)";
        
    $path             "upload/";
        
    mkdir($path);
        echo 
    "try to upload file:".$_FILES["file"]["name"];
        
        if(
    is_uploaded_file($_FILES["file"]["tmp_name"]) == false) {$err[] = "no file found to upload";}
        if(
    preg_match("/\.".$allowed_types."$/i"$_FILES["file"]["name"]) == false) {$err[] = "wrong file typ ( ".$_FILES["file"]["name"]." is not allowed)";}
        if(
    $_FILES["file"]["size"] <= $max_byte_size == false) {$err[] = "file to big, max: ".($max_byte_size/1000)." KB";}
        if (
    file_exists($path.$_FILES["file"]["name"])) {$err[] = "file already exist";}
        if (!
    count($err)){
            if(
    copy($_FILES["file"]["tmp_name"], $path.$_FILES["file"]["name"])) {
                
    $picture $_FILES["file"]["name"];
                echo 
    "... done :)";
            } else {
                echo 
    "an error occured:";
                echo 
    "file can't be uploaded";
            }
         } else {
                echo 
    "some errors occured:";
                echo 
    "<ul><li>".implode("<li>",$err)."</ul>";
         }
        
    } else {
        
    $picture "picture that will be loaded if no picture is uploaded.jpg";
    }
    ?>
      <form name="upload" enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF?>" >
        <input type="file" name="file" id="file">
        <input type="submit" name="submit" id="submit" value="Upload">
      </form>
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
      codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="320" height="240" title="counter">
        <param name="movie" value="file.swf?fname=<?php echo $path.$picture?>" />
        <param name="quality" value="high" />
        <embed src="file.swf?fname=<?php echo $path.$picture?>" width="320" height="240" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" flashvars="name=root"></embed>
      </object>
    </div>
    sorry for my bad school English
    btw. visit my Page: projects.lewxx.de
    or lewxx.de (<= German)

  3. #3
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    I have no idea how to use php...

    and how do i use the fname variable to insert the picture into the file?
    Last edited by ZippyDee; 06-20-2008 at 07:07 PM.
    Z¡µµ¥ D££

    Soup In A Box

  4. #4
    3DFA hobby scripter LewxX²'s Avatar
    Join Date
    Jul 2006
    Location
    Germany, Karlsruhe
    Posts
    198
    in flash you can use:
    pic.loadMovie (fname);
    to load your pictures

    you can test the script here:
    http://www.flash.lifestylepics.de/pic2flash/

    is also possible to show a list of all uploaded files, or something like this.
    Last edited by LewxX²; 06-21-2008 at 05:15 AM.
    sorry for my bad school English
    btw. visit my Page: projects.lewxx.de
    or lewxx.de (<= German)

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