Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

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
0
ao_m
Asked:
ao_m
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now