fade movieClip when going to another frame label?

I am trying to create the effect -  that when you press a button it will go to another frame label, but will fade the flame label it is currently at (which contains a movieClip).

Please help
ao_mAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh ChopraCommented:
here is a function which takes two parameters:

1: movieClip which needs to fade, if it is on _root, just pass _root as first parameter
2: "frame number" or "frame label" to which should be shown after fade effect

example code for to show frame number 5 or root:
// Just paste complete function code on root first frame and call it as following on any button click or anyother event..
//------------------
loadFrame(_root, 5);

function loadFrame(mc, frame) {
	var newVal = 0;
	var clrObj = new Color(mc);
	var myTransformObj = clrObj.getTransform();
	var transformObj = clrObj.getTransform();
	//
	var steps = 10;
	var count = 0;
	var phase = 1;
	//
	var rb = (255-transformObj.rb)/steps;
	var gb = (255-transformObj.gb)/steps;
 
	var bb = (255-transformObj.bb)/steps;
 
	//
	mc.onEnterFrame = function() {
 
		if (phase == 1 && count<steps) {
			transformObj.rb += rb;
			transformObj.gb += gb;
			transformObj.bb += bb;
			count++;
		} else if (phase == 1 && count>=steps) {
			this.gotoAndStop(frame);
			count = 0;
			phase = 2;
		} else if (phase == 2 && count<steps) {
			transformObj.rb -= rb;
			transformObj.gb -= gb;
			transformObj.bb -= bb;
			count++;
		} else {
			var transformObj = myTransformObj;
			delete this.onEnterFrame;
			//
		}
		clrObj.setTransform(transformObj);
		updateAfterEvent();
	};
}

Open in new window

0
Aneesh ChopraCommented:
here is a sample FLA for your reference, rename the extension to .FLA
LoadFrameWithFadeEffect.fla.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ao_mAuthor Commented:
I don't know if I am doing something wrong... but it didn't work :(

I took the function placed it in my actions layer, frame 1.
Replaced loadFrame(_root, 2), and then anywhere were there was an mc with _root, and frame with 2.
It gave me this error message:

1084: Syntax error: expecting identifier before 2.
0
Aneesh ChopraCommented:
I have given you working sample FLA, if you still unable to make it work,
I suggest to attach your problem FLA so that I can review and let you knw what is going wrong with your implementation
0
ao_mAuthor Commented:
I downloaded the fla, and it it exactly what I want (well I just want the fade out, as I have animated fade in when you go to next section). I tried implementing it, but I keep getting error messages like:

1180: Call to a possibly undefined method Color.
1180: Call to a possibly undefined method updateAfterEvent.
1119: Access of possibly undefined property onPress through a reference with static type flash.display:SimpleButton.
1120: Access of undefined property _level0.

I wish I could upload the fla, but it's too big. I have placed a code snippet to show you what I am doing.
I have 7 different label frames, and 7 buttons to navigate through them. The code below is in my actions layer (first layer), on _root.

ps- forgive the actionscript in there - i am just starting to learn how to be more efficient.


stop();
 
//fade function
/*link1T_btn.onPress = function() {
	loadFrame(_level0,_level0.songwritters);
};
 
function loadFrame(mc, frame) {
	var newVal = 0;
	var clrObj = new Color(mc);
	var myTransformObj = clrObj.getTransform();
	var transformObj = clrObj.getTransform();
	//
	var steps = 10;
	var count = 0;
	var phase = 1;
	//
	var rb = (255-transformObj.rb)/steps;
	var gb = (255-transformObj.gb)/steps;
 
	var bb = (255-transformObj.bb)/steps;
 
	//
	mc.onEnterFrame = function() {
 
		if (phase == 1 && count<steps) {
			transformObj.rb += rb;
			transformObj.gb += gb;
			transformObj.bb += bb;
			count++;
		} else if (phase == 1 && count>=steps) {
			this.gotoAndStop(frame);
			count = 0;
			phase = 2;
		} else if (phase == 2 && count<steps) {
			transformObj.rb -= rb;
			transformObj.gb -= gb;
			transformObj.bb -= bb;
			count++;
		} else {
			var transformObj = myTransformObj;
			delete this.onEnterFrame;
			//
		}
		clrObj.setTransform(transformObj);
		updateAfterEvent();
	};
}
*/
// this will take you to the categories 
 
function onDrop1Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("songwritters");    
}
link1T_btn.addEventListener(MouseEvent.CLICK, onDrop1Click)
 
function onDrop2Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("emerging");
}
link2T_btn.addEventListener(MouseEvent.CLICK, onDrop2Click);
 
function onDrop3Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("education");
}
link3T_btn.addEventListener(MouseEvent.CLICK, onDrop3Click);
 
function onDrop4Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("aboriginal");
}
link4T_btn.addEventListener(MouseEvent.CLICK, onDrop4Click);
 
function onDrop5Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("industry");
}
link5T_btn.addEventListener(MouseEvent.CLICK, onDrop5Click);
 
function onDrop6Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("responsibility");
}
link6T_btn.addEventListener(MouseEvent.CLICK, onDrop6Click);
 
function onDrop7Click(evt:MouseEvent):void {
	SoundMixer.stopAll();
	gotoAndStop("links");
}
link7T_btn.addEventListener(MouseEvent.CLICK, onDrop7Click);

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.