[FMX]Load movie in container with fade in fade out?

Hi,

I have a menu (mc_menu) with 6 button mc’s (btn_home, btn_about, …btn_contact) I also have 6 containerson the stage (content_home, content_about, …content_contact)

Right now I’m loading different external swf’s(home, about,…contact) with the following AS code:

function pagina(page) {
showContent(page);
}
function showContent(page) {
var c = this["content_"+page];
for (var i in this) {
if (this*._name.substr(0, 8) == "content_") {
this*._visible = (this*._name.substr(8) == page);
c.loadMovie(page+".swf");
}
loadingPage = page;
}
}

and on the buttons I call that functions:

function setButton() {
for (var i in menuMc) {
if (menuMc*._name.substr(0, 4) == "btn_") {
clip = menuMc*;
//RollOver and RollOut stuf goes here
clip.onRelease = function() {
	[color=red]pagina(this._name.substr(4));[/color]
};
}
}
}

But I want the external swf’s to load in just one container with fade in and fade out. How can I reach this?

Thanks in advance

It already would be helpful if I only have the fuction for the loadMovie wich goes with my button function.

Is this so dificult that knowbody knows how to do it ?? Are there maybe some sugestions where I can look for the answers?

Look out in the flash samples installed on your hdd :)… you should have there a LoadMovie feature explained with all the as for fade in fade out.
Help > Samples :wink:

I know that sample but I need something that goes along with my button function. In my case all external swf’s have different names!
But thanks anyway

Have a look at the Photogallery tut, you can use that with a simple modification and then use this in your code (instead of the loadMovie)

c.changePhoto(page+".swf");

scotty(-:

Thanks scotty,

Which Photogallery tut do you mean?

http://www.kirupa.com/developer/mx/photogallery.htm
Change the code igave you before like this:

_root.changePhoto(page+".swf");

and the gallery code like this:

this.fadeSpeed = 20;
MovieClip.prototype.changePhoto = function(pic) {
	this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
	if (this.c._alpha>this.fadeSpeed) {
		this.c._alpha -= this.fadeSpeed;
	} else {
		this.loadPhoto();
	}
};
MovieClip.prototype.loadPhoto = function() {
	this.c._alpha = 0;
	this.c.loadMovie(pic);
	this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
	var l, t;
	l = this.c.getBytesLoaded();
	t = this.c.getBytesTotal();
	if (t>0 && t == l) {
		this.onEnterFrame = fadeIn;
	} else {
		trace(l/t);
	}
};
MovieClip.prototype.fadeIn = function() {
	if (this.c._alpha<100-this.fadeSpeed) {
		this.c._alpha += this.fadeSpeed;
	} else {
		this.c._alpha = 100;
		this.onEnterFrame = null;
	}
};

I hope (didn’t test it) that it’ll work:)

scotty(-:

Thanks scotty I will give it a try :slight_smile:

welcome, let me know if it worked;)

scotty(-:

Hi scotty,

I can’t get it to work as yet. One question to make sure I understand what I should do. Do I still need the function [color=red]showContent,[/color] because that part is with the seperate content_mc’s, and I would like to work with just one container. I’m a bid confused? because in the tut the container color=red[/color] is declared in the [color=red]prototype loadPhoto[/color] (var p = _root.photo;) so I don’t know how to continiue?

You need the showContent, in that function you call the changePhoto:

_root.changePhoto(page+".swf");

In the tut they’ve used “photo”, if you look at the code in post#8, you’ll see I’ve changed that in your mc “c”.
So if you add that code, it should work… (like I’ve said before, I didn’t test it;) )

scotty(-:

Thanks :slight_smile: But what should come instead of:

for (var i in this) {
if (this*._name.substr(0, 8) == "content_") {
this*._visible = (this*._name.substr(8) == page);

Where is the container coming in place?

Your code should look like

function pagina(page) {
	showContent(page);
}
function showContent(page) {
	var c = this["content_"+page];
	for (var i in this) {
		if (this*._name.substr(0, 8) == "content_") {
			this*._visible = (this*._name.substr(8) == page);
			_root.changePhoto(page+".swf");
		}
		loadingPage = page;
	}
}

If you use this with my gallery code, there is a chance it’ll work, LOL.
the container has an instancename “c”.
If you cant get it working, post a .fla?

scotty(-:

Hi scotty,

Thanks for the patience
Sorry but I don’t understand the part with content_.I tried it with just one container (content) and I tried it with a content_ container for every seperate swf but it doesn’t work. HeI have send the zip by email becauseI couln’t get it smal enough to attach it here

Thanks in advance

Hey dboers,

Check your mail=)

scotty(-:

Hi scotty,

I checked my mail and also the fla. At first I couln’t open it MX 2004, But after I installed that I could open it and it works great.

1000 times thanks :slight_smile:

no problem:)

you can add an additional parameter to your function like this:


MovieClip.prototype.changePhoto = function(my_pic,my_where) {
	this.picToLoad = my_pic;
	this.whereToLoad = my_where;
	this.onEnterFrame = fadeOut;
};

and then modify the load movie part like so:


MovieClip.prototype.loadPhoto2 = function() {
	// specify the movieclip to load images into
	var p = this.whereToLoad;
	//------------------------------------------
	p._alpha = 0;
	p.loadMovie(this.picToLoad);
	this.onEnterFrame = loadMeter;
};

that should do it. now you call the function with two parameters, the item you want to load, and which container you want to load it into. you call the function like this:


_root.changePhoto(yourPicture.jpg,yourContainerMovie);

Hi treatkor,

Thanks a lot for this additional information, very helpfull :slight_smile: