Sunday, March 28, 2010

Adding a url to flash buttons in...

I have a web site built and I have recently added Flash buttons and I need to add my web pages to the buttons. How would I go about doing this?

Adding a url to flash buttons in...

This is normally done when you create the Flash files, unless you have purchased these buttons and they are designed to have you specify url's in the embedding code. You will be the only one who can determine that at the moment.

Adding a url to flash buttons in...

I created the buttons.

If you created the buttons using Flash (not Dreamweaver), then you need to build the linking code into the buttons.

How would I name the links in AS? They aren't live yet.

The links themselves are plain old urls. much like any other links, but the code to make them link depends on what version of actionscript your file is using.

I'm using AS 3.0. So for example, it in order to link up the home button it'd the action script would be home.goto index. Could I add hot spots in Dreamweaver and achieve the same result?

Let's say you create a button symbol.?Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.?The first thing you need to do to make it useful code-wise is to assign it a unique instance name.?So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it ''btn1''


In AS3, to make a button work with code, you need to add an event listener and event handler function for it.?You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.?In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:


btn1.addEventListener(MouseEvent.CLICK, btn1Click);

The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:

?
function btn1Click(evt:MouseEvent):void {

var url:String = ''http://www.awebsite.com/awebpage.html'';

var req:URLRequest = new URLRequest(url);

navigateToURL(req);

}

Does the website have to be live for this to work?

Not necessarily, but it helps when things involve working with browsers.?Flash doesn't always implement browsers properly when testing locally.

I tried the script and it didn't work. I copied and pasted what you have and nothing happened.

The code and directions I provided will work, but you have to know what you are supposed to be doing with them, and without being certain of what you've designed, I can't really explain that beyond what I have already.?What I can do is create a quick sample for you to look over...

Here's a link to a web page that holds a button in a Flash file if you need to see the html page code.

http://www.nedwebs.com/Flash/AS3_Button.html

And here is a link to the Flash source file:

http://www.nedwebs.com/Flash/AS3_Button.fla

  • get ride of
  • No comments:

    Post a Comment