Tinting with our first plug-in
We are ready to take a step out of the core features of TweenLite and expanded into the plug-in architecture. The TweenLite library comes without most of the most exciting features of the tween library but they are only a line away from being activated. To activate features (stored in plugins) you must activate them,contrary to the TweenMax that comes with many of the plugins baked into it. In this in lesson, we will see how to activate the TintPlugin and see how we can use it to recolor elements on the stage.
Video Transcript
00:00Chapter 4. So let's get started. What this chapter is going to be about, we're going to wrap up Tweenlight, really diving into that world of plug-ins, we'll check out a few of those plug-ins, and we'll convert our way into Tweenmax.
00:14Now, the difference between Tweenlight and Tweenmax is very minute, besides Tweenlight is lighter, it's a smaller library.
00:22But it's built on the same foundations, and basically Tweenmax is an extension of Tweenlight, meaning that everything you can see in Tweenlight you will find in Tweenmax as well. Only in Tweenmax comes with more things.
00:34And it comes pre-built with a lot of different plug-ins that are default connected to them.
00:41Now, another thing to note is, if you use in your project Tweenmax, your Tweenlight will have all the plug-ins that Tweenmax has as well, because as soon as you activate the plug-ins, they're available for all your animations.
00:54So really, if you're only working with Tweenlight, fantastic. If you're working with both Tweenlight and Tweenmax, it's kind of unneeded, you could just work with Tweenmax.
01:03Because as soon as you have one instance of Tweenmax, all the files have been loaded already, so there's no point in working with a lighter library, because Tweenmax has all those capabilities and more.
01:15But obviously, if you're not going to use any of the advanced capabilities, you could stick to Tweenlight, which will keep your file size smaller, which is always a good thing.
01:23So let's take a look at creating those tweens. So I'm actually going to keep on working for now with the tweenlight, so I'm going to import that.
01:31I'm going to import that com folder, green sock, tweenlight.
01:35And the next thing I want to do is I want to go into the plug-ins folder, or package, whatever you like calling it, plug-ins.
01:44And in there, you're going to find a class called tween plugin.
01:49Now, tween plugin is not a specific plug-in, but that's the static class that has a method that enables you to add more plug-ins.
02:00And we're going to see immediately how do we activate a plug-in.
02:03So the next step after that, what I want to do is I want to pick a plug-in that I want to play around with.
02:08So we're going to start again, going into the same folder, plug-ins.
02:11Now, we're not going to go over every single plug-in here, but I do recommend that you familiarize yourself with them, because you might find a few that are incredibly handy and useful.
02:20But for now, what I'm going to do is I'm going to go for the first plug-in that I want to work with, and that is going to be the tint plug-in.
02:27And the tint plug-in enables me to very quickly change colors of an object in an animation, which is relatively cool.
02:36So next step for me, and now that I've already loaded all these classes, is to actually say, hey, I want to actually activate this tint plug-in.
02:44To do that, I'm going to call my tween plugin, and I'm going to call it activate, and there I'm going to send an array, and inside of that array, I'm going to put whatever plug-ins I want to activate.
02:56In my case, I want to activate only the tint plug-in, so I'm just sending in that class, all that class, into the activate, and that will activate that plug-in.
03:05Once it's activated, we only have to do that once, and it's going to be available throughout the SWF file, throughout the experience of our animation and of our program.
03:15So I don't have to activate it again in other classes, so really just make sure that you activate it only in your main class, activate all the plug-ins that you want to activate,
03:23instead of having activations happening all over, try to keep it as clean as you can.
03:28Now that we have that, what I'm going to do is I'm going to approach my MC logo, and I'm just going to tween its color.
03:35So I'm going to tween light it, and I'm going to take my object MC logo, and I'm going to set a duration here, let's say I have one second,
03:43and let me set the tint of it by setting the property tint, and then I pass over a color.
03:48So for example, let's say we want to tint our color to be red, so I'm going to send the value of red, and hex values.
03:55And what I'll do next is I want to put here a small delay, let's say a delay of one second, so for one second it's not going to animate.
04:03And that's all I have to do to first step one, is I figured out what plug-in I want to import, then I activated that plug-in,
04:11and then I'm ready to use, and you'll have to use the documentation.
04:14We'll just explore a couple of the plug-ins, but they're relatively easy.
04:18Once you activate them, usually they'll have one property that you could actually use them,
04:23and you'll find that information in the technical documents on Green Sock, with the technical documents,
04:29and how to actually use them once they're activated.
04:32So I'm going to click on save, and I'm going to run my application, and once the second is over,
04:36it's going to tint my graphic and turn it all into this red, beautiful nothingness.
04:42Now, by the way, if I wanted to, I could also untint, and the way I untint is by calling the tween light to,
04:49let me just copy this animation again, and I'm just going to add here a slight delay of, let's say, two seconds,
04:56and instead of sending a color, I'm going to send in the value of null to nullify my tint.
05:02And there we go, we've created a tint, and we undid that tint.
05:08Obviously, in our scenario, we probably wouldn't want to tint our whole logo,
05:11but if we wanted to tint only the black lines, we could have gone inside and selected those lines,
05:17created a layer there, so how about we do that?
05:20We could go inside of our element, select the actual elements that we want to tint.
05:25So maybe this is the only element we want to tint, so I could maybe copy that layer,
05:29and I could then modify it and maybe convert it into a symbol,
05:35and I could call this MC black border, and I'll just give it a name, MC border,
05:47and now I could go back into my animation, and instead of animating MC logo,
05:54I'm just going to go ahead and animate MC border.
05:57Obviously, I did that really quickly, so it's not going to be incredibly clean,
06:00but then you could see how we could animate only specifically the elements that we wanted to animate,
06:04and we could create a lot more sophisticated animations in that style.
06:10All right, that's it for tween, this tween, this plugin,
06:14and we're going to check out a couple more before we wrap up our conversation about tween light
06:18and move into tween max.
