flash AS question
- Started
- Last post
- 40 Responses
- CygnusZero4
I need to animate something without using tweens, but Im not a scripting pro.
I have a movieclip called "test". I need it to scale from 150% to 0% over 150 frames. I also need it to fade in over the first 30 frames, and fade out over the last 30.
Ive found the code in pieces on google but cant get it all working together. Like I can get it to fade in, but it wont scale. Or as it scales when it goes to fade out it stops scaling. Cant get all this to happen in 1 move.
- redant0
Have you tried using this? http://www.greensock.com/tweenli…
- Even if you don't use this, you should learn it as one of your main Flash tools.CyBrainX
- Mishga0
Are you sure you don't want to use tweens???
Will be pretty easy....
send me your fla...
- CygnusZero40
^ I have to animated 65 movieclips, and they made end up making changes, I CANNOT use tweens for this thing.
- Are you talking about timeline Tweens or Tweens Extensions like greensock or fuzekit?Mishga
- i was talking about dynamic fadein, scale...etc...Mishga
- Timeline, cant do those for this. Never used any extensions.CygnusZero4
- Yeah, thats what I need.CygnusZero4
- send me your fla...Mishga
- Ok I willCygnusZero4
- ifeltdave0
GTween
- fyoucher10
Greensock as redant mentioned above is probably best and something you should learn as it's kind of a standard nowadays (TweenMax, TweenLite, or TweenNano).
Or if you're using AS2, mctween2 is really easy to understand if you've never used a tweening engine before.
http://hosted.zeh.com.br/mctween…For mctween2, just download the AS file and put it next to your FLA. There are extensions you can download but just scroll down the Downloads page and download the AS file instead.
Then in your actions panel in a frame where your movieclip is type the following:
(Assuming your FLA is 30 FPS, it's AS2, and the movieclip is called myClip)#include "mctween_2_28_29.as"
//Start off at 150% scale
myClip._xscale = myClip._yscale = 150;//Scale to 0% over 5 seconds
myClip.scaleTo(0, 5, "linear");
//The easing equation can be many different things.
//Look up those string values ("easeOutQuart", "linear", etc) here >
//http://hosted.zeh.com.br/mctwe...//fade in 0 > 100% alpha
myClip._alpha = 0;
myClip.alphaTo(100, 1, "linear");//fade out at end
myClip.alphaTo(0, 1, "linear", 4);
// the last parameter 4 is the delay value. So it'll fade out after 4 seconds.
- Pixter0
addEventListener(Event.ENTER_FRA... decrease);
function decrease(e) {
anymovieclip.scaleX-=.01;
if (anymovieclip.scaleX<=0) {
removeEventListener(Event.ENTER... decrease);
}
}
- fyoucher10
You can even turn all of that into a function or prototype for reusing across movieclips
MovieClip.prototype.scaleAndfade = function():Void {
this._xscale = this._yscale = 150;
this.scaleTo(0, 5, "linear");
this._alpha = 0;
this.alphaTo(100, 1, "linear");
this.alphaTo(0, 1, "linear", 4);
}myClip1.scaleAndFade();
myClip2.scaleAndFade();
myClip3.scaleAndFade();
etc, etc, etc.
- CygnusZero40
I downloaded TweenLite. I cant even figure out how to install it. Theres no installer, no instructions. Just a bunch of AS files. Im new to all this stuff, I think they assume everyone knows what to do with this.
- redant0
They are scripts that you call up in AS, they just sit in a folder ("com" folder)
instructions
http://blog.greensock.com/get-st…- http://www.greensock…
that page helps u with the code. Import the scripts. Then use the code. Read the documentation.
redant
- http://www.greensock…
- Pixter0
addEventListener(Event.ENTER_FRA... decrease);test.scaleX=test.scaleY=1.5;
test.alpha=0;function decrease(e) {
//scale
test.scaleX=test.scaleY-=.01;//fade in and out
if (currentFrame<30) {
test.alpha = currentFrame/30;
}
if(currentFrame>totalFrames-30){
test.alpha = (totalFrames - currentFrame)/30;
}//clear memory
if (this.currentFrame==this.totalFr... {
removeEventListener(Event.ENTER... decrease);
}}
- fyoucher10
Just put those files next to your FLA and where you need to use that code, just import the classes
import com.greensock.*;
import com.greensock.easing.*;Then you need to read the documentation, thoroughly as well. It's something you just need to remember.
The difference between mctween and Greensocks Tweenlite is that you enter the properties to change as params inside of { } off of a TweenLite instance... where as mctween you just specify the movieclip and do one of the methods like myClip.alphaTo to fade something out, scaleTo to scale something proportionally, etc. Again, you have to read the documentation though. mctween is much easier to understand for a beginner though.
- CygnusZero40
^ Cool, I definitely will, just dont have time to learn all this right and now read documentation. Only have 1 day to get this thing done. Basically was hoping for some copy and paste code but I cant get anything to work right. Might have to do this manually. grrrrrr
- Take 30 mins to read the doc and you'll be better for it. Evolve.acrossthesea
- fyoucher10
If you're using AS2, follow the directions and Copy and paste the mc tween stuff I wrote above.
- CygnusZero40
Hilarious. Im 100% certain I have mc_tween_2_28_29.as sitting with my FLA. I put the code in the frame, damn thing tells me theres an error opening include file mc_tween_2_28_29.as. Awesome.
- class path????Mishga
- < I sent you the FLA, did you get it? Dont know what you mean by class path.CygnusZero4
- ooops...checking email now...!Mishga
- sent you an email...hope you find it useful. cheers!Mishga
- Awesome, Ill check it out in the morning. Thanks!CygnusZero4
- fyoucher10
You don't import the classpath, you include the as file, see my code above
- CygnusZero40
^ This isnt working. I foundout how to import in the preferences and added these 2 lines--
import com.greensock.*;
import com.greensock.easing.*;But its not working. I have no idea whats wrong with this.
- CygnusZero40
Wait you guys are giving me code for 2 different things here. Im using mctween, not tweenlite.
Im using this code--
#include "mctween_2_28_29.as"
//Start off at 150% scale
myClip._xscale = myClip._yscale = 150;//Scale to 0% over 5 seconds
myClip.scaleTo(0, 5, "linear");
//The easing equation can be many different things.
//Look up those string values ("easeOutQuart", "linear", etc) here >
//http://hosted.zeh.com.br/mctwe...//fade in 0 > 100% alpha
myClip._alpha = 0;
myClip.alphaTo(100, 1, "linear");//fade out at end
myClip.alphaTo(0, 1, "linear", 4);
// the last parameter 4 is the delay value. So it'll fade out after 4 seconds.And I have the AS file sitting with my FLA, but it still tells me that there is an error opening the include. There's something wrong still.
- orpkoobcam20
If adobe hadn't messed up with making AS far too hard for a designer/animator with no degree in computer science to grasp, then in AS1 you could have simply done this:
new mx.transitions.Tween(myclip_mc, "_alpha", mx.transitions.easing.Regular.ea... 0, 100, 30, false);
var scaleup = new mx.transitions.Tween(myclip_mc, "_xscale", mx.transitions.easing.Regular.ea... 0, 150, 150, false);
scaleup.onMotionChanged = function(){
if(scaleup.duration == 120){
new mx.transitions.Tween(myclip_mc, "_alpha", mx.transitions.easing.Regular.ea... 100, 0, 30, false);
}
}no includes and separate AS files or object orientated coding to learn, etc... just a few simple to understand lines of code.
Job done.Bring back the simplicity and simple to understand (from a designers point of view) code of AS1 to Flash. That's what I wish for. And they can bring back Freehand whilst they are at it.
- CygnusZero40
^ Just tried it. It's amazing how I cant get anything to work. My movieclip is just flashing on and off very fast. No scaling or anything.
Also getting a code error saying expected a field name after '.' operator
- ohok looks like your code didnt paste in correctlyCygnusZero4
- CygnusZero40
Hehe, still didnt work pasting the code from the link. Just doesnt do anything now, no errors though, lol. Man I suck at flash scripting. Cant even get copy/paste code to work. Jesus.