Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. /* This is in the MC that has a bunch of children MCs which I want to attach events to */
  2. stop();
  3.  
  4. /* Initially open & show the first item */
  5. photo1.gotoAndPlay('open');
  6.  
  7. /* Set some defaults */
  8. var currOpen:Number = 1;
  9. var i:Number = 1;
  10.  
  11. /* THe listener object */
  12. var jumpToPage:Object = new Object();
  13. jumpToPage.onMouseDown = function(obj:Object) {
  14. trace('Object: '+obj);
  15. };
  16.  
  17. /* Populate the numbers for the pager and attach a click listener */
  18. for(i; i<6; i++)
  19. {
  20. var mc:MovieClip = this["photo"+i];
  21. mc.page.text = i;
  22. mc.addListener(jumpToPage);
  23. }
  24.  
  25. /* Animate the item if needed */
  26. function animateOpen(id):Void
  27. {
  28. // If it's already open, don't do anything
  29. if(id == currOpen)
  30. {
  31. return;
  32. }
  33.  
  34. if(currOpen !== 0)
  35. {
  36. var openMC:MovieClip = this[currOpen];
  37. openMC.gotoAndPlay('start_closing');
  38. }
  39.  
  40. currOpen = id;
  41. var mc = this["photo"+id];
  42. mc.gotoAndPlay('start_opening');
  43.  
  44. return;
  45. }
  46.  
  47. ## Inside the child MCs
  48. /* This is inside the child MC */
  49. AsBroadcaster.initialize(this);
  50.  
  51. /* On mouse down (i.e. when clicked) broadcast a message) */
  52. this.onMouseDown = function() {
  53. broadcastMessage('onMouseDown', this);
  54. }
Add Comment
Please, Sign In to add comment