1 Reply Latest reply on May 16, 2006 12:22 PM by Newsgroup_User

    missing something fundamental here... please help.

    Level 7
      Okay, I know the answer to this is going to be easy but I am at a loss.

      I have some movieclips that have been exported as SWFs, call them
      piece1.swf
      piece2.swf
      piece3.swf

      Then, I have a main movie with one empty movieclip on the stage with an
      instance name "holder".

      To start, I do the following.

      holder.loadMovie("piece1.swf")

      which loads fine. I then assigned an onRelease event handler for the movie
      clip in the main timeline.

      holder.onRelease = function() {
      trace(this.var1)
      }

      where var1 represents some variable of piece1.swf. Now this doesn't work.
      But, as the documentation about the MovieClip.loadMovie method
      "Using event handlers with MovieClip.loadMovie() can be unpredictable. If
      you attach an event handler to a button by using on(), or if you create a
      dynamic handler by using an event handler method such as
      MovieClip.onPress(), and then you call loadMovie(), the event handler does
      not remain after the new content is loaded. However, if you attach an event
      handler to a movie clip by using onClipEvent() or on(), and then call
      loadMovie() on that movie clip, the event handler remains after the new
      content is loaded."

      So, that makes some sense... I have loaded a movie that destroys the event
      handler. But, now I have added a MovieClipLoader which when finished calls
      a function to set the onRelease() event hadler for the "holder" movieclip.
      STILL NO LUCK.

      Even though it is not what I want (or can use) I tried using the on(release)
      event handler on the 'holder' mc and it does work. But, I need to have the
      onRelease() function be dynamic and do different stuff based on the
      movieclip loaded so this approach will not work.

      I know I am missing something fundamental here so I am sorry if this post is
      a waste of time - and bandwidth.

      I have even tried the following:
      holder.loadMovie("piece1.swf");
      var c:MovieClip = holder.createEmptyMovieClip("loader", 0);
      holder.onEnterFrame = function() {
      lb = holder.loader.getBytesLoaded();
      tb = holder.loader.getBytesTotal();
      if (lb == tb) {
      activateMC(this);
      delete holder.onEnterFrame;
      }
      }


      function activateMC(mc) {
      trace("ACTIVATED");
      trace(mc);
      trace(holder._height);
      mc.onPress = function() {
      trace("PRESSED");
      }
      }

      which, when run, traces
      ACTIVATED
      _level0.holder
      200

      What AM I MISSING???

      THANKS..


        • 1. Re: missing something fundamental here... please help.
          Level 7
          "ACB" <amy.berry@foums.macromedia.com> wrote in message news:e4d1r1$8dm$1@forums.macromedia.com...
          > I have even tried the following:
          > holder.loadMovie("piece1.swf");
          > var c:MovieClip = holder.createEmptyMovieClip("loader", 0);
          > holder.onEnterFrame = function() {
          > lb = holder.loader.getBytesLoaded();
          > tb = holder.loader.getBytesTotal();
          > if (lb == tb) {
          > activateMC(this);
          > delete holder.onEnterFrame;
          > }
          > }
          >
          >
          > function activateMC(mc) {
          > trace("ACTIVATED");
          > trace(mc);
          > trace(holder._height);
          > mc.onPress = function() {
          > trace("PRESSED");
          > }
          > }
          >
          > which, when run, traces
          > ACTIVATED
          > _level0.holder
          > 200
          >
          > What AM I MISSING???

          just a couple of problems there.
          1) never mess with a movieclip while it's loading an external file!
          2) preloader must not end when both values are zero (matching)

          Here is a slightly different arrangement (using AS1 coding)

          this.createEmptyMovieClip("loader", 10);
          loader.loadMovie("piece1.swf");
          // now, you must not do anything to loader movieclip until the loading is done

          // an onEnterFrame connected with the main timeline, not the loader clip
          this.onEnterFrame = function() {
          lb = loader.getBytesLoaded();
          tb = loader.getBytesTotal();
          // make sure that the values are not zero AND that they match
          // because empty movieclips hold the value of 12 bytes I always check for a minimum
          // value of 100
          if ((lb > 100) && (lb == tb)) {
          trace(lb);
          activateMC(loader);
          delete this.onEnterFrame;
          }
          }
          // A little tip for you.. don't use lower case L in variable names.. It gets confused with I and 1 a lot. I learned this the hard
          way in past years!

          function activateMC(mc) {
          trace("ACTIVATED");
          trace(mc);
          trace(mc._height);
          mc.onPress = function() {
          trace("PRESSED");
          }
          }

          good luck,
          tralfaz