Contact
| ABN 76 112 803 072
Folio currently contains
131
items
Products
SeniorStore e-shop
SeniorCMS content management
Digital Signage
Flash & AIR
Video + Broadcast Apps
AIR Apps
Flash Apps / Sites
AS3 Code
Games
Animations
E-cards
Websites
Flash Sites
Dynamic PHP Sites
E-Commerce Sites
Photography Sites
iPhone/iPad Friendly Sites
Games
Flash Games
Shockwave Games (Old)
Competitions
Animation
Flash Animations
Banners
E-cards
DVD Menus
DVD Showreels
Design
DVD Menus
DVD Showreels
Graphics
Experimental
Code
Recent Work
Top Ten Views This Month
Contact us
Viewed
17
times this month
Actionscript 3.0 - LEVEL
BASIC
AS3 Example Flash Banner Class
Last edited 27TH NOV, 2009
This a
very
basic class for someone new to AS3 - showing how to setup a banner. It should be set as the document class.
package { // FLASH CLASS IMPORTS (whatever is needed has to be explicitly defined here) import flash.display.*; import flash.events.*; import flash.net.*; public class simpleBanner extends MovieClip { // CONSTANTS AND CLASS VARS public var DEFAULTURL:String = "INSERT BANNER URL HERE"; // obtain ClickTag if being passed in // CONSTRUCTOR AND SETUP public function simpleBanner () { addEventListener (Event.ADDED_TO_STAGE, attach, false, 0, true); } private function attach (e:Event) : void { // remove redundant listener removeEventListener (Event.ADDED_TO_STAGE, attach, false); evalParam("clickTag", "DEFAULTURL", DEFAULTURL); // add code to the button movieclip (must be called myBtn) on the stage myBtn.buttonMode = true; myBtn.addEventListener(MouseEvent.CLICK, bannerClick); } private function evalParam (sName:String, sVarName:String, $default:* ) : void { var checkVar:* = root.loaderInfo.parameters[sName]; if ( checkVar == null || checkVar == undefined) this[sVarName] = $default; else this[sVarName] = checkVar; } // =================================================================================================================== // PUBLIC METHODS public function bannerClick (e:MouseEvent) : void { navigateToURL( new URLRequest( DEFAULTURL ) , "_blank"); } } }