Work in progress Experiment

*Originally posted by Phil Jayhan *
**marz why not?

pj :angry:

that is pretty cool lost-
pj :stuck_out_tongue: **

:slight_smile: Thanks Phil.

OH yeah, and Marz, I know Flash can only load in non-progressive .jpg images, but I had to add .gif in there because the only images I had up in that folder are .gif format, so for testing reasons I used that.

Yeha man… That’s cool… I’ll see what I can whip up here.

You said you wanted it to load up the file name, width and height right?

Yep:)

You have no idea how much that would help me.

If I were in a class for server-side FLash I would get an F-- and I am not talking about a decrementing F variable :stuck_out_tongue:


<?php
$dir = opendir(".");
$packet = "images=";
while($file = readdir($dir))
{
   if($file=="." or $file=="..") continue;
   $dotposition = strrpos($file, ".");
   $filename = substr($file, 0, $dotposition);
   $extension = substr($file, 1 + $dotposition);
   if($extension == "jpg" || $extension == "gif")
   {
      $size = getImageSize($file);
      $height = $size[1];
      $width = $size[0];
      $temp = $temp . "$filename.$extension::$height::$width::";
   }
}
$final = $packet . $temp;
$filePointer = fopen("imagedata.txt", "w");
fputs($filepointer, "$final");
fclose($filepointer);
?>

This should print out the This should display the following.

http://www.fantom-stranger.com/~mentalconcepts/pics/images.php

then open up the text file…

http://www.fantom-stranger.com/~mentalconcepts/pics/imagedata.txt

Check it out… That’s the way it should display. Then you just need a function in flash to read it… Which would be…



_root.onLoad = function()
{
   imgVars = new LoadVars();
   imgVars.load("url/imagedata.txt");
   loaded = FALSE;

   fileNames = new Array();
   imgHeights = new Array();
   imgWidths = new Array();
}

_root.onEnterFrame = function()
{
   if(loaded == FALSE)
   {
      if(imgVars.loaded)
      {
         index=0;
         imgList = imgVars.images;
         temp = imgList.split("::");
         for(i=0; i<(temp.length-1); i+=3)
         {
            fileNames[index] = temp*;
            imgHeights[index] = temp[i+1];
            imgWidths[index] = temp[i+2];
            index++;
         }
         loaded = TRUE;
      }
   }
}

See how that works out for you… I tested the php script but couldn’t test the flash script out yet… Tell me if it works sufficiently or not… It should load all the filenames, heights and widths into their appropriate arrays. I made the length of the array - 1 because my php script adds an extra :: at the end of the file that could be mistaken as real data :wink:

[EDIT]Screwed up the Flash Code a tiny bit… lowercase l instead of uppercase L lol[/EDIT]

SWEEET!!! Thanks man.

I can’t test it at this moment either, but I will be testing that later… W00t!!!

cough… By the way… I did test this out and it works like charm… Lemme upload the .swf to my server here really quickly to show you :slight_smile:

http://www.fantom-stranger.com/~mentalconcepts/pics/datatextexample.swf

There ya go man… AND NO laughing at my button… I put all my heart and soul in that baby… hehehe

100% Excellent!

You rock man! You saved me :slight_smile: