Posted By

jeffnehlsen on 02/17/11


Tagged


Versions (?)

component.as


 / Published in: ActionScript 3
 

  1. package {
  2. import flash.display.MovieClip;
  3. import flash.events.MouseEvent;
  4. import customEvents.CustomDataEvent;
  5.  
  6. public class Component extends MovieClip {
  7.  
  8. // Some simple test data that can be grabbed from flex.
  9. public var myTestData:String = "THIS DATA CAME FROM THE SWF!";
  10.  
  11. public function Component() {
  12. // Create event listeners.
  13. btn_push.addEventListener(MouseEvent.CLICK, onMouseClick);
  14. }
  15.  
  16. private function onMouseClick(e:MouseEvent):void {
  17. // Create an anonymous object and store a bit of data in it.
  18. var myObj = new Object();
  19. myObj.testString = "This is data coming from my data object!";
  20.  
  21. // Dispatch a CustomDataEvent. The Object that is passed is stored inside
  22. // of the event and can be accessed by anything that catches the data.
  23. dispatchEvent(new CustomDataEvent(CustomDataEvent.SAVE_DATA, myObj, true));
  24. }
  25.  
  26. // This function is to be called from the Flex project to show you can
  27. // call public functions in a SWF.
  28. public function testFunction():void {
  29. btn_push.visible = false;
  30. }
  31. }
  32. }

Report this snippet  

You need to login to post a comment.