A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: search through a 1000 frames with labels

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    3

    search through a 1000 frames with labels

    Hello

    Im new to as3 and flash in general
    i have a 1000 frame flash file
    each frame is labeled uniquely
    ive managed to create a input text field searchbox in frame no1 which gets me to my desired frame
    (when i enter the frame label inside the input text "search box")

    my problem is that you have to enter the exact name of the frame label (case sensitive and tough to guess)

    my question is how can i make this "search engine" offer me the closest result
    (or to choose among two or three possible frame labels)

    i appologise if this seem complicated, im just starting ( i hope to be answering this kind of questions after a while )

    Thanks in advance

  2. #2
    Junior Member
    Join Date
    Dec 2016
    Posts
    3

    ive found a solution

    the validator variable

    seems strange noone suggested it here as it seems to be the thing to learn today

    when i finish my code ill try to post it here

    thanks for nothing guys

    maybe you should be faster when responding so i dont increase mileage on other flash tutorial web sites

    cheers

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I would get rid of the frames, put all the names in an array, and attach what you need to on frame 1, and with the array you can search

    arrayname.indexOf("search_string_here") and stuff and flash has functions like str.toLowerCase() to make everything lower case

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Alternatively you could put the frame names into an array and jump to the frame name you have entered into your search box.
    if there is more than one name with the same letter begining then you could make a temporary array of the relevant words and offer all of those suggestions to the user.

    you can use str.toLowerCase() or str.toUpperCase() if the case is necessary at all.

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Example
    PHP Code:
    var frameArray:Array = new Array("Adder""Antelope""Bee""Bear""Buzzard""Cat""Dog");
    var 
    matchArray:Array = new Array();

    function 
    doMatches(arg:String):Void
    {
        
    matchArray = [];
        for (var 
    a:Number 0frameArray.lengtha++)
        {
            if (
    arg.toLowerCase() == frameArray[a].charAt(0).toLowerCase())
            {
                
    matchArray.push(frameArray[a]);
            }
        }
        
    trace(matchArray);
    }

    doMatches("B"); 
    thats one way

    another way would be like so uding the same arrays as above
    PHP Code:
    function goFrame(arg:String):Void
    {
        var 
    lower:String arg.toLowerCase();
        for (var 
    a:Number 0frameArray.lengtha++)
        {
            if (
    lower == frameArray[a].toLowerCase())
            {
                
    gotoAndStop(lower);
                
    trace(lower);
            }
        }
    }

    goFrame("Bear"); 
    I have tested and the frame name does not require case sensitivity, so a frame called "BEar" would accept bear.

    Or as suggested before, you can just call each bit of data to frame 1 or 2 from external sources or from the library to save having a 1000 odd frames, although either way it seems you have a lot to do with so many.
    Last edited by fruitbeard; 12-16-2016 at 04:38 AM.

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I just noticed you said AS3, so a few slight changes would be needed

    so you could infact dynamically create an array of your frame labels and numbers, AS2 does not allow you to do that.

    PHP Code:
    import flash.display.FrameLabel;

    var 
    labels:Array = currentLabels;
    var 
    labelNames:Array = new Array();
    var 
    labelNumbers:Array = new Array();

    for (var 
    i:Number 0labels.lengthi++)
    {
        var 
    label:FrameLabel labels[i];
        
    trace("frame " label.frame ": " label.name);
        
    labelNames.push(label.name);
        
    labelNumbers.push(label.frame);
    }

    function 
    goFrame(arg:String):void
    {
        for (var 
    a:Number 0labelNames.lengtha++)
        {
            if (
    arg.toLowerCase() == labelNames[a].toLowerCase())
            {
                
    gotoAndStop(labelNumbers[a]);
            }
        }
    }

    goFrame("Bear");

    trace("Label names : " labelNames);
    trace("Label name numbers : " labelNumbers); 
    Attached Files Attached Files
    Last edited by fruitbeard; 12-16-2016 at 05:32 AM.

  7. #7
    Junior Member
    Join Date
    Dec 2016
    Posts
    3
    Thanks for the suggestions, ill come back once ive solved my issue
    this tolowercase line is exactly what i need
    much obliged

    see ya

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Nice idea fruitbeard. now i know my ABC's (actionscript byte codes)
    Last edited by AS3.0; 12-16-2016 at 05:50 PM.

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Well put them to good use Alloy, no more of the bum stuff code.

    What exactly doy ou mean by ABC anyway, do you know immense amounts of byte code stuff, if so then put up some mega stuff for us to see and utilise.
    in your own thread though, don't want to occupy somebody elses too much.
    Last edited by fruitbeard; 12-17-2016 at 05:46 AM.

  10. #10
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    they should have named the bytearray the bitarray and they should of named bitmaps bytemaps xD

  11. #11
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Good stuff alloy.

  12. #12
    Junior Member
    Join Date
    Jan 2017
    Posts
    1
    yes, guys you are right

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