Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
I have mentioned before in this title that if you are going to write a lot of code for your applications, you should be using Flash Builder to write the code rather than Flash Professional. This is for the simple reason that Flash Builder has more powerful code writing tools than Flash Professional. Of course, if you don't have Flash Builder, maybe you don't want to go out and buy it just for this feature. But if you do, I highly recommend using Flash Builder as your coding platform. So in this movie, we will look at creating the artwork in Flash and using Flash Builder just to write the code.
So on the Stage here I have my mini application. It's a simple banner ad. I am going to make this button a link, so this is going to open up the Explore California website. Now, the formal way to do this would be to create an ActionScript class file in Flash Builder, write the code out, and then come back into Flash Professional to do the testing. So let's see how to do that. Note that my instance name is link_btn. So I will Deselect everything and then I am going to create something called the document class.
Now, I don't really want you to worry about what the document class is. This is something I am going to cover extensively in my ActionScript 3.0 title for Flash CS5. So for more information about ActionScript, go to that title. I am just showing you for those of you who want to get heavily involved into writing code, this is how to do it. So I am going to click the Pencil icon next to Class to edit the class definition. Flash will then open up the Create ActionScript 3.0 Class window, where I can choose to use Flash Professional or Flash Builder as my class editor.
Then I will set a class name. So I call this FBTest. So I will click OK. And then I already have Flash Builder open, so Flash will tab over there for me and then I need to set my FLA file, which Flash Builder already knows, and then for my project contents I am just going to check Use default location, and I will click Finish. So Flash then creates my file and it takes me over to my FLA file. And I have to set the New ActionScript Class setting, so I am going to set this right here.
I can change the package or adjust the superclass if I want to. For right now I am just going to click Finish. So now I am in FBTest.as. So inside of the constructor method for here, I am going to write some code. I am not concerned with you understanding exactly how this code works. This is just something for people that are going to be writing a lot of code using Flash Builder. So I am going to type link_btn.addEventListener. And the Event is going to be MouseEvent.CLICK, all caps.
And then I am going to run a method called clickButton. I will have to import the MouseEvent lasses, so import flash.events.*. And then I will define that clickButton method. So I will type function clickButton. We'll receive the MouseEvent, colon void. Again, I am going to explain how all of this code works in my ActionScript title, so definitely go there if you are interested in learning this.
So in here I am going to type navigateToURL. I am going to create a new URLRequest, and in here I am going to write a link to the Explore California website. So www.explorecalifornia.org. And then I am going to import all of the .net classes so I can get this navigateToURL method as well. So I will save the file. So I have created this file and edited it through Flash Builder and now I will tab back over to Flash Professional.
So I have written the functionality for this button in Flash Builder. Now when I test the movie from Flash, I can click on the button and I will see the link to that website. So the whole purpose of this movie was to show you that you can write code in Flash Builder by creating a new class and choosing Flash Builder as your editor.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.