AS3 Class Basic Banner


/ Published in: ActionScript 3
Save to your folder(s)

The basic structure As3 Class for producing a banner.


Copy this code and paste it in your HTML
  1. package com.db.banner {
  2. import com.greensock.TimelineLite;
  3. import com.greensock.TweenLite;
  4. import com.greensock.easing.Expo;
  5. import com.greensock.easing.Quint;
  6.  
  7. import flash.display.LoaderInfo;
  8. import flash.display.MovieClip;
  9. import flash.events.MouseEvent;
  10. import flash.net.URLRequest;
  11. import flash.net.navigateToURL;
  12.  
  13. // ---
  14. public class Template extends Main {
  15. private var content : MovieClip;
  16. private var tl : TimelineLite;
  17.  
  18. public function Template() {
  19. super();
  20. buttonMode = true;
  21. content = this;
  22. init();
  23. }
  24.  
  25. // ----------------- init ---v
  26. public function init() : void {
  27. tl = new TimelineLite();
  28. addListeners();
  29. reset();
  30. animate();
  31. }
  32.  
  33. // ----------------- event listeners ---v
  34. public function addListeners() : void {
  35. addEventListener(MouseEvent.CLICK, onClick);
  36. }
  37. // ----------------- clickTag ---v
  38. private function onClick(event : MouseEvent) : void {
  39. navigateToURL(new URLRequest(LoaderInfo(root.loaderInfo).parameters.clickTag), "_blank");
  40. }
  41.  
  42. // ----------------- animate ---v
  43. public function animate() : void {
  44. TweenLite.to(content.key, 1, {alpha:1});
  45. // tl.insert(TweenLite.to(content.myMC, 1, {y:0, ease:Expo.easeInOut}), 2);
  46. // tl.insert(TweenLite.to(content.myMC, 1, {y:0, ease:Quint.easeOut}), tl.duration() - 0.5);
  47. // tl.append(TweenLite.to(content.myMC, 1, {y:0, ease:Quint.easeOut}), -0.5);
  48.  
  49. }
  50.  
  51. // ----------------- reset ---v
  52. public function reset() : void {
  53. content.key.alpha = 0;
  54. }
  55.  
  56. // This is the end... my only friend the end.
  57.  
  58. }
  59. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.