A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Typing / Typewriter effect like in RPGs ?

  1. #1
    Registered User sundayshivers's Avatar
    Join Date
    Jul 2014
    Posts
    2

    Post Typing / Typewriter effect like in RPGs ?

    Hi all! I've just started using Flash CS5 this July 4, 2014 and it's been really awesome!


    A collaborator and myself are making a small comic featuring our roleplay characters doing a skit. He is in charge of the story, dialogue, coloring and design while I am in charge of drawing the lineart in photoshop (which he will color) and compiling everything into a flash movie.

    The whole flash thing was my idea to keep our homepage 'clean' as we will be making a lot of comic panels. And we decided to use a simple typing/typewriter effect to make the flash movie look like a real rpg.

    I've already searched flashkit but the codes I saw don't work for me Maybe they're already obsolete since most of them dated way back in 2005 to 2009-ish? Idk anything about scripting and I don't have any backgrounds whatsoever. But here is a code that's worked for me so far, with blahblah being the Dymanic Text's instance name and the only word I altered from the original post I got from the internet (from where exactly, I don't remember anymore)..


    Code:
    var effectTxt:String = blahblah.text;
    blahblah.text = "";
    var startEff:Number = 1;
    onEnterFrame = function() {
    	if (effectTxt.length>=startEff) {
    		blahblah.text = effectTxt.substr(0, startEff);
    		startEff++;
    	}
    };

    I can't figure this thing out. It works really well on one frame but when I extend that frame above the Dymanic Text Layer, only the first frame plays out like a typewriter and the rest just appear static.

    I would like to be able to post the code into one single frame which I can extend up to the end of the whole timeline just like what I can do with buttons so I wouldn't have to paste it on e-v-e-r-y frame where there's a dialogue, and maybe help get rid of a few more kb from the flash movie.

    I've seen it work on tutorials and flash files that use AS3 (with addEventListeners, EVENT_FRAME, etc.) but I am hoping this can also be done in AS2 as I have already started our small flash movie using AS2, with an existing preloader, a mute button, a gotoAndPlay button, and also some music using attachSound.

    Is it even possible? I hope it does! I've attached my sample fla for you to look at.


    And please, please, please assume that I don't know anything about scripting since I've only started using Flash (and I really don't know anything at this point). Thanks a bunch!

    Attachment 74979

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

    Perhaps you can make something from this I did a while ago

  3. #3
    Registered User sundayshivers's Avatar
    Join Date
    Jul 2014
    Posts
    2
    Thanks for replying, fruitbeard!

    So I used the script from your fla file and the first frame works. I placed it on an Actions layer and extended the said layer up to the end of the timeline. The first frame works perfectly but the second frame appears blank.

    I wrote it like this:

    Code:
    var theMessage:String = "This is the text I want to see looking like it's being typed.";
    var messageLength:Number = theMessage.length + 1;
    var theSage:String = "Second frame containg text also being typed.";
    var sageLength:Number = theSage.length + 1;
    var addLetter:Number = 0;
    var typeSpeed:Number = 40;
    var typeInterval = setInterval(doType, typeSpeed);
    
    function doType():Void
    {
    	field1.text = theMessage.substring(0, addLetter);
    	addLetter++;
    	if (addLetter >= messageLength)
    	{
    		clearInterval(typeInterval);
    	}
    }
    
    {
    	field2.text = theSage.substring(0, addLetter);
    	addLetter++;
    	if (addLetter >= sageLength)
    	{
    		clearInterval(typeInterval);
    	}
    }
    
    doType();

    The second frame appears blank and only the first frame works. I know I'm doing it the wrong way.

    Please help!
    Attached Files Attached Files

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

    Ok then , try this, do whatever you like to it, it's probably not the best way

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