|
-
[RESOLVED] Problems Using Classes
I have come across a cool class I would like to use but have run into some problems using it. Could some please help me.
The example of the class in action is here:
http://pixelfumes.blogspot.com/2006/...lass-with.html
I created my .as file and name it flip.as and place it in the same folder as my movie.
this is the content of my flip.as file:
Code:
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
class CardFlip{
private var cardWrapper:MovieClip;
private var cardFront:MovieClip;
private var cardBack:MovieClip;
private var cardBackLinkageID:String;
private var cardSide:Number = 1;
private var flipComplete:Boolean = false;
private var xAxis:Number;
private var dropShadow:DropShadowFilter = null;
function CardFlip(cardW:MovieClip,back:String,xa:Number,ds:DropShadowFilter){
cardWrapper = cardW;
cardBackLinkageID = back;
//init card
cardWrapper.createEmptyMovieClip("back",cardWrapper.getNextHighestDepth());
cardBack = cardWrapper.back;
cardBack._visible = false;
cardBack.attachMovie(cardBackLinkageID,"mc",1);
xAxis = xa;
if(ds){
dropShadow = ds;
cardWrapper.filters = [ds];
}
}
public function flip(t,b,r1,r2){
flipComplete = false;
var time:Number = t;
var blurAmt:Number = b;
switch(cardSide){
case 1:
cardSide = 2;
var cfrTween = new Tween(cardWrapper, "_rotation", Strong.easeIn, cardWrapper._rotation, r2, time, true);
break;
case 2:
cardSide = 1;
var cfrTween = new Tween(cardWrapper, "_rotation", Strong.easeIn, cardWrapper._rotation, r1, time, true);
break;
}
var myBlur:BlurFilter = new BlurFilter(0, 0, 3);
cardWrapper.filters = [myBlur,dropShadow];
var blurTween = new Tween(myBlur, "blurX", Strong.easeIn, blurAmt, blurAmt, time, true);
blurTween.cRef = this;
blurTween.onMotionChanged = function() {
this.cRef.cardWrapper.filters = [myBlur,this.cRef.dropShadow];
}
var cfTween = new Tween(cardWrapper, "_xscale", Strong.easeIn, 100, 0, time, true);
var cfxTween = new Tween(cardWrapper, "_x", Strong.easeIn, xAxis, xAxis + cardWrapper._width/2, time, true);
cfTween.cRef = this;
cfTween.onMotionFinished = function(){
if(this.cRef.cardSide == 1){
this.cRef.cardBack._alpha = 0;
this.cRef.cardBack._visible = false;
}else{
this.cRef.cardBack._visible = true;
this.cRef.cardBack._alpha = 100;
}
if(flipComplete != true){
cfTween.yoyo();
cfxTween.yoyo();
flipComplete = true;
}else{
this.cRef.cardWrapper.filters = [new BlurFilter(0, 0, 3),this.cRef.dropShadow];
}
}
}
}
on the first frame of my movie I have:
And on my button I have:
Code:
on (release) {
cf = new CardFlip(card_mc, "cardBack_mc", 50, ds);
}
The mc onstage is named:
card_mc and the one in the library has the identifier:
cardBack_mc:
When I press my button nothing happens, what am I doing wrong?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|