Skip to main content
Participating Frequently
Apr 2, 2007 6:01 PM UTC
Answered

Webcam Application

I'm currently developing an application but am running into some troubles. I hope you guys can help me.
What I'd like to do is a webcam game, that's how it should work:
- a master movie is placed on the server
- the first person opening the swf can see the master movie, then he's asked to reproduce what he saw with his webcam
- the second person comes and sees the last recorded movie and then again has to reproduce what he saw, when he finishes he will se the master movie, to compare.
- and so on

now recording and playing all works fine, more or less, but how can I find out how many movies are there already? I thought about saving an xml with php on a simple webserver, but there has to be an easier way, a solution I can solve with FMS to read out the data in the folder.

Thanks in advance.
    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer
    Apr 3, 2007 4:37 AM UTC
    You don't really need to use the filter flag.

    Let's assume you're running the default instance of your application, and the streams are being saved in streams/_definst_. You could do something like this:

    fileObject = new File("streams/_definst_");
    fileList = fileObject.list();
    for (a=0; a<fileObject.length; a++){
    trace("File found "+fileList.name);
    }
    }

    8 replies

    McKeanAuthor
    Participating Frequently
    Apr 5, 2007 8:12 PM UTC
    Thanks fguru, since I got it to work without a shared object, I'll keep it in mind though since performance won't really matter...

    Jay, I was playing around with it for a while and I never knew that I had to restart the application once I changed it (stupid me) and I didn't know that I can return arrays, so I returned a comma separated string and parsed it on the client, I also had to get rid of all the subfolders since it gave me the files like folder/folder/file.flv, and for playback I had to leave away the .flv dunno why you have to do that...

    well, thanks for all the help I really appreciate it, I'm slowly getting to like fms =)
    Translate
    McKeanAuthor
    Participating Frequently
    Apr 4, 2007 9:18 AM UTC
    sorry to bother again, I placed the code into my fla:

    function doConnect() {
    client_nc = new NetConnection();
    client_nc.onStatus = function(info) {
    trace("Level: "+info.level+newline+"Code: "+info.code);
    fileObject = new File("streams/_definst_");
    fileList = fileObject.list();
    trace(fileList);
    for (a=0; a<fileObject.length; a++) {
    trace("File found "+fileList.name);
    }
    };
    client_nc.connect("rtmp://192.168.1.42/sample_room");
    }

    I think I'm doing something wrong here...
    Where do I have to place this?

    Thanks!
    McKeanAuthor
    Participating Frequently
    Apr 3, 2007 8:46 AM UTC
    Thanks a lot mate!
    I'll give it a try.
    Translate
    McKeanAuthor
    Participating Frequently
    Apr 2, 2007 9:23 PM UTC
    Thank you for your reply Jay!

    how could i read out the files?
    with fileObject.list(filter) ?
    I will have to place this on the application .asc file?
    or can i put this on the client side .fla ?

    thanks!
    Translate
    Correct answer
    Apr 3, 2007 4:37 AM UTC
    You don't really need to use the filter flag.

    Let's assume you're running the default instance of your application, and the streams are being saved in streams/_definst_. You could do something like this:

    fileObject = new File("streams/_definst_");
    fileList = fileObject.list();
    for (a=0; a<fileObject.length; a++){
    trace("File found "+fileList.name);
    }
    }