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

Setting up the TweenNano Class

Setting up the TweenNano Class takes a few steps but they're the same steps that are involved with integrating any third-party plug-ins into Adobe flash. You mainly have two distinct options: using the classes directly or using a compressed version of them. In this lecture, we will see how to integrates the GSAP Library to enable us to start animating in Adobe Flash.

Video Transcript

00:00Alright, we're done with intros, it's time for us to physically get everything set up
00:04and ready to start working with our tweenlight, max, nano, and so on and so forth libraries.
00:11So the first thing that we want to do is I'm just going to give you a quick overview of
00:14the actual files that you will find inside of your source files.
00:17So if I just bring onto the display the source folder, you'll find in your source folder
00:22a com folder, an fla file, there's only going to be one fla file there, and inside
00:27of your com folder you're going to find the classes that represent the lessons or
00:33groupings of lessons that we're going to go over. They're going to have generic
00:37names inside of the com, o2geek, gsap, chapter 1, and you'll find the different
00:44chapters as we go along. Now in the fla file itself, which is already currently
00:49open, and let me just scroll right in there, you'll find two files inside of
00:54our fla, sorry, two visuals, one is going to be our graphic and the other will be a
00:58text field, and you will find o2geek that it's connected if we click on to nothing,
01:03it's going to be connected to a certain class. So make sure when you're starting
01:07chapter 1 to connect it to chapters 1 class. Now the class itself was already
01:14created and you don't have to worry too much about object-oriented programming,
01:17we're not going to touch that at all in this lesson, although we have many
01:21courses about object-oriented programming, we're going to work inside of
01:25an object itself inside of a class, but don't worry about it too much, you could
01:29work on the timeline if you're more comfortable on the timeline. But go ahead
01:33and click on to the edit class definition, and really most of the code
01:37that we're going to do is going to be inside of the constructor function, in
01:40this case we're in the side of the class chapter 1, inside of the
01:44constructor, which is called chapter 1 as well, and we're having here a small
01:48little trace, and if we just run our application really quickly we'll see
01:51hello inside of our output, which is exactly what we'd want to happen at
01:55this early stage of our development. So that's all the intros that we're going
01:59to give for setting up and configuring. I do recommend that you move into the
02:04world of object-oriented programming, we have a lot of really cool courses on
02:07it, but we're not going to talk about it more than just the setup,
02:10and beyond that we're going to try to live inside of the areas
02:14that are logical so you don't have to worry too much about what is object-oriented
02:18programming, we'll try to stick to a class at a time to keep things more simple to
02:23people that are not familiar with object-oriented programming. Alright, so
02:27the next step that I want to do is I want to make sure that I go to the
02:30download, I downloaded the the files that come with the green sock, and what I
02:34want to do is I want to grab or the SWCC file, the green sock dot SWCC, or
02:38the COM folder. Now the difference between the two is very simple, the
02:42COM folder actually contains everything, all the different classes that are
02:46involved inside of the GSAP library, which is full of different animation tools, and
02:51we're going to look at a lot of them throughout the next few lessons. While
02:54the SWCC file, literally all it is is all those files but in a compressed way,
03:00so it's all compressed so you don't have access directly to the files, it keeps
03:04files clean, it keeps it smaller visually, there really isn't any
03:08difference for you to grab this and put it inside of your folders beyond the
03:12fact that you might have to override things which could get a little bit
03:15dirty, right? On the other hand, the SWCC is a little bit more cleaner because
03:19it's completely separated, it's living inside of its own box. So what we're
03:24going to do, I'm going to take the SWCC because I really don't, I'm not planning
03:26on editing any of those COM folders, but if at any stage I feel like I need
03:30to, I could always switch between and go to the COM folder, for example, if I
03:34get some sort of an error and I don't understand what it is and it's
03:36sending me to some sort of class, although we really wouldn't find it,
03:40usually we wouldn't find a bug and we wouldn't expect to find a bug in the
03:43library but that might happen. Alright, so what I'm going to do is I'm going
03:47to use the SWCC folder, so to do that I'm just going to create a new folder
03:50here and I'm going to call this library. Usually I would have this type of
03:54folder in an external folder, not inside of the same project, but I'm
03:58putting it inside of here just to make things easier because we want to keep
04:00everything in the same place for our project that we're going to be
04:03working on together. Next what I want to do is I want to just take that
04:07green sock SWCC file and I'm just going to move it into my library and
04:12that's all I don't need to download anymore. Now that I have the SWCC
04:16inside of my library, I should be set. Now one thing that I do want to warn
04:20you, especially if you're new to SWCC files, is if by mistake you put it
04:24directly inside of the same folder of your library, of where your FLA
04:30file is, by default if I come here and I try to do an import, and I'm
04:35going to do that really quickly, import com.green sock. You're going to
04:40notice and you're going to think that everything is fine, so I'm going to
04:42import that between nano. It's going to look like and feel like everything
04:47is fine but as soon as you run your application you're going to see that
04:50there's going to be an error that's going to come back that the
04:52definition was not found. Now the reason why the definition was not
04:56found is probably you might say a little bug inside of Flash. Now it
05:00really just depends on the Flash version that you're running, but if I
05:03just go quickly into that entire folder, the reason is because Flash is
05:08recognizing all the different classes that are there but it's not actually
05:12making them available for application. To make them available for application
05:16we want to explicitly say that we want to have access to that SWCC. So to do
05:21that I'm going to first I'm going to move it into my library just to make
05:24sure that it's a little bit less confusing. And now if I go into my FLA
05:28and I'm going to go from my FLA to my publish settings, so I'm going to go
05:32here into my properties and I'm going to click on my action script 3 settings.
05:37Once I do that I'm going to see that I have here my source path which is where
05:42my SWCC was earlier and that's why it loaded in all the different
05:47definitions for our SWCC, but it doesn't really load the SWCC file itself. To load
05:52the SWCC file I need to use the library path. Now with the library path I
05:57could have if I wanted to just put here a dot just like the dot that we
06:00had in our source, oh sorry for that, I could have put here a dot just like the
06:03dot that we had in our source path. And that would work if our file was still
06:07inside of that same position. But really to try to keep things clean I'm
06:12separating it into a library because most likely you're going to use the
06:15GSAP library for many projects. So it makes sense for you to put it in a
06:19completely separate folder such as maybe two dots behind or you might go
06:24explicitly to a certain folder and browse to the specific path that you
06:29want the file to be. In my case I know it's going to be inside of my live inside
06:33of the same folder inside of the library folder. So that's all I really
06:37wanted to do and I'm going to by doing that I don't even need that slash by
06:40doing that I'm going to import everything that is inside of that
06:43library. Not only that specific SWCC so if I put it there any other SWCC it's
06:47going to automatically load those as well and by the way also any A and E
06:51files which is not relevant for us right now because we're not running on
06:54air we're running on action script and it's going to be a regular project and
06:58not an air project but in case we were running an air project we could have
07:02added our A and E's in the same type of the same location. Alright so I'm going to
07:06click on OK and I'm going to save this and if I run my application one more
07:10time you're going to see that now I'm seeing that a low message I'm not seeing
07:13any errors. Now before we wrap up this this intro to the intro to getting
07:18started and setting everything up and configuring everything I want to make
07:22sure that the two elements that I have on the stage are actually accessible via
07:27code. To do that I'm going to first click on my text field and I'm going to set
07:31my text field and give it a name so I'm going to it's a dynamic text field I'm
07:34going to call it T names so that way I have direct access to that specific
07:38element and by the way because I'm planning on animating that text field
07:43I have to make sure that the fonts are embedded so if you have so if you
07:48are and you have some text you're going to have to make sure that you're
07:51embedding that text and make sure that it's actually really embedded so if
07:54you see any errors saying that the fonts are not rendered and you try to make an
07:58animation the reason why that animation won't work is because it has to be
08:02embedded for it to be able to animate inside of action script. Alright next is
08:07I have an element a visual element but this visual element is literally just
08:11something that I imported directly from Illustrator which means that it's not
08:16going to have direct access to any programmatic features to give it some
08:20programmatic features where I'm going to have to do is I'm going to have to
08:22convert it and turn it into some sort of a visual element such as a movie clip so
08:28I'm going to go ahead and I'm going to click on modify on the top menu and
08:32convert it to a symbol once I convert it click on convert to symbol I could give
08:36it a name MC logo and I don't have to export it to action script because we're
08:41not going to actually create that actual element in action script we just have to
08:45make sure that it's a movie clip which on its own is accessible to code
08:48and I'm going to click on OK once I've created that movie clip instance I want
08:53to give it a stage name just like I did to my text field so I'm going to go into
08:56my properties and I'm going to give it the same stage name as the library name
09:01which will be MC logo and there we go and now we set up both our files last
09:06but not least before we wrap up this lesson and next lesson start our actual
09:10animation is I want to make sure that I could trace out one of those visual
09:14elements such as MC logo so I'm going to go ahead right into my class and
09:18inside of my constructor I'm just going to call MC logo just to validate that I
09:23have direct access to that file and I surely do now it might be in your case
09:28that you get an error or you might not get anything in that case the reason for
09:32that is if you go again into your properties and go into your action
09:36script properties oopsie I went into my class instead into my properties and
09:40into my action script 3 properties make sure that your stage automatically
09:45declare stage instances is set to be true if you don't set it to be true and you
09:50run your application without it it's not going to find that logo because it's
09:55not going to connect the dots so just make sure that if you're adding stage
09:59elements elements directly on the stage that you're set up and you have your
10:03automatically declare stage instances checkbox selected all right so that's it
10:09about setting up and configuring we got our files up we got we got our visuals
10:14on the stage we gave them a name we connected our library in the next video
10:19in the next lesson we're going to take a first peek at the tween nano before we
10:24move on to our main meet of our du jour which is our tween light library so see
10:29you in the next session where we start exploring tween nano

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!