Jump to content
Search Community

3d card flip using tweenlite

pushfate test
Moderator Tag

Recommended Posts

Hi Im kinda new to AS3, I normally code in AS2 and Im using flash cs3.

 

I have created a zooming playing card animation and so basically inside the zooming movie clip I have placed the front_mc and the back_mc of the card and the back_mc has an animation on it when it flips over all that works except, I want the card to auto flip at the end of the animation on the main timeline without having to click on the card itself, I dont really mind if the is no flip back option, I just want the card to flip over at frame 20 on the maintime.

 

I downloaded the greensock component, I used this because you cant distort mc's and bitmaps and this is the code Im currently using which I got from this site:

 

import com.greensock.TweenLite;

front_mc.addEventListener(MouseEvent.CLICK,cardCli ck);

function cardClick(event:MouseEvent):void {

back_mc.visible = true;

TweenLite.to(front_mc,0.5,{scaleX:-1, overwrite:false});

TweenLite.to(front_mc,0,{alpha:0,delay:.15, overwrite:false});

TweenLite.to(back_mc,0.5,{scaleX:-1, overwrite:false, onComplete:hidden});

TweenLite.to(back_mc,0,{alpha:1,delay:.15, overwrite:false});

back_mc.addEventListener(MouseEvent.CLICK, backClick);

}

function hidden() {

front_mc.visible = false;

}

function backClick(event:MouseEvent):void {

front_mc.visible = true;

TweenLite.to(back_mc,0.5,{scaleX:+1, overwrite:false});

TweenLite.to(back_mc,0,{alpha:0,delay:.15, overwrite:false});

TweenLite.to(front_mc,0.5,{scaleX:+1, overwrite:false, onComplete:ReHidden});

TweenLite.to(front_mc,0,{alpha:1,delay:.15, overwrite:false});

}

function ReHidden() {

back_mc.visible = false;

}

 

Does anyone know how to make the front_mc flip over to the back_mc without a mouse click on frame 20 of the main timeline.

 

PLEASE HELP.

Link to comment
Share on other sites

if you want no clicking just remove the eventListeners on the cards and the event:MouseEvent from the function parameters.

 

import com.greensock.TweenLite;

function cardClick():void {
back_mc.visible = true;
TweenLite.to(front_mc,0.5,{scaleX:-1, overwrite:false});
TweenLite.to(front_mc,0,{alpha:0,delay:.15, overwrite:false});
TweenLite.to(back_mc,0.5,{scaleX:-1, overwrite:false, onComplete:hidden});
TweenLite.to(back_mc,0,{alpha:1,delay:.15, overwrite:false});



}
function hidden() {
front_mc.visible = false;
}
function backClick():void {
front_mc.visible = true;
TweenLite.to(back_mc,0.5,{scaleX:+1, overwrite:false});
TweenLite.to(back_mc,0,{alpha:0,delay:.15, overwrite:false});
TweenLite.to(front_mc,0.5,{scaleX:+1, overwrite:false, onComplete:ReHidden});
TweenLite.to(front_mc,0,{alpha:1,delay:.15, overwrite:false});
}
function ReHidden() {
back_mc.visible = false;
}

 

in frame 20 of your timeline place an action:

cardClick();

Link to comment
Share on other sites

that's strange, functions defined in frame 1 should be accessible everywhere.

 

place all your code and assets on frame 1 and try again.

 

 

OR place all your code and assets on frame 20. this really shouldn't make a difference.

 

make sure function cardClick(){ ... on frame 1 doesn't have any typos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...