-
Tween vs. actionscript
Hi there
I am creating a flash file that has many long tweens... With each additional tween I had (because of the image I'm tweening) the swf gets bigger and bigger... I was wondering if there is some actionscript that I could use instead of tweening to make the same effect but to minimize the file size.
All I'm doing is scrolling a series of images from up to down, side to side. The images fade in... scroll and fade out...
Thanks gang!
Losse
-
You can use the Action Script tween class
example:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Move MovieClip Down the y axes
var myTween:Tween = new Tween(who, "_y", mx.transitions.easing.Regular.easeIn, 5, 100, 3, true);
// FadeIn
var myTween2:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 0, 100, 3, true);
// FadeOut
var myTween3:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100, 0, 3, true);
hope this helps
-
Thanks man! That works... how do I make it so that "who" stays at opacity 100 for like 3 seconds and then fade out...
-
Also I just tried it and it seems like it's just doing the mytween3... I only see it fade from 100% to 0%...
-
those where example's but here is some code that will fadeOut then back in
Code:
function FadeOutIn (who){
var myTween2:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
myTween2.onMotionFinished = function(){
var myTween3:Tween = new Tween(who, "_alpha",mx.transitions.easing.Regular.easeIn, 0, 100, 3, true);
}
}
-
whoa... pardon my ignorance... I'm a bit new to actionscript... So how does it all tie in together?
-
Senior Member
what will happen is when that method is called, it'll start that first tween. Then onMotionFinished() it will set off the second method to fade it in.
As for the 3 second timer deal, you got two options, set an Interval for x amount of time, or create empty keyframes, and on x keyframe call that first function to initiate the tweens. (first option is recommended for best performance and orginization)
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
well... here's the interesting thing... I have about 6 images that will tween like I've been explaining... every additional tween starts 1.5 seconds before the previous one ends... So that they blend into eachother (assuming the fade out is 3 seconds and the fade in is 3 seconds also).
-
Hi all. let's say I have an animation using the motion tween. On the last frame of the animation I can write a code like movie_mc.gotoAndPlay("about") or something. How can i make an animation using the mx transitions to do the same thing? A code that would be like " when the animation is finished movie_mc.gotoAndPlay("about")). I'm asking because by using mx transitions you only have one frame. Any help? Thank you
ps: i've seen the onMotionFinished there but i don't really know how to use it. Tried it and no luck. I use (like the unprofessional that I am) empty frames in an empty movieclip, and i calculate the duration of the animation and depending on how many fps my flash file has, i crate the empty frames. Thats embarasing i know.
Last edited by cristi_b_1; 03-19-2007 at 10:43 PM.
-
Senior Member
well... here's the interesting thing... I have about 6 images that will tween like I've been explaining... every additional tween starts 1.5 seconds before the previous one ends... So that they blend into eachother (assuming the fade out is 3 seconds and the fade in is 3 seconds also).
Are you perfoming a fadeIn, fadeOut tween one time on each MC? if so, then try this.
Code:
//Put in your actions layer
var counter:Number = 0;
import mx.transitions.Tween;
import mx.transitions.easing.*;
function CreateTimer():Void
{
setInterval(StartFading, 1500);
}
function StartFading():Void
{
counter++;
switch (counter)
{
case 1:
var myTween1:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 2:
var myTween2:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 3:
var myTween3:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 4:
var myTween4:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 5:
var myTween5:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 6:
var myTween6:Tween = new Tween(who, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case default:
break;
}
}
Hi all. let's say I have an animation using the motion tween. On the last frame of the animation I can write a code like movie_mc.gotoAndPlay("about") or something. How can i make an animation using the mx transitions to do the same thing? A code that would be like " when the animation is finished movie_mc.gotoAndPlay("about")). I'm asking because by using mx transitions you only have one frame. Any help? Thank you
Code:
myTween.onMotionFinished() = function():Void
{
myMC.gotoAndStop("frame");
}
Last edited by RangrJay; 03-19-2007 at 11:07 PM.
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
-
Hi there... thanks again... I got this error
Code:
**Error** Scene=Scene 1, layer=image, frame=1:Line 39: Unexpected 'default' encountered
case default:
**Error** Scene=Scene 1, layer=image, frame=1:Line 42: Unexpected '}' encountered
}
Total ActionScript Errors: 2 Reported Errors: 2
-
Does anyone know why I got these errors?
-
Before mere mortals can render an opinion on the cause of an effect, some information about precipitating events is required (error messages are not always indicative). When you post a file, the probability (and quality) of answers is immediately higher.
-
Originally Posted by losse
Hi there... thanks again... I got this error
Code:
**Error** Scene=Scene 1, layer=image, frame=1:Line 39: Unexpected 'default' encountered
case default:
**Error** Scene=Scene 1, layer=image, frame=1:Line 42: Unexpected '}' encountered
}
Total ActionScript Errors: 2 Reported Errors: 2
1) you have this
case default:
should be
default:
2) you can remark out the "}" on line 42.
-
Thanks Gang... Here is the entire code... Now I don't get errors but when I open it I don't see anything happening!
Code:
#include "lmc_tween.as"
//Put in your actions layer
var counter:Number = 0;
import mx.transitions.Tween;
import mx.transitions.easing.*;
function CreateTimer():Void
{
setInterval(StartFading, 1500);
}
function StartFading():Void
{
counter++;
switch (counter)
{
case 1:
var myTween1:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 2:
var myTween2:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 3:
var myTween3:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 4:
var myTween4:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 5:
var myTween5:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
case 6:
var myTween6:Tween = new Tween(mv_house1, "_alpha", mx.transitions.easing.Regular.easeIn, 100,0, 3, true);
break;
default:
break;
}
}
-
If you do not get a response soon, please post a copy of the lmc_tween.as. Obviously, your code to tween the alpha is not working. The reason is probably obvious to some, but not to me. If I see the code that the displayed code cooperates with, it might help.
Otherwise, you might want to check path assumtions with a trace or two.
-
Thomas, would you like to send me an email and we can try to resolve this via email?
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
|