attachMovie fade in/out - Anyone done this?

  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 12, 2007
  • Posts: 13
  • Loc: Sydney
  • Status: Offline

Post June 19th, 2007, 12:38 am

Hello!

I'm trying to work out the easiest way to make this possible.

I have a series of thumbnail images, each one of them actions attachMovie - bringing it's own movieClip to my stage.

When a different thumbnail/button is clicked, I want the currently playing movieClip to fade out while the new mclip fades in.

How do I do this?

With an array?

Please help.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 19th, 2007, 12:38 am

  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 12, 2007
  • Posts: 13
  • Loc: Sydney
  • Status: Offline

Post June 19th, 2007, 1:10 am

Here is my attempt - it doesn't work but maybe this will help to sjow you what I'm attempting?

Code: [ Select ]
host = new Array("host1","host2", "host3", "host4", "host5");

this.createEmptyMovieClip("target1", "target1", 3)
this.createEmptyMovieClip("target2", "target2",4)

target1.attachMovie(host[0]);
target2._alpha = 0;
activeTarget = target1;
currentIndex = 0;

this.onEnterFrame = function() {
   if (obj1._alpha > 0) {
      obj1._alpha -= 10;
   }
   if (obj2._alpha < 100) {
      obj2._alpha += 10;
   }
};

myBtn.onRelease = function() {
   if (activeTarget == target1) {
      obj1 = target1;
      obj2 = activeTarget = target2;
   } else {
      obj1 = target2;
      obj2 = activeTarget = target1;
   }

   if (currentIndex < host.length-1) {
      currentIndex++
   } else {
      currentIndex = 0
   }

   obj2.attachMovie(host[currentIndex])
}
  1. host = new Array("host1","host2", "host3", "host4", "host5");
  2. this.createEmptyMovieClip("target1", "target1", 3)
  3. this.createEmptyMovieClip("target2", "target2",4)
  4. target1.attachMovie(host[0]);
  5. target2._alpha = 0;
  6. activeTarget = target1;
  7. currentIndex = 0;
  8. this.onEnterFrame = function() {
  9.    if (obj1._alpha > 0) {
  10.       obj1._alpha -= 10;
  11.    }
  12.    if (obj2._alpha < 100) {
  13.       obj2._alpha += 10;
  14.    }
  15. };
  16. myBtn.onRelease = function() {
  17.    if (activeTarget == target1) {
  18.       obj1 = target1;
  19.       obj2 = activeTarget = target2;
  20.    } else {
  21.       obj1 = target2;
  22.       obj2 = activeTarget = target1;
  23.    }
  24.    if (currentIndex < host.length-1) {
  25.       currentIndex++
  26.    } else {
  27.       currentIndex = 0
  28.    }
  29.    obj2.attachMovie(host[currentIndex])
  30. }
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13458
  • Loc: Florida
  • Status: Offline

Post June 19th, 2007, 1:34 am

What version of Flash are you using ?

I like to use the mx.transitions.Tween class in Flash 8.

This one will cross-fade two MovieClips, oldClip & newClip over a matter of half, or 0.5 seconds.

Code: [ Select ]
import mx.transitions.Tween
import mx.transitions.easing.Stong

var tweenOut:Tween = new Tween(oldClip, "_alpha", Strong.easeOut, oldClip._alpha, 0, 0.5, true);

var tweenIn:Tween = Tween(newClip, "_alpha", Strong.easeIn, newClip._alpha, 100, 0.5, true);
  1. import mx.transitions.Tween
  2. import mx.transitions.easing.Stong
  3. var tweenOut:Tween = new Tween(oldClip, "_alpha", Strong.easeOut, oldClip._alpha, 0, 0.5, true);
  4. var tweenIn:Tween = Tween(newClip, "_alpha", Strong.easeIn, newClip._alpha, 100, 0.5, true);
Strong with this one, the sudo is.
  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 12, 2007
  • Posts: 13
  • Loc: Sydney
  • Status: Offline

Post June 19th, 2007, 1:45 am

hey joebert - good to see you (I see your posts a lot!)

Yeah - I admit I copied some old code here & didn't update it!

I am a HUGE fan of the tween class. I willd definitely use it -

What I am most confused about is how the heck do I make it so:
a) the current movieclip (which in the case of my project has a flv playing in it) fades out...
b) The newly selected movieclip fades in (using our lovely tween class)

I have a LOT of movieclips to jump between - so this is why I figure an Array would be cool.

How do I do this? (or at least go about starting to?)
  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 12, 2007
  • Posts: 13
  • Loc: Sydney
  • Status: Offline

Post June 19th, 2007, 2:24 am

Ok - here's another attempt.

I have my array.

As my attached movie plays, I want to assign it a variable to act as a currentMovie.

When a new movie is selected to play I want to fade out the currentMovie & fade the new movie in.

Please?

Code: [ Select ]
hostArray = new Array("host1","host2", "host3", "host4", "host5");

for (var i:Number = 0; i < 50; i++);


currentHost = hostArray[i];

import mx.transitions.Tween;
import mx.transitions.easing.*;

//Test Episode buttons - adapt to LC functions later
ep1.onRelease = function() {
currentHost = hostArray[i];
projector.loadMovie("flvPlayer.swf", 1);    
host.attachMovie("host1", "host1", 2);
var aF1:Tween = new Tween(host, "_alpha", Strong.easeOut, 0, 100, 5, true);
var aF2:Tween = new Tween(currentHost, "_alpha", Strong.easeOut, 100, 0, 5, true);
}

ep2.onRelease = function() {
currentHost = hostArray[i];
projector.loadMovie("flvPlayer.swf", 1);
host2.attachMovie("host1", "host1", 2);
var aF2:Tween = new Tween(host2, "_alpha", Strong.easeOut, 0, 100, 5, true);
var aF2:Tween = new Tween(currentHost, "_alpha", Strong.easeOut, 100, 0, 5, true);
}
  1. hostArray = new Array("host1","host2", "host3", "host4", "host5");
  2. for (var i:Number = 0; i < 50; i++);
  3. currentHost = hostArray[i];
  4. import mx.transitions.Tween;
  5. import mx.transitions.easing.*;
  6. //Test Episode buttons - adapt to LC functions later
  7. ep1.onRelease = function() {
  8. currentHost = hostArray[i];
  9. projector.loadMovie("flvPlayer.swf", 1);    
  10. host.attachMovie("host1", "host1", 2);
  11. var aF1:Tween = new Tween(host, "_alpha", Strong.easeOut, 0, 100, 5, true);
  12. var aF2:Tween = new Tween(currentHost, "_alpha", Strong.easeOut, 100, 0, 5, true);
  13. }
  14. ep2.onRelease = function() {
  15. currentHost = hostArray[i];
  16. projector.loadMovie("flvPlayer.swf", 1);
  17. host2.attachMovie("host1", "host1", 2);
  18. var aF2:Tween = new Tween(host2, "_alpha", Strong.easeOut, 0, 100, 5, true);
  19. var aF2:Tween = new Tween(currentHost, "_alpha", Strong.easeOut, 100, 0, 5, true);
  20. }
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13458
  • Loc: Florida
  • Status: Offline

Post June 19th, 2007, 2:50 am

Here's the source for the latest video player I've done.

You're welcome to take a look if you want, there's a few alternatives to opacity fades being used in it, I guess it could even be adapted to use _alpha, along with some XML/SharedObject/ExternalInterface stuff going on that's always good to know. :D
Strong with this one, the sudo is.
  • Head In A Pan
  • Newbie
  • Newbie
  • User avatar
  • Joined: Jun 12, 2007
  • Posts: 13
  • Loc: Sydney
  • Status: Offline

Post June 19th, 2007, 3:06 am

That's a very cool video player! ;)
Nice one.
Thanks for the source code - I'm having a look at it now...
Starting to realise maybe I should just go solely off the XML...
I was trying to cheat & do it without XML - just loading an array in my script.

Just one thing - how do I specify a variable to the current clip playing?

I reckon I can get it from there.
  • Rafe
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 28, 2007
  • Posts: 8
  • Status: Offline

Post June 29th, 2007, 8:30 am

Here is a similar question...

I have a movieclip that loads a random .jpg from a folder. This works fine but the image just pops in there when it's loaded (sometimes it may take a sec to load the image). How would I tell the image to fade in once it's completely loaded. I was thinking I would have to use a listener but not sure how to implement it.

Here is the code I am using:
Code: [ Select ]
imageLoader.loadMovie(randomURL("http://www.URL.com/image", 4));

function randRange(min:Number, max:Number):Number {
  var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
  return randomNum;
}

function randomURL( baseURL :String, maxImageNumber :Number ):String{
  return baseURL + randRange(1, maxImageNumber) + ".jpg";
}
  1. imageLoader.loadMovie(randomURL("http://www.URL.com/image", 4));
  2. function randRange(min:Number, max:Number):Number {
  3.   var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
  4.   return randomNum;
  5. }
  6. function randomURL( baseURL :String, maxImageNumber :Number ):String{
  7.   return baseURL + randRange(1, maxImageNumber) + ".jpg";
  8. }


Thanks.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post June 29th, 2007, 8:51 am

Initially set the alpha of the holder movie to 0, and when it's completely loaded do the fade in.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • Rafe
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Jun 28, 2007
  • Posts: 8
  • Status: Offline

Post June 29th, 2007, 9:40 am

But wouldn't that be based on the file size of the movie holder and not based on what is loading inside of it? I don't want the movie loader to fade in once its loaded, but the random image still pop in. I just want to make sure the random imaged loaded completely before it fades in.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 30 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.