2 Replies Latest reply on Nov 14, 2008 7:39 AM by Newsgroup_User

    question about tweens

    Level 7
      I have a moviecliploader that loads in jpeg images into movieclips. The code
      is below. I'm not sure if this is good code, for example should the listener
      and loader be outside of the function. Also, depending on the size of the
      jpeg loading, how can I tell which jpg has loaded when the
      FADE_IN.onMotionFinished has been triggered. Any helpon this would be much
      appreciated.

      function LOAD_BACKGROUND(newback){
      this.createEmptyMovieClip("mBACK"+vCURRENT_BACK_DEPTH,
      vCURRENT_BACK_DEPTH);
      this["mBACK"+vCURRENT_BACK_DEPTH]._alpha=0;

      var LISTENER_BACK:Object = new Object();

      LISTENER_BACK.onLoadInit = function(target_mc:MovieClip) {
      //background has loaded now fade it in
      trace("New background loaded:"+target_mc);
      FADE_IN = new Tween(target_mc, "_alpha",
      mx.transitions.easing.None.easeNone, 0, 100, .5, true);
      FADE_IN.onMotionFinished = function() {
      _root["mBACK"+(vCURRENT_BACK_DEPTH-1)].removeMovieClip();
      vCURRENT_BACK_DEPTH++;
      }
      }
      var MCL_BACK:MovieClipLoader = new MovieClipLoader();
      MCL_BACK.addListener(LISTENER_BACK);
      MCL_BACK.loadClip(" http://"+_root.vSERVER_NAME+"/involve/backgrounds/"+newback+".jpg","mBACK"+vCURRENT_BACK_D EPTH);}

        • 1. Re: question about tweens
          kglad Adobe Community Professional & MVP
          this would be better:

          • 2. Re: question about tweens
            Level 7
            Thanks for this, I notice that you have taken all of the listener and loader
            out of the function, makes sense!

            If I were loading many backgrounds, how do I know which background FADE_IN
            is referring to, ie FADE_IN.onMotionFinished = function()

            Many thanks


            "kglad" <webforumsuser@macromedia.com> wrote in message
            news:gfk4m5$7c$1@forums.macromedia.com...
            > this would be better:
            >
            >
            >
            > function LOAD_BACKGROUND(newback) {
            >
            > this.createEmptyMovieClip("mBACK"+vCURRENT_BACK_DEPTH,vCURRENT_BACK_DEPTH);
            > this["mBACK"+vCURRENT_BACK_DEPTH]._alpha = 0;
            >
            >
            > MCL_BACK.loadClip(" http://"+_root.vSERVER_NAME+"/involve/backgrounds/"+newback+
            > ".jpg",this["mBACK"+vCURRENT_BACK_DEPTH])
            > }
            >
            > var LISTENER_BACK:Object = new Object();
            >
            > LISTENER_BACK.onLoadInit = function(target_mc:MovieClip) {
            > //background has loaded now fade it in
            >
            > trace("New background loaded number: "+target_mc._name.substring(5));
            > FADE_IN = new Tween(target_mc, "_alpha",
            > mx.transitions.easing.None.easeNone,
            > 0, 100, .5, true);
            > FADE_IN.onMotionFinished = function() {
            > _root["mBACK"+(vCURRENT_BACK_DEPTH-1)].removeMovieClip();
            > vCURRENT_BACK_DEPTH++;
            > };
            > };
            >
            > var MCL_BACK:MovieClipLoader = new MovieClipLoader();
            > MCL_BACK.addListener(LISTENER_BACK);
            >