TronicVolta

TypewriterPlugin and DecoderTextPlugin

Recommended Posts

I just created two plugins to achieve the popular typewriter and decoder text effects.

They follow the same architecture as the other plugins, and behave just like a tween.

Pass a Textfield instance as the target, and a String for the property.

Thanks Jack!

 

TextEffect Plugins

 

So for the TypewriterPlugin you would use.

import com.greensock.TweenLite;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.TypewriterPlugin;

TweenPlugin.activate([TypewriterPlugin]);
TweenLite.to(textField, 0.5, {typewriter:"Lorem Ipsum"});

 

DecoderTextPlugin:

import com.greensock.TweenLite;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.DecoderTextPlugin;

TweenPlugin.activate([DecoderTextPlugin]);
TweenLite.to(textField, 0.5, {decoder:"Lorem Ipsum"});

Share this post


Link to post
Share on other sites

Hi, I just tried to implement the TypewriterPlugin, but get the error message:

"Mit 'override' gekennzeichnete Methode muss eine andere Methode außer Kraft setzen." German, I know :-) But there are some issues with the override thing in the Plugin.
 
Do you know something about that?
 
Thanks
Zoran

Share this post


Link to post
Share on other sites

Looks like this was written for v11 - here is a quick port to v12 for the TypewriterPlugin.

 

It won't allow me to attach a file for some reason so here a paste of the file:

 

/**
   VERSION: 1.2
   DATE: 3/27/2010
   ACTIONSCRIPT VERSION: 3.0
   @author Marco Di Giuseppe, marco [at] designmarco [dot] com
   @link http://designmarco.com
   
   Ported to Greensock v12 by 
   @author Rob Verzera, rbv [at] logicswing [dot] com
  
 */
package com.greensock.plugins
{
	import flash.text.TextField;
	import com.greensock.TweenLite;
	import com.greensock.plugins.TweenPlugin;
	/**
	   TypewriterPlugin tweens the characters of a Textfield simulating a typing effect.

	   @usage
	   import com.greensock.TweenLite;
	   import com.greensock.plugins.TweenPlugin;
	   import com.greensock.plugins.TypewriterPlugin;

	   TweenPlugin.activate([TypewriterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
	   TweenLite.to(textField, 0.5, {typewriter:"Lorem Ipsum"});

	   Greensock Tweening Platform
	   @author Jack Doyle, jack@greensock.com
	   Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html
	   or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
	 */
	public class TypewriterPlugin extends TweenPlugin
	{
		/** @private **/
		public static const API:Number = 2; //If the API/Framework for plugins changes in the future, this number helps determine compatibility
		
		/** @private **/
		protected var _target:Object;
		
		//protected var target:TextField;
		protected var newText:String;
		protected var newLength:int;
		protected var oldText:String;
		protected var oldLength:int;

		public function TypewriterPlugin()
		{
			super("typewriter");
		}

		override public function _onInitTween(target:Object, value:*, tween:TweenLite):Boolean
		{
			_target = target;
			
			if (!(_target is TextField)) return false;

			oldText = _target.text;
			oldLength = oldText.length;

			newText = String(value);
			newLength = newText.length;

			return true;
		}
		
		override public function setRatio(v:Number):void {
			super.setRatio(v);
			var valueA:Number = oldLength + (-oldLength * v);
			var valueB:Number = oldLength + ((newLength - oldLength) * v);
			_target.text = newText.substr(0, int(valueB - valueA + 0.5)) + oldText.substr(0, int(valueA + 0.5));
		}
	}
}

Share this post


Link to post
Share on other sites

Hello,

 

The link is not working anymore, I can't find the files for these plug-ins. Does someone happen to have them and can share them?

 

Thanks!

Share this post


Link to post
Share on other sites

It looks like Rob v provided the source for his plugin in this thread. You probably just need to put that into a file named TypewriterPlugin.as and put it in the plugins folder.

 

That's about all the help I can provide. We do very little Flash support these days and I have no experience with this plugin created by Rob many years ago. Sorry.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.