Log in

View Full Version : page transition slide in and out



kony
07-20-2008, 08:14 PM
Hello there,

I am very beginer for actionscript.

I would like to make the site below.

http://www.gotmilk.com/#/gotmilkbrand/

I do not know specific name of what I want to do.

First, In the site 1st page( mc?) is slided in,
and then, when one (it is supposed to go to 2nd page) of the buttons in the navigation bar is clicked, 1st page will be slide out, then 2nd page will be slided in.

Anyone knows how to do this.

Please help and give me tip and idea.

Thank you.

Medyman
07-21-2008, 01:35 AM
AS 2.0 or 3.0?

kony
07-21-2008, 03:41 AM
I am starting as 3.0

I am leaning basic things.

Medyman
07-21-2008, 11:40 PM
In general, I agree with what Erik Hallander told you over on the GTAL forums -- start with the basic and work your way up.

But, I consider this a basic concept. It's referred to as masking. I'm not sure how familiar you are with Photoshop or Flash, but masking is basically manually defining the portion of a particular plane to show. So, on the page that you linked, what's happening is that the page moves down and then another comes up in it's place.

This can be done by creating a separate movieclip for each "page" and animating them in/out as necessary. Or you can have page and swap out content. The latter is definitely the more efficient of the two.

Before you go further though, you should learn the basics of masking, then move on to tweening (animating). In AS 3, I generally use the Tweener classes (http://code.google.com/p/tweener/) for animation. I've started using TweenMax (http://blog.greensock.com/tweenmaxas3/) and TweenLite (http://blog.greensock.com/tweenliteas3/) because they're less resource intensive. But, for what you'll be doing, the performance of all of them will be the same.

So, take a look at this (http://www.visualbinary.net/files/tutorials/masking/as3/) example. When you open the .fla, you'll notice a pink layer. That's the visible area of the .swf. No matter how large/small you make the .swf when you embed it, only that area will be visible. So, if you want to create that sinking down and coming back up effect, you simple animate the object to drop below the visible area, and then reappear. Note that the "ripple" effect from the Got Milk? website is probably a video important in from After Effects of the like.

I hope that helped. Let me know if you have any questions.

kony
07-22-2008, 02:45 AM
Thank you for response.

basically I understood how teen worked.(I looked at the lee's video again and again)
It was very helpful, but I did not expect masking for the site.

The link you gave did not have fla anymore, but I try to figure this out by myself.
what you commented is very helpful, and I really appreciate you caz you gave me key to start.

Medyman
07-22-2008, 11:56 AM
The link you gave did not have fla anymore, but I try to figure this out by myself.

Oops. Sorry about that. I'll fix that soon.

kony
07-22-2008, 04:34 PM
hello

if possible , i would like to see fla.

anyway, again thank you.

Medyman
07-22-2008, 05:16 PM
hello

if possible , i would like to see fla.

anyway, again thank you.

Yeah, like I said, I'll fix it soon. The .fla is on my home computer and I'm at my office. I'll upload it when I get home.

kony
07-24-2008, 02:01 AM
hello
I wrote the code below:


import caurina.transitions.*;
import caurina.transitions.properties.*;


home_mc.addEventListener(MouseEvent.CLICK, onBtn1Clk);
addChild(btn1_mc);


btn1_mc.buttonMode = true;

//function onBtn1Clk(evnet:MouseEvent):void {

function onBtn1Clk(event:MouseEvent):void {
Tweener.addTween(ref_mc, { y:500, time:2, transition:"easeinoutQubic"});
Tweener.addTween(ref2_mc, {y:100, time:2, transition:"easeinoutQubic"});
}


//trace("btn1_mc was clicked.");

//}




philosophy_mc.addEventListener(MouseEvent.CLICK, onBtn2Clk);
addChild(btn2_mc);

btn2_mc.buttonMode = true;


function onBtn2Clk(event:MouseEvent):void {
Tweener.addTween(ref_mc, { y:100, time:2, transition:"easeinoutQubic"});
Tweener.addTween(ref2_mc, { y:500, time:2, transition:"easeoutSine"});

}





What i did is that there are 2 buttons, and when you click on btn1_mc, ref_mc is going to come up from the bottom, and then when you click on btn2_mc, ref_mc is going down , and ref2_mc is coming up.

But, i do not think it is what I want to do. What I want to do is "when you click on btn2_mc, ref_mc is going down after ref_mc is donw completerly, then ref2_mc is coming up.

so I just wonder how this transition works?

Use timerEvent? or something else?

Medyman
07-24-2008, 12:26 PM
You can do that in one of two ways:

1) Add a delay
There is a delay parameter. So, if you know that ref_mc will take 2 seconds to move all the way down, you can do this:


Tweener.addTween(ref_mc, { y:500, time:2, transition:"easeinoutQubic"});
Tweener.addTween(ref2_mc, {y:100, time:2, delay:2, transition:"easeinoutQubic"});

Now, ref2_mc's tween starts 2 seconds after ref_mc.

2) onComplete
Tweener also has a callback function. It'll fire as soon as the initial tween is complete. So, your code might look something like:


Tweener.addTween(ref_mc, { y:500, time:2, transition:"easeinoutQubic", onComplete: function():void { Tweener.addTween(ref2_mc, {y:100, time:2, transition:"easeinoutQubic"});}});

Or, cleaning it up to use a function call instead of the anonymous function

Tweener.addTween(ref_mc, { y:500, time:2, transition:"easeinoutQubic", onComplete: TweenRef2 });
function TweenRef2() {
Tweener.addTween(ref2_mc, {y:100, time:2, transition:"easeinoutQubic"});
}

hyk
07-24-2008, 03:33 PM
In general, I agree with what Erik Hallander told you over on the GTAL forums -- start with the basic and work your way up.


Medyman:What does GTAL means???
why is there a need for a preloader in some of the Flash videos? I suddenly thought of it when i went to the link kony gave.:)

kony: If you do not mind, would you mind pasting your code using the code button instead of the quotes.

Medyman
07-24-2008, 04:01 PM
Medyman:What does GTAL means???
why is there a need for a preloader in some of the Flash videos? I suddenly thought of it when i went to the link kony gave.:).

GTAL = gotoAndLearn() (http://gotoandlearn.com/) - A great flash learning resource.

The reason for preloading content is to allow for continuous, streaming playback. On slower connections, it might stream at a speed slower than playback, so you get a lot of buffering. In some instances, that doesn't matter. In others, it disrupts the functionality of the site.

kony
07-25-2008, 05:50 PM
Hello,


kony: If you do not mind, would you mind pasting your code using the code button instead of the quotes.
sorry hyk, i will use it.

I am stuck to make transition btw multiple MCs(4 mcs:ref_mc, ref2_mc, ref3_mc, ref4_mc).

my code is:

btn1_mc.addEventListener(MouseEvent.CLICK, onBtn1Clk);
addChild(btn1_mc);


btn1_mc.buttonMode = true;

var setBtn= function onBtn1Clk(evnet:MouseEvent):void {

Tweener.addTween(ref_mc, { y:500, time:1, transition:"easeinoutQubic", onComplete:setBtn,onCompleteParams:["ref2_mc","ref3_mc","ref4_mc"] });




I think wrong code is:

var setBtn= function onBtn1Clk(evnet:MouseEvent):void {

and One more question,
is that possible that a couple of different MCs coming up when one button is going to be presssed?



Please some tips , anyone, thank you.

Medyman
07-29-2008, 02:02 PM
var setBtn= function onBtn1Clk(evnet:MouseEvent):void {

That is certainly incorrect. You can't set a function equal to a variable. It should just be:


function onBtn1Clk(evnet:MouseEvent):void {

But, I'm not sure that will help you in tweening between multiple MCs. You have two options here: track through variables or arrays.

If arrays are too advanced for you at this point, take a look at this (http://gotoandlearn.com/player.php?id=22). It's Lee's tutorial on XML in AS 2.0. Most of it won't apply here, but pay attention to the "WhoIsOn" logic. You can use the same logic with this.