A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Knowing you're at the end?

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    Knowing you're at the end?

    Hey everyone!

    Ok Im wondering something. Im attempting to make this simple photoalbum and everything is fine and dandy, I can do it for myself. But Im making it for my cousin and I want it to be as easy to use as possible. That is, all she has to do is drag a new picture into one of the catagories, seperated by folders, and it'll be updated.

    Now this is how I did it. I simply made a photoalbum folder and created three sub folders inside it. For example lets say I made the sub folders squares, circles and random

    For my idea to work, you have to name each picture contained inside the catagories like so: square1, square2 etc etc.


    In flash I dragged on a loader component. Now for example, Ill use the square catagory. When you go to this catagory in my program, the loader automatically loads the picture square1.jpg on load.

    I then created a next button. When you click next, the variable square is incremented by one. So for example, the next button would look like:

    code:

    on (release){
    _root.square ++
    _root.squareLoader.contentPath = "square/square"+_root.square+".JPG";
    }



    This all works and everything, since it'll go to the next picture in the catagory folder all the way to the last one.



    Now heres my question, is there a way to first check if the picture is at the last picture?

    So for example I had five square pictures. How would you find out if your on number five? Since this is for my cousin, I want her to be able to do is simply drag a new square picture into the folder and it'll be added. Because as it is now, you keep clicking the next button until it goes to the sixth square picture, which does not exsist - it needs to loop back to the first.

    I hope you know what I mean and thanks for the help

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Is this for local files only or is this something that will be on the internet? You will need to create a variable to hold the total number of files in each folder. You could simply import a textfile into the app that populate a totalFiles variable. The user would have to manually update the filecount in the textfile if it is used locally. If it is used on the internet, you could use a backend language like PHP to update the total filecount in each folder.

  3. #3
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey,

    I was afriad you were going to say something like that, and I have no idea how to do any of that. I was intending to build a website to display her photos and all she would need to do is open the ftp and drag in new pictures into the corresponding catagories.

    So there is no way to be like:

    - Load a picture
    - Check if that picture loads properly
    - If it does load properly , then continue displaying it
    - If it doesnt load properly, then display the first picture

    That way it'll be alot simplier without any backend script. Any ideas?

  4. #4
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    One way I can think of without using some backend scripting is the way I mentioned before. Using a textfile with a single variable to hold the folders total file count. Then increment another photo count variable everytime the next or previous buttons are released(or if your using thumbnails, a particular image count for each thumbnail). Using an if statement, you can compare the two variables and if the photo count variable is greater than the total files variable, reset it to the first picture. However, that textfile would need to be updated everytime a new photo was added to the folder. One other possible idea is if your using a movieclip loader object. You could test the load of each image and if it returned undefined, move to the first image. I'll do a few quick tests tomorrow to see if there is an easy method without using a backend script.

    Since this is for the internet, it would be much simpler to use a bit of PHP to return the total files in the folder and eliminate the need for any text file updateing. That is, if the webhost supports PHP. The photo gallery in my sig uses this method. It currently uses a single folder, but the application itself wont ever need editing. Simply adding images to the folder is all that is needed. The PHP script detects the number of images in the folder and the gallery automatically sets up the number of necessary pages. This is a pretty easy method to employ and dynamically increases the ability of self extendable applications. If you would like to learn how, contact me by email and we can go from there.

    Regards
    NTD

  5. #5
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Thanks NTD,

    Im using a loader component and hoped there was a way you can return a true or false (or something like that) with it, in the end knowing if the picture loaded properly or not. If not, then simply play the first one again.

    Your probably right about Php being the easiest method, but I have zero knowledge of Php, nor do I have it installed on my work computer. Thanks for the offer to help me out here and I might take you up on it if I there is no way to do it with the component loader.

    Ill mess around with it a little more

  6. #6
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Since we dont have the full script to take a look at, heres an idea of what you could try...

    // load script here, but Dont include display picture
    myPic.onLoad = function(success) {
    // .onLoad might have to be modified depending on how you are loading it
    if (success) {
    // loads the file into mytextbox
    // display picture
    }
    if (!success) {
    // load previous picture script
    }
    };

    Now, that will probably be pretty much useless to you, considering we don't know how you're doing it. If you attached the script, then i can get a better idea of how you are loading everything

  7. #7
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey corky

    Anyways, Ive decided to just use a text file. Simple and sweet. Thanks for the help

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