A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: gurus, help with string manipulation

  1. #1
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43

    gurus, help with string manipulation

    thanks a lot of someone can help with this one.

    my string takes the form of path to a .swf that looks like this: "video/test.swf" where test may be any name for the .swf and any length. for example it might be video/bigmovie.swf or video/thebadmovie.swf etc.

    i need to extract everything inbetween the"/" and the"." so i can use that to reference a frame label that has special info for that .swf

    any ideas?

    thanks.

    --grish

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Location
    Georgia
    Posts
    226
    in understand you correctly, you want something like a list to pull directory & file names from a remote location and flash sort them into a list for users to click on read info on it, and watch them is wanted correct?
    life aint easy, stop whinen'
    Oldnewbi - if you quit this forum needs to be shut down!, its posintless without you!

  3. #3
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43

    i'll explain...

    ikandi-mac, thanks for your repily. it isn't that complex, fortunately.

    i'm loading one at at time about 60 video.swf's into a movie clip that has a controller and stuff and a clip that has info for each movie, with at button click. so i'm trying to use the name of the loading .swf to jump to the correct frame in a info clip so i dont have to code in a bunch of ifs for each loaded .swf that basically converts the filepath into a frame label. the frame lable seems to not be valid with a "." or a "/" in it. or both, i didn't isolate which one is messing things up.

    i want to have a little function that looks at the filepath and assigns a variable "jumpTo" with the part of the filepath i described in the above post. then it does this:

    info.gotoAndStop(jumpTo);

    so i'm passing the file path to a function but i want to avoid having to code up 60 if's . if you catch my drift...

    function showInfo(moviePath) {
    if (moviePath == "video/test.swf") {
    info.gotoAndStop("test");
    }

    if (moviePath == "video/testbig.swf") {
    info.gotoAndStop("test_2");
    }
    }


    thanks so much if you can help

    --grish

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    code:

    function findFileName(filePath) {
    var pathArray = filePath.split("/");
    return pathArray[pathArray.length - 1].substr(0, pathArray[pathArray.length - 1].indexOf("."));
    }



    which could be used like this,

    trace(findFileName("videos/files/test.swf")); // displays test
    trace(findFileName("somewhere/something.swf")); // displays something
    trace(findFileName("/a/b.swf")); // displays b

  5. #5
    Member
    Join Date
    Oct 2000
    Location
    san franacisco, ca
    Posts
    43

    hit that one on the nose man

    that's exactally what i was looking for and better. catbert303, you rock. thanks a ton.

    --grish

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