MX04 Mixing ActionScript Loops and Tweens
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Mixing ActionScript Loops and Tweens

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    1

    Mixing ActionScript Loops and Tweens

    Hi,

    The basic premise of the piece I'm working on.

    We're looking at a phone, a message types itself in on the phone. Once the message has finished typing a piece of text fades in next to the phone. That's all.

    It should be very simple but several things seem to go wrong. This is where I got my typing script from: http://www.youtube.com/watch?v=rjCo0w3u2cg

    I tried to turn the text into a movie clip and have it tween within the movie clip. That did nothing, the text just appeared static from frame 1 (I assume as there was nothing to activate it? I don't know, I'm not very good at flash)

    I tried to just tween the text on the timeline but that just looped the entire clip everytime the tween ended the clip looped and the text wouldn't even type out in full.

    Is there a way I can somehow tell the script to work out when everythings finished (as it seems to do already because the clip stops when the message has ended) and then tell it to play the movie clip or from a certain frame onwards?

    Here is my code:

    Code:
    var myString:String ="Hey Blah Blah Blah this is my text for typing";
    var myArray:Array = myString.split("");
    addEventListener(Event.ENTER_FRAME, framelooper);
    function frameLooper (event:Event) :void {
    if (myArray.length > 0 {
    tf.appendText(myArray.shift());
    } else {
    removeEventListener(Event.ENTER_FRAME, frameLooper);
    }
    }
    Am I supposed to put something in the 'else' section to point it somewhere? When I try that it seems to automatically jump to whatever frame I point it to before the text is done. As I've said I'd like them one after the other.

    Have I explained this well enough? Sorry if I've been unclear.

  2. #2
    Junior Member
    Join Date
    Oct 2013
    Posts
    1
    You have two syntax errors in the posted code:

    1. framelooper in the addEventListener but frameLooper elsewhere ("L" is not capitalized in first instance)
    2. You're missing a closing parenthesis after the (myArray.length > 0 statement

    You should be getting errors. Are you checking your output? Fix the syntax errors first, then repost if problems persist.

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

Poll by Flashkit.com