02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Using The AutoAlphaPlugin

When animating, many times you will animate an element to a zero visibility. In Adobe flash, elements that are not visible are still being rendered and the only way to stop the rendering is by removing it from the stage or setting visibility to false. The AutoAlphaPlugin helps reduce the stress on your display engine as it automatically sets the visibility of the item to false when it's not visible. In this lecture we will explore the AutoAlphaPlugin.

Video Transcript

00:00All right, so what I want to do next is I want to approach two new plugins that both kind of relate to visibility.
00:06Well, they don't kind of, they do.
00:08So I'm going to import them. We're going to see how do they relate to visibility.
00:11Again, it's going to be inside of our plugins folder.
00:14And then we'll go inside and we're going to select our auto alpha plugin.
00:20And let me just copy all this and we're going to do that again.
00:24And I'm going to also import our visible plugin.
00:28OK, so I'm just going to activate both of them by just adding them into my array of the active activate function.
00:36So I'm just going to send them over.
00:38That way, all these three plugins are going to be active.
00:41What I'm going to do next is I'm going to just comment out this animation, because what I want to do,
00:45I'm going to show it. I want to do a different animation instead of this one.
00:49And what I wanted to get first is I want to animate my visual object and fade it out after it turns red.
00:57So to do that, I'm going to just fade out my image by creating a new tween light to MC logo dot.
01:06MC logo itself, we want to animate out and it's going to take, oh, there was a second.
01:11I was playing around with stuff when we were gone and I'm going to animate that for one second as well.
01:17And I'm going to have it alpha to zero.
01:20And it's going to happen in a delay after that first animation is done, which would happen after two seconds.
01:26So basically, our flow is one second.
01:28We're waiting for a second.
01:30We're tinting into red.
01:32And then a second after that, we're going to animate ourselves into not being visible.
01:38And if I run my application again and we run it, we'll see it'll turn red and then we're going to fade out, which is perfect.
01:43Now, the only problem that we have, and if I add here a quick on complete function,
01:49I'm going to do an inline function here and I just want to trace out MC logo visible.
01:55Now, visible is basically a property in flash that basically says that is it visible on the stage or not?
02:01If it's visible on the stage, that means that flash is rendering this image.
02:05And if flash is rendering the image, that means we're impacting the rendering, even though it's not visible.
02:10So what will actually happen and let me just fix this little error that we got here.
02:15So first of all, I complete its functions in lower case.
02:25So let me just run this one more time.
02:29There you go. And you can see that the value that we're getting back is true.
02:33And that's not a good thing, especially if we have a lot of animations that are happening at the same time.
02:37Maybe some are fading in and some are fading out.
02:40But as long as they're visible on the stage, flash is rendering them, which is hurting our performance.
02:46So what I want to do is I'm going to use the property that comes with the auto alpha plugin,
02:51which enables me instead of calling the alpha command to call that auto alpha.
02:55And what auto alpha will do is once we reach zero, it will automatically switch off our visibility.
03:01And if I run this one more time and we're going to let it animate out again,
03:05we'll see now the visibility will go down to zero.
03:07So that is the advantage of working with the auto alpha, which will basically improve your performance of your application.
03:14The next item I wanted to talk about is the visible plugin, which is a really cool plugin that could work as well.
03:20So imagine instead of creating this alpha, and I'm just going to comment this section out and create a new animation.
03:28And how about I'm going to comment this out is this is fine, actually, and I'm going to take this animation.
03:34And this time around, what I want to do is I'm going to make my animation really big once the animation is complete.
03:39So I'm going to create a delay of two seconds and maybe I'm going to go to scale X, scale X.
03:45I'm going to make it 10, 10 times the size and scale Y.
03:49I'm going to make it also 10 times the size.
03:51Let's leave it at a second here for a second and I'm going to animate my full logo, basically blowing it up out of proportion.
03:57If I run this a second just to see how it would look like, then I should expect my logo to fly into our face,
04:03which is exactly what it's doing.
04:05My only problem is, is once this flight is over, I really want to turn the visibility off
04:09because it's kind of like flying out of your visibility.
04:13So to make that happen and to make it work, I could create an on complete and then go to my MC logo
04:18and then set my visibility to be false because I haven't been animating my alpha.
04:23Or I could set my visibility directly, set it to false.
04:28And what will happen is because we're using the plugin visible plugin,
04:32it will automatically switch the visibility based on the value that's here once our animation is complete.
04:38So if I save this and watch it one more time, we'll see that the animation will fly right into the user's face and then disappear.
04:45Now, I don't know if obviously, but this seems like the we need a better a better ease to this because what's happening is it's kind of like easing into its spot,
04:54making it really obvious that we're switching off.
04:58What we really want to do is add here some sort of an ease.
05:00So I'm going to come here and I'm going to import an ease and let's find a right ease for this.
05:07And let's try let's try with something that's a little bit more hard.
05:11What do we want to be? We want to we're going to take the default ease.
05:16And what I'm going to do is that what I want is I want the ease to be faster,
05:20basically less of an ease towards the end.
05:23Or in other words, let's give it a try and see the two variations.
05:26So if I come here and I said you're an ease and I choose from the ease, which is the basic package.
05:31Oh, let me let me find a different one.
05:34This ease thing doesn't look like it's going to do the trick.
05:41Is it really weird that I'm not getting hints?
05:44Maybe because it's a core element, they actually can't use it.
05:47So I need to find something that is very standard, like regular.
05:51If there's regular here, let's find regular linear linear sounds good to me.
05:56So linear sounds like the most simple type of animation.
05:59And if I check my linear and I'm going to I'm going to choose.
06:02First of all, if I choose a linear ease,
06:04my guess is that it's going to be the same speed from beginning to end, which isn't very natural.
06:10Now, on the other hand, what I want to do is I want to have the speed kind of like become faster and faster as we get close.
06:16If I create an ease in, that means it's going to slow down as it's getting close to the end, which is not what we want either.
06:23What we really want to have is an ease out,
06:26which basically would say that we're starting slowly and then we're speeding up basically,
06:36which is much better.
06:37But still, I don't like this linear.
06:39Let's find a different one.
06:40Maybe we're not saying that's a little bit more dramatic.
06:44So not elastic because we don't want it to jump around, but we might want to try maybe one of the power eases.
06:49You have your power one, two, three.
06:51How about let's see strong.
06:53Strong sounds like a good beginning because we want to have a strong ease or more accurately want to have a strong ending.
06:59We don't ease and now we just want to have an ease out.
07:02Let's give it a try.
07:06So this is a lot.
07:08This is very interesting.
07:09But our problem with this is that it's actually the exact opposite of what we want.
07:13So we're going to put here and ease in.
07:14And literally what I'm doing right now is exactly the type of game that you would be doing to try to figure out the perfect animation.
07:20And you can see here you go.
07:21This one worked perfectly.
07:23It feels very natural.
07:24It doesn't feel like it's stopping at any stage.
07:26So it's kind of like flying into your face.
07:29And that's exactly what we wanted and expected it to do.
07:32So there you go.
07:33And by the way, we didn't have to wait for that initial ease because I'm kind of thinking it'd be cool if the color was changing.
07:39And I would be like maybe I would even change it to maybe a different color or maybe some sort of a gray.
07:44And instead of maybe delay of one and a half seconds, I would have it halfway through as it's animating,
07:50as the color is happening, switch it out.
07:52And I don't like that gray.
07:54So you see, but this is basically the game.
07:55And this is like where you go crazy and you start playing around to try to figure out what makes you happy.
08:01Obviously, nothing right now is making me happy.
08:03Maybe I want a darker color.
08:06Yeah, I feel like maybe a dark color would be more suitable.
08:09So yeah, so it's a much more subtle animation, which I kind of like.
08:12So it's not even almost almost not even noticeable.
08:15All right. Perfect.
08:16So that's it for auto ease and what is it?
08:20No, it's our auto alpha plug in invisible plug in.
08:22We played around a little bit with the easing.
08:24And so how do you finesse and play around to try to find that right easing as well in the process of creating this little animation?
08:32That's it. And we're going to continue in the next lesson where we're going to look at one more ease, which is going to be our blur ease.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!