/ Published in: ActionScript 3
The basic structure As3 Class for producing a banner.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package com.db.banner { import com.greensock.TimelineLite; import com.greensock.TweenLite; import com.greensock.easing.Expo; import com.greensock.easing.Quint; import flash.display.LoaderInfo; import flash.display.MovieClip; import flash.events.MouseEvent; import flash.net.URLRequest; import flash.net.navigateToURL; // --- public class Template extends Main { private var content : MovieClip; private var tl : TimelineLite; public function Template() { super(); buttonMode = true; content = this; init(); } // ----------------- init ---v public function init() : void { tl = new TimelineLite(); addListeners(); reset(); animate(); } // ----------------- event listeners ---v public function addListeners() : void { addEventListener(MouseEvent.CLICK, onClick); } // ----------------- clickTag ---v private function onClick(event : MouseEvent) : void { navigateToURL(new URLRequest(LoaderInfo(root.loaderInfo).parameters.clickTag), "_blank"); } // ----------------- animate ---v public function animate() : void { TweenLite.to(content.key, 1, {alpha:1}); // tl.insert(TweenLite.to(content.myMC, 1, {y:0, ease:Expo.easeInOut}), 2); // tl.insert(TweenLite.to(content.myMC, 1, {y:0, ease:Quint.easeOut}), tl.duration() - 0.5); // tl.append(TweenLite.to(content.myMC, 1, {y:0, ease:Quint.easeOut}), -0.5); } // ----------------- reset ---v public function reset() : void { content.key.alpha = 0; } // This is the end... my only friend the end. } }