With the creation of Actionscript 3.0 many things changed. Once familiar code is now long gone, and old concepts have been completely revamped. The once familiar web link is now a thing of the past replaced by new commands and methodology. The tutorial below is useful for created a Flash movie that will automatically jump to a web page as often occurs at the end of an animated intro or presentation.
All of the code here should be placed in the last frame of your timeline. It is standard practice to place all code on it's own layer called actions. This makes it easier to find and edit the code in your project when you come back to it at a later date.
The full code block looks like this:
stop();
var myLink:URLRequest = new URLRequest("insert URL here");
navigateToURL(myLink);
//First you will want to stop the timeline to prevent the animation from looping. If you don't do this the animation will repeat as will the command to open a new web page. I once crashed a computer because I forget about this fact and it ended opening p hundreds of web page windows, one after the other.
stop();
/*
1: All links to external content must be stored in a variable before they can be used. This is true if you want to import data from an external file like a text (.txt) or html (.html) file or as we do here to navigate to an external website.
2: The var keyword is used to declare a variable. Here the arbitrary name myLink is used as the variable name. All variables should be datatyped, that is the type of data that they are going to contain needs to be explicitly stated. As seen in the code below datatypes are connected to the variable names via a colon.
3: On the right side of the variable declaration the new keyword is used to instantiate the myLink variable. This establishes it as an instance of the URLRequest class. If you aren't familiar with them classes are the many different types of objects that you have access to in Flash. Other examples of classes would be SimpleButtons and MovieClips. The actual URL you would like this varaible to hold are placed inside the parenthesis on the right side of the equattion.
*/
var myLink:URLRequest = new URLRequest("insert URL here");
/*
1: Once the myLink variable has been declared it can be used. The code here is the function that actually navigates to the web page. Since this code is written all alone in the keyframe it will execute the moment that playhead encounters it instead of in response to some user initiated event like a button click. Note that the URLRequest variable that was declared about is placed inside the parenthesie of the navigateToURL function here.
*/
navigateToURL(myLink);
Technorati Tags: flash, Actionscript 3.0, actionscript, weblink, Adobe Flash
All of the code here should be placed in the last frame of your timeline. It is standard practice to place all code on it's own layer called actions. This makes it easier to find and edit the code in your project when you come back to it at a later date.
The full code block looks like this:
stop();
var myLink:URLRequest = new URLRequest("insert URL here");
navigateToURL(myLink);
//First you will want to stop the timeline to prevent the animation from looping. If you don't do this the animation will repeat as will the command to open a new web page. I once crashed a computer because I forget about this fact and it ended opening p hundreds of web page windows, one after the other.
stop();
/*
1: All links to external content must be stored in a variable before they can be used. This is true if you want to import data from an external file like a text (.txt) or html (.html) file or as we do here to navigate to an external website.
2: The var keyword is used to declare a variable. Here the arbitrary name myLink is used as the variable name. All variables should be datatyped, that is the type of data that they are going to contain needs to be explicitly stated. As seen in the code below datatypes are connected to the variable names via a colon.
3: On the right side of the variable declaration the new keyword is used to instantiate the myLink variable. This establishes it as an instance of the URLRequest class. If you aren't familiar with them classes are the many different types of objects that you have access to in Flash. Other examples of classes would be SimpleButtons and MovieClips. The actual URL you would like this varaible to hold are placed inside the parenthesis on the right side of the equattion.
*/
var myLink:URLRequest = new URLRequest("insert URL here");
/*
1: Once the myLink variable has been declared it can be used. The code here is the function that actually navigates to the web page. Since this code is written all alone in the keyframe it will execute the moment that playhead encounters it instead of in response to some user initiated event like a button click. Note that the URLRequest variable that was declared about is placed inside the parenthesie of the navigateToURL function here.
*/
navigateToURL(myLink);
Technorati Tags: flash, Actionscript 3.0, actionscript, weblink, Adobe Flash
No comments:
Post a Comment