1 Replies - 6628 Views - Last Post: 20 October 2009 - 01:06 PM

#1 chrisdegrote  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 18-November 08

How to clear the stage when entering a new frame

Post icon  Posted 09 October 2009 - 02:56 PM

Dear all,

I am making my first website in flash based on frames. When you go to an other frame the Stage fades out. When you enter the frame you see nothing at all. So how can I clear the stage when entering the frame or even better it fades into the frame with clearing the objects & code of the previous frame.

Hope somebody can help me with this!
 /*buttons naar frames*/

homehome.mouseChildren = false;
homehome.buttonMode = true;
homehome.addEventListener(MouseEvent.CLICK, actie5);
homehome.addEventListener(MouseEvent.ROLL_OVER, actie5);
homehome.addEventListener(MouseEvent.ROLL_OUT, actie5);
var fadetimer:Timer;
var st:MovieClip = new MovieClip();


function actie5(event:MouseEvent):void {
 
  //klikken
if(event.type == "click"){
st.graphics.beginFill(0xFFFFFF); //Choose your color to fade.
		st.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
		st.graphics.endFill();
		st.alpha = 0;
		stage.addChild(st);
		fadetimer = new Timer(100);
		fadetimer.addEventListener(TimerEvent.TIMER, fadeStage);
		fadetimer.start();

 }
 
  //roll over
  if(event.type == "rollOver"){
	infohome.text = "je staat op de knop";
  }
 
  //roll off
  if(event.type == "rollOut"){
	infohome.text = "";
  }

}
function fadeStage(te:TimerEvent):void {
	if (st.alpha < 1) {
		st.alpha += 0.05;
	} else {
		fadetimer.stop();
		fadetimer.removeEventListener(TimerEvent.TIMER, fadeStage);
		gotoAndStop(7);
	}
}



Thanks a lot for your time

Is This A Good Question/Topic? 0
  • +

Replies To: How to clear the stage when entering a new frame

#2 DigitalMonk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 16-June 09

Re: How to clear the stage when entering a new frame

Posted 20 October 2009 - 01:06 PM

Hey Chris,

I don't have an answer for your existing code, but I can offer a way to get where you want to be.

Let's say you have three different frames (different pages) in one movieclip, and you want to fade to black and fade into your next page based on a button click...

Create a seperate movieclip that covers the entire stage and label it something like "transition". Put this movie clip just below your actions layer or atleast above your content movieclip. Fill your movieclip "mc_trans" with black using your paint bucket. Turn your mc_trans background into a movieclip so you can adjust the alpha.

On your mc_trans timeline add keyframes at frame 1, 16 and 31. Change the alpha on frame 1 & 31 to zero and create a tween between 1 & 16 and 16 & 31. On frame 16 in your actions frame make a gotoAndPlay("jumpFrame") statement to change your content page that is now hidden behind your black curtain.

on your main timeline actions frame, create a variable called jumpFrame, and
Label your content pages with frame labels. On your nav button code, instead of sending your movieclip to another frame number, set jumpFrame equal the framelabel you want to go to. like... MOUSE_DOWN, HomeBtn);
function HomeBtn (...
jumpFrame = "home";
mc_trans.play;

When you click your Nav buttons, instead of immediately going to your next page, you tell mc_trans to play. Your mc_trans movieclip will play from frame 1 (alpha 0%) to 16 (alpha 100%) and continue to frame 31 (alpha 0%). On the actions frame of frame 31 of mc_trans you'll add at gotoAndStop(1); //sending your playhead back to frame one for the next transition call.

The last thing is to add code to you actions layer on frame 16 in your transition movieclip to send your content page to your jumpFrame. So when you hit frame 16, your code will send you content movieclip to jumpFrame which is set by the nav button you clicked on. something like mc_content.gotoAndStop(jumpFrame);

In other words... Label your frames, use a movieclip like a curtain to hide your content pages and change the content page when the curtain alpha is at 100%. Your new page will be revealled when the transition movieclip finishes playing to the last frame where the alpha is 0%.

Hope that's not too confusing. Using a black curtain is pretty straight forward, but creating a transistion page out of a movieclip allows you to do some cool transitions while you change your content in the background.

Best of luck
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1