Basic Flash ActionScript for Designers - Navigating, URLs, and Loading Images
(Page 3 of 4 )
Navigate between scenes
Scenes in Flash can be used to organize your document into discrete sections. You can control the navigation between scenes through AcrionScript using the scene name and usinggotoAndStop() or gotoAndPlay() methods. Here are a couple examples:
// Sends the playhead to the first frame of “Scene 2”
// and stops
gotoAndStop("Scene 2", 1);
// Sends the playhead to the first frame of “Scene 1”
// and plays
gotoAndPlay ("Scene 1", 1);
Opening a URL from Flash
You can open a URL from a button or on a movie clip using getURL() method. It accepts three parameters: URL, window, and variables sending type.
URL is a valid path to a specific page or web site.
Window is an optional parameter specifying the window or HTML frame into which the document should load. You can enter the name of a specific window or select from the following reserved target names:
_self
specifies the current frame in the current window
_blank
specifies a new window
_parent
specifies the parent of the current frame
_top
specifies the top-level frame in the current window
Variables sending type is the GET or POST method for sending variables. Omit this parameter if there are none. The GET method appends the small numbers or variables to the end of the URL. The POST method sends long strings of variables in a separate HTTP header.
// Opens the site devarticles.com in a new window and sends the variables
// from flash using POST method.
getURL(“http://www.devarticles.com”, “_blank”, “POST”);
Loading an external JPEG/SWF into a movie
You can load JPEG and SWF files into your flash movie at runtime instead of importing them into flash while authoring. There are a couple of ways to do this but the easiest is using the loadMovie() method of the movie clip class. That allows you to control the movie clip to perform actions on the loaded file.
// Loads ani.swf file into anim_mc Movieclip.
anim_mc.loadMovie(“ani.swf”);
// Loads a JPG file.
anim_mc.loadMovie(“ani.jpg”);
Next: Loading External MP3 Files >>
More Flash Articles
More By Adi Reddy Mora