9 Replies Latest reply on Feb 23, 2007 3:08 PM by Newsgroup_User

    Fading in a External jpg or swf

    StargrrlMedia
      Im using this actionscript to load external swf's into an emtpy movie clip called "square":

      on (release) {
      loadMovie(" http://www.stargrrl.com/flash/intro.swf", "_root.square");
      _root.square._x=170;
      _root.square._y=120;
      }


      I want to make the swf's fade in using actionscript. I found this code online for fading in swfs and jpgs but Im not having any luck getting it to work:

      onClipEvent (load) {

      this._alpha = 0;

      }

      onClipEvent(enterFrame) {

      if (this._alpha <100) {

      this._alpha += 10;

      }

      }

      Any help or pointers would appreciated. I can't find one tutorial that precisely lays out how to do this!

      A
        • 1. Re: Fading in a External jpg or swf
          Darshan Rane Level 3
          have u written this code on movieclip _root.square where u are loading u r swf
          • 2. Re: Fading in a External jpg or swf
            StargrrlMedia Level 1
            The external swf is loading into and empty movie clip on the stage with an instance name of "square".

            A
            • 3. Re: Fading in a External jpg or swf
              Pal_w_G Level 1
              Try to monitor the loading process......

              after the swf loads then assign the onLoad and onEnterFrame code that should solve your problem......
              • 4. Re: Fading in a External jpg or swf
                StargrrlMedia Level 1
                You mean like this? It doesnt pull any errors but It doesnt seem like its fading in or its fading in too fast:

                on (release) {
                loadMovie(" http://www.stargrrl.com/flash/intro.swf", "_root.square");
                _root.square._x=170;
                _root.square._y=120;
                square._alpha = 0;
                if (square._alpha <100) {
                square._alpha += 10;
                }
                }
                • 5. Re: Fading in a External jpg or swf
                  Level 7
                  You're going about this all wrong... as you've summized, your clip is fading
                  in too fast. It fades in before your image loads because of the way you have
                  it coded.

                  First of all, use the MovieClipLoader class. LoadMovie is worthless. Using
                  the MovieClipLoader class, you will get the onLoadInit handler which you can
                  use to start your fade in.

                  I will let you do some reading - but basically you want to do it like so:

                  start your empty clip, on the stage, with an alpha of 0
                  use MovieClipLoader to load your swf into the empty clip
                  As soon as onLoadInit fires then fade the clip in by assigning the
                  enterFrame function... and here you might look at using something like Fuse
                  which will make things like fading clips in much easier and more
                  straightforward.

                  --
                  Dave -
                  Head Developer
                  www.blurredistinction.com
                  Adobe Community Expert
                  http://www.adobe.com/communities/experts/


                  • 6. Re: Fading in a External jpg or swf
                    SymTsb Level 2
                    I prefer a much simpler method. create the MovieClipLoader instance and load your clip. Inside your onLoadInit, use the Tween Class to fade the image in. It works all the time for me. I hate using onEnterFrames as they are controlled by the timelines frame rate. Tween allows you to set an actual set number of seconds. Its not 100% accurate but it is certainly more realistic than the onEnterFrame method.
                    • 7. Re: Fading in a External jpg or swf
                      StargrrlMedia Level 1
                      Simple is great I dont know enough actionscript to do this. Do you happen to know of tutorial that will walk me though it? How did you learn the method? I'd love to have someone I can pay to do work that is still beyond my ability. Know of anyone?

                      The Fuse sounds great but I'm not at that point yet unfortunately to even use that. I just need something very basic.

                      A
                      • 8. Re: Fading in a External jpg or swf
                        SymTsb Level 2
                        Stargrrl, tried responding to your message to me with no luck. Regardless, send me an e-mail @ spydird@spydirdesu.net We'll get it squared away.
                        • 9. Re: Fading in a External jpg or swf
                          Level 7
                          The way I outlined is pretty much the same as SymTsb said - I just use Fuse
                          instead of Flash's own Tween class - mostly because Fuse is _much_ more
                          powerful.

                          You can use Fuse... it's quite easy to do simple things - you'll find that
                          fading clips in is much simpler with Fuse. Example:

                          import com.mosesSupposes.fuse.*;
                          ZigoEngine.register(PennerEasing);

                          those two lines import the Fuse classes and allow you to use short cuts for
                          easing. You would use those as the first couple lines in any fla you make
                          that you want to use Fuse in.

                          Now, to fade in a clip you simply do:

                          var f:Fuse = new Fuse();
                          f.push({target:clipToFade, alpha:100, seconds:1.5, easing:"easeInQuad"});
                          f.start();

                          that's it - the clip with the instance name 'clipToFade' will tween it's
                          alpha to 100 in 1.5 seconds.

                          I would suggest you looking in the Help at the MovieClipLoader class, and
                          specifically its onLoadInit method. It has a good example of loading a clip
                          and knowing when it's finished loading...

                          --
                          Dave -
                          Head Developer
                          www.blurredistinction.com
                          Adobe Community Expert
                          http://www.adobe.com/communities/experts/