Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Loading in SWF Content is fairly easy using the UILoader component, but what if you want to link to content on other sites? Well, this can be done a number of ways. And I need to do it in this about.fla file. So if I open that up, you can see that I've text in here, and quite frankly, you're probably going to have some text that you want to link out to a place on the Web. Say, for instance, if I just select this word, 'Adobe,' and I want this to link to Adobe systems site, I can select that word and in the Properties panel, down right under Options, twirl that down, if it's not already open and in the Link field, you can go ahead and type in http://www.adobe.com.
Now if I want to open up a new browser window, I can select _blank. That way it keeps them on my site, but also serves up the information that they're after on Adobe's site. So that's done and that word is still highlighted. And probably what you're going to want to do is make it look different, so it looks like a link, so it stands out more. Currently, most of my buttons are red and that's kind of my signature color for this site. I'll change the color of that to red as well. Well, what about email addresses? Well, right down here, I have an email address.
And I want this link to link to firstname.lastname@example.org. So I am going to select that text and in the same area under Options in the Link field, I can type in mailto: email@example.com. Just like in HTML you do it the same way. It's pretty simple, just hit Return. I won't worry about the Target at all, but that's set up and the last thing I need to do for that is change the color to red. All right.
It's looking good so far, so let me just do Ctrl+Test Movie and if I click on Adobe, it opens up Adobe's site. Great! Close that. You see email. If I click on that email link, it will open up my default email client with that email address in the To field and I can type whatever I want, since they'll be emailing John@johndoe. It's done that easily and I'll close that.
Well, what about your own sort of standalone button? What if it's not text in a sentence? Well, I need to do that a little bit differently, because I need to set this up as a button, give it an instance name and then do a navigate to the URL. So I'm going to close that SWF and I'm going to open up the Timeline panel and I'm going to select New layer. I'm going to change this layer name to AS, because my ActionScript is going to go here.
Now the first thing I need to do is select this item and currently, it just says it's an instance of a Blog button, but it's really just a Movie Clip. Well, to be honest, I want to make this actually a button. Okay, so I'm just going to go ahead and do a Modify. I'm going to do a Convert to Symbol. It's the equivalent of just dragging it into my Library, but I'm going to do a Convert to Symbol and then, I can type in 'blog' and I'm going to make sure this is a Button, and select OK. All right.
So this is now a Button. So just to confirm in my Properties panel, it says that it's a button and I need to give it an instance name, blog_btn, just like that. I want to remember this name, so I'm just going to do a Command+C to copy it, copy that instance name. Now I'm going to go to that layer I have created. I'm going to select that first frame. I'm going to go to Window and open up my Actions panel. Now right in here, this is where I'm going to write my code. So just a comment, Link to website, I'm going to paste in blog_btn and I'm going to add an EventListener, just like I've done in the past, MouseEvent, I'm going to listen for the CLICK and then it's asking me for another parameter, which I'm going to put in visitSite.
So that's the name of the function that is going to be called when they click on this button. So visitSite. All right. Now I need to make this function, function visitSite, and it's going to accept a MouseEvent and then I'll just type in void, because it's not going to return to anything. But this is the basic structure for any function and it's looking good so far. But right in here, within these two curly braces, this is where I want to put a URL request and then a navigate to URL.
So I need to create a variable called req or request. It could be called anything you want it to be called. Just remember the name and I want this to be a URLRequest. So I'm creating a variable that is a URLRequest and it's a new URLRequest. And you know it's correct, because it will change colors usually to that blue and then you can go ahead and type in your URL.
That's this blog so - all right. There we have it, a new URLRequest I've just created. So within this container called req, exists this URL. Now I can use that wherever I want, but really the only place I need to use it, currently, is in the navigateToURL function. So I'm going to create this call to this function, called navigateToURL, and I'm just going to say req for request.
So that's my variable and then I can do a comma and if you want, you can also type in _blank within quotes and that will open up a new web page. So let me just get rid of this last line. So that's how it's done, to sort of create a container that's going to contain that URL and then just put that variable into the navigateToURL function call is what it is, and then make sure it opens up in a new window. Now let's do a Ctrl+Test Movie.
These buttons I know it'll work, these links, but let's check this one out. Click Visit Blog and sure enough, it opens up my personal blog in your default browser. So, it works out great. Pretty simple to do for the most parts. And really, it's again, all back to EventListeners and then just adding a navigateToURL that passes in that certain URL Request. And that's really how you link to a content that exists outside of your site.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 59226 Viewers
61 Video lessons · 92183 Viewers
82 Video lessons · 104057 Viewers
56 Video lessons · 106753 Viewers
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.