A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: horizontal auto-scroll text w/ region detection

  1. #1
    Junior Member
    Join Date
    May 2005
    Posts
    18

    Lightbulb horizontal auto-scroll text w/ region detection

    I need help with trying to make a single-line text box auto-scroll a text string horizontally with a way to detect new words on the x-axis.

    I'm trying to make a rhythm practice game for ESL students at my college, but I'm a linguistics major, not a programmer. I want something that is similar to the vocal part in Rock Band (minus the pitch, for now). So for a simplified, proof-of-concept version I just need it to detect when a new word has collided with a defined region of say "100 < x < 50".

    I know how to implement the microphone using activityLevel to detect when the user is speaking into the mic, but just not how to use activityLevel alongside the region detect of the new word in the text box.

    Hopefully this makes sense. I know what I want, but it's kinda difficult to type.

    Thanks everyone in advance for any help you can give me!

  2. #2
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    put the new word in a movieclip (select and press F8), then click the movieclip and in the properties box, change the instance name to something like word1 and put this script around the part that makes it move

    if(word1._x >= 50) {
    THE SCRIPT THAT ALLOWS IT TO MOVE RIGHT
    } else if(word1._x <= 100) {
    THE SCRIPT THAT ALLOWS IT TO MOVE LEFT
    }

    if you dont understand that, post the script youve got and ill put it in for you where it needs to go, i dont know exactly what your script is like so i dont know exactly what i need to write
    NOTE
    Script above is AS2

  3. #3
    Junior Member
    Join Date
    May 2005
    Posts
    18
    I've been trying to do this in CS5 using AS3 (There are no spaces in the actual code in the word "hitTestObject", i don't know why it's displaying them in the quotes):

    addEventListener(Event.ENTER_FRAME, checkCollision);

    function checkCollision(event:Event) {
    if(this.text_mc.textinsert_mc.stress1.hitTestObjec t(hitbox_mc)) {
    stress_txt.text = "stress";
    } else if(this.text_mc.textinsert_mc.stress2.hitTestObjec t(hitbox_mc)) {
    stress_txt.text = "stress";
    } else if(this.text_mc.textinsert_mc.stress3.hitTestObjec t(hitbox_mc)) {
    stress_txt.text = "stress";
    } else if(this.text_mc.textinsert_mc.stress4.hitTestObjec t(hitbox_mc)) {
    stress_txt.text = "stress";
    } else if(this.text_mc.textinsert_mc.stress5.hitTestObjec t(hitbox_mc)) {
    stress_txt.text = "stress";
    } else if(this.text_mc.textinsert_mc.unstressed1.hitTestO bject(hitbox_mc)) {
    unstressed_txt.text = "unstressed";
    } else if(this.text_mc.textinsert_mc.unstressed2.hitTestO bject(hitbox_mc)) {
    unstressed_txt.text = "unstressed";
    } else if(this.text_mc.textinsert_mc.unstressed3.hitTestO bject(hitbox_mc)) {
    unstressed_txt.text = "unstressed";
    } else if(this.text_mc.textinsert_mc.unstressed4.hitTestO bject(hitbox_mc)) {
    unstressed_txt.text = "unstressed";
    } else {
    stress_txt.text = "";
    unstressed_txt.text = "";
    }
    }
    but I keep getting the error:
    Error #1010: A term is undefined and has no properties.
    at srr_fla::MainTimeline/checkCollision()[srr_fla.MainTimeline::frame1:4]
    I have the main movie timeline with 1 frame that has 2 layers (as3 and content) and there's a movieclip of the text motion tweening followed by a movieclip that has each individual word as a movieclip, each with its own instance name.

    It worked when I had the motion tweening on the main timeline, taking up 120 frames, but I wanted to clean it up better on the main timeline since I'd also be adding the activityLevel later on to detect if the person was speaking at the moment when the stressed word would pass over the hittest.

    I didn't realize there was an AS3 thread until after I posted it in here, so if a mod could relocate this over to the AS3 thread, I'd appreciate it, unless it's easier to do in AS or AS2.

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I dont know AS3..

    but I dont think it would be that hard in AS2.

    import/load your text/song..

    break/split it apart by spaces.. each word going into the same array..

    loop through array to:

    create a new/empty movie clip for each word
    create a new/empty textfield in the above movieClip for each word

    use the array to tween/slide your clip across the stage
    use this same array to check/loop through to see if that particular clip is hitting a 'pointer' clip..if yes..highlight word/text..

    I havent worked up an example..but could if you need it.

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Moved to the AS 3.0 forum.

    gparis

Tags for this Thread

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