dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: massive attack typer..

  1. #1
    Sporadic Member therhomworkshop's Avatar
    Join Date
    Oct 2001
    Location
    floating
    Posts
    276

    massive attack typer..

    hello there..

    on hi-res's massive attack site (www.massiveattack.co.uk) they use something which ive been trying to do for ages.

    i was wondering if anyone knew how to achieve the populating and unpopulating list effect that is used in the news and interview sections..

    i know it must be an array of somekind but am unsre of how they've done it..

    any ideas?

  2. #2
    Friendly fire ain't. skd's Avatar
    Join Date
    Mar 2002
    Location
    toronto.ca
    Posts
    389
    MX specific: If you want to give an effect of text apppearance letter-by-letter, you can use a procedure like this

    Code:
    _root.initType = function(str) {
    	clearInterval(_root.typing);
    	_root.dataText.text = "";
    	_root.strToType = new String(str);
    	_root.typing = setInterval(_root.typeLetter, 40);
    };
    
    _root.typeLetter = function() {
    	_root.dataText.text += _root.strToType.substr(1, 1);
    	_root.strToType = _root.strToType.substr(1);
    	if (!_root.strToType.length) {
    	    clearInterval(_root.typing);	
    	}
    };
    You need a textbox named dataText on _root for this to work
    use
    Code:
    _root.initType("your string value");
    to initialize the typer

    The substr values in typeLetter allow for output of larger chunks of text if altered to greater ones.

    --hope that helps

  3. #3
    Sporadic Member therhomworkshop's Avatar
    Join Date
    Oct 2001
    Location
    floating
    Posts
    276
    cheers for that


    but i use this code to do the same...

    onClipEvent (load) {
    actualChar = 0;
    display = "";
    span = 1;


    }
    onClipEvent (enterFrame) {
    textToDisplay = _root.blocktext;
    if (textToDisplay eq display) {
    stop ();
    } else {
    display += textToDisplay.substr(actualChar, span);
    actualChar += span;
    }
    }

    i am trying to modify this code to untype, thats why i kinda really liked the massive attack thing..

    ive been messing around with the above code, but i cant seem to get it working so that it untypes what has written..

  4. #4
    Friendly fire ain't. skd's Avatar
    Join Date
    Mar 2002
    Location
    toronto.ca
    Posts
    389
    If you use enterframe event, you can't really alter the speed at which the text outputs - that's what I like about the interval.

    To erase the value back, you can alter the same interval function

    Code:
    _root.killType = function() {
    	clearInterval(_root.erasing);
            //snatch the current text from the textbox >
    	_root.strToKill = new String(_root.dataText.text);
            //set erase interval
    	_root.erasing = setInterval(_root.delLetter, 40);
    };
    
    _root.delLetter = function() {
            //chop last character off the string
            _root.strToKill =_root.strToKill.substr(0,(_root.strToKill.length - 1));
            //give the textbox the value of the current string (shorter)
    	_root.dataText.text = _root.strToKill;
    	if (!_root.strToKill.length) {
               //when length = 0, exit, effectively, the textbox is erased
    	    clearInterval(_root.erasing);	
    	}
    };
    accoding to my caffeinated test, it works

  5. #5
    Sporadic Member therhomworkshop's Avatar
    Join Date
    Oct 2001
    Location
    floating
    Posts
    276
    man!!

    that is fantastic!! that has made me a very happy man indeed!!!
    i see what you mean about using the interval function's.. i must find out more about the textfield changes in MX!!

    thanx alot skd!!!

  6. #6
    Sporadic Member therhomworkshop's Avatar
    Join Date
    Oct 2001
    Location
    floating
    Posts
    276
    hi again,

    im having problems with the untype method.

    i have 4 buttons (mc) which type the text that i want to display.
    problem is that i want the buttons to untype what is in the text box and then type out afterwards if that makes sense.

    the problem im having though is that when i do this using the type and untype methods it doesnt display the text correctly ...

    its types it out fine the first time, then when you click the same button again it untypes fine, but the 3rd time you click the text gets cut of at it beginning...

    im using a substr rate of 10 as i want my text to appear quickly..

    any ideas??

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