1 Reply Latest reply on Mar 26, 2011 1:17 AM by Pursue G

    Unable to get custom events from child movie clip

    Pursue G

      Hey Guys

       

       

      I am not much aware of AS 2.0 and i am stuck at getting custom events from Child SWF to Parent SWF file

       

      Please find my code attched.

       

       

      Any sort of help would be great...

       

      Thanks a lot man!!!

       

       

      Parent swf

       

      System.security.allowDomain("*");

      import mx.utils.Delegate;

      var addEventListener:Function;

      createEmptyMovieClip("mcTemp",this.getNextHighestDepth());

      var loader:MovieClipLoader = new MovieClipLoader();

      loader.addListener(this);

      loader.loadClip("EventDispatcher.swf", mcTemp);

      var eventHandlerDelegate = Delegate.create(this, eventHandler);

      function onLoadComplete(e):Void

      {

      trace("on load complete");

      mcTemp.onPlay();

      mcTemp.addEventListener("hello", this);

      mcTemp.addEventListener("onPickedUp", this);

      mcTemp.addEventListener("onDropped", this);

      mcTemp.addEventListener("END_OF_QUIZ", this);

      }

      function onPickedUp(e:Object)

      {

      trace("11111111111onPickedUp");

      }

      function onDropped(e:Object)

      {

      trace("onDropped");

      }

      function hello(e:Object)

      {

      trace("hello");

      }

      *********************************************************End****************************** **************
      Child :
      stop();
      import mx.events.EventDispatcher;
      var broadcaster:Object = new Object();
      EventDispatcher.initialize(broadcaster);
      var listener:Object = new Object();
      listener.onPickedUp = function() {
      this.dispatchEvent({type:"onPickedUp"});
      trace("Picked up.");
      };
      listener.onDropped = function(evt:Object) {
      trace("Dropped on " + evt.msg + " side.");
      };
      broadcaster.addEventListener("onPickedUp", listener);
      broadcaster.addEventListener("onDropped", listener);
      // ** General code **
      var halfway:Number = Stage.width / 2;
      mcBall.onPress = function() {
      this.startDrag();
      broadcaster.dispatchEvent({type:"onPickedUp"});
      };
      mcBall.onRelease = function() {
      this.stopDrag();
      if (this._x < halfway) {
      broadcaster.dispatchEvent({type:"onDropped", msg:"left"});
      } else {
      broadcaster.dispatchEvent({type:"onDropped", msg:"right"});
      }
      };
      function onPlay()
      {
      flash.external.ExternalInterface.call("alert", "inside onPlay");
      trace("inside player");
      }