Movieclip: tween() - Tween movieclip properties in a clean and easy way, using Robert Penner's easing equations
msg1 {
zeh[+],
posted: 04.15.03 6p•05.05.03 10a,
top [^]
}
Here's an example of the tween method in action. Just click the buttons or press 0-6 to see the animation. It uses the tween method to pass from each room to another, tweening the position and rotation properties of the "map" object. In this case, since the map object is a kind of a 3d engine, it's used on map variables instead of normal properties (like _y, _x, etc), but the concept is the same.
I'll post new examples (including graphics showing how each animation type is ran) later.
msg2 {
zeh[+],
posted: 04.29.03 8a•04.29.03 9a,
top [^]
}
These methods have been updated to work with Robert Penner's easing equations version 1.4. He added two great animation types - elastic easing and back easing - which also adds some more parameters. Thanks for Martin Klasson for telling me of the update, BTW.
The XML syntax help file (mentioned two posts above) has also been updated with the new syntax. It's getting more complex with the new variables and such, but everything is still optional and elastic + back easing works great with the default values.
msg3 {
zeh[+],
posted: 05.02.03 6a•05.02.03 6a,
top [^]
}
These methods have been updated to work with Robert Penner's easing equations version 1.5 (again). He added one animation type - bounce easing (the guy's a monster). This one is simple to use but actually needed some modification on the code since it's recursive and I'm using a completely different syntax. It's all tested and working though.
msg4 {
hopbot[+],
posted: 05.07.03 8p•-,
top [^]
}
this is great. hey, i have several of these types of tween-prototypes and yours looks very good! i want to use it but one thing i end up adding is some generic callbacks like onTweenDone and onTweenStep. onTweenDone gets called by the movie clip that was tweening when the tween is done and onTweenStep happens everytime the movieclip that is being tweened is updated on the stage.
what i often do is just set the tween of one clip and then have it update the positions of others in its onTweenStep callback... does that make sense? it seems to be more efficient when you have a lot of clips that need to be animating
msg5 {
zeh[+],
posted: 05.08.03 5a•05.29.03 6p,
top [^]
}
Hrm, good idea. In fact, there's the callback parameter which acts like a onTweenDone event; but there's nothing that acts like onTweenStep (could be emulated by setting the mc's own onEnterFrame).
But since this tween method is meant to be easy to use and several "layers" of tween commands are allowed at the same time and with different durations, having events called when an update has occured or finished is a bit tricky - not because it's difficult to do, but because it depends a lot on what people think is a finished or update event. For instance, should the update event be called each time a property is updated, meaning two calls per frame on a slideTo method? Should it be called only once per frame, no matter the number of properties updated? Or should it be called once for each property with a different event name? And the finished event? If you called slideTo, should it have one event for _x and one for _y, or only one event? But if you started a slideTo event and in the middle of it started a new _x tween (overwriting the old _x one created by slideTo), what would happen to the finishing event? Would it be deleted or carried to _y only? I think there's so much to consider that's to risky to implement a definitive solution on this aspect.
For now, I think callback functions to the job, although I believe the implementation is not perfect (it basically has the same problems I mentioned above when using a "finished" event). But you gave a suggestion I hadn't though a lot about, I will definitely consider something like this. Thanks.
Edit: Also, I think my callback implementation is a bit bad (functions need weird references when the tween is not done from _parent). Any suggestion or idea on a better way to implement that would be greatly appreciated.
msg6 {
sweepah[+],
posted: 05.26.03 6a•-,
top [^]
}
amazing work man, this is helping me out a lot thnx
msg7 {
1stpixel[+],
posted: 07.08.03 4a•-,
top [^]
}
Nice done!
as you requested, here's my solution for the callback:
replace
with (this._parent) {
this._callback ();
} with
scope[callback].apply(null, [args]);
now you should call a tween as followed:
// example code, place on root
#include zTween.as
Obj = {};
Obj.foo = function (arg) {
trace (arg);
};
MovieClip.prototype.DrawCircle = function (x,y,diameter) {
var r=diameter/2;
var c1=r*(Math.SQRT2-1);
var c2=r*Math.SQRT2/2;
this.moveTo(x+r,y);
this.curveTo(x+r,y+c1,x+c2,y+c2);
this.curveTo(x+c1,y+r,x,y+r);
this.curveTo(x-c1,y+r,x-c2,y+c2);
this.curveTo(x-r,y+c1,x-r,y);
this.curveTo(x-r,y-c1,x-c2,y-c2);
this.curveTo(x-c1,y-r,x,y-r);
this.curveTo(x+c1,y-r,x+c2,y-c2);
this.curveTo(x+r,y-c1,x+r,y);
}
msg11 {
orangechicken[+],
posted: 07.22.03 9a•-,
top [^]
}
I think that using an object as the callback parameter would be better for backwards compatibility.
in place of a function pointer pass this:
{ scope: path.to.scope, func: theFunction }
and then in the code do nearly exactly what 1st said and do:
if( this._callback instanceof Function ){ // for backwards compatibility
with( this._parent )
this._callback()
} else {
this._callback.scope[ this._callback.func ]();
}
I didn't include the args array so that the syntax for tween() would remain unchanged.
HTH,
chicken
msg12 {
theranch[+],
posted: 07.28.03 4a•-,
top [^]
}
I love this...works great!
msg13 {
hopbot[+],
posted: 07.28.03 7a•04.29.04 5p,
top [^]
}
great stuff once again zeh,
just a note: i replaced where you do the callback in my own uses - I use ASBroadcaster to broadcast an onTweenDone event and after doing the tween frame i broadcast an onTweenStep message, in case i need to sync stuff up. i actaully do it in the section where you selete the property from the proplist becasue i have found, with similar tween prototypes, that if you are doing any major stuff, like loading xml or populating a datagrid or something when an animation is done, the last frame "hangs" so i wait that extra frame.
Yeah hopbot, it's best for people to replace my (sloppy) callback implementation with a feature of their own liking. I won't change the way this tween() method works because that'd break code already created or result in a code with too much room for different parameters to be passed and it'd get too complicated for people without much grasp of AS to handle. But if people have a better way of using it and want to, all the better.
Also, thanks orangechicken. I'll consider something like this in my own next methods too :)
msg15 {
orangechicken[+],
posted: 07.30.03 11p•-,
top [^]
}
I found I needed the args object after all (like 1stpixel suggested). I used my method (for backwards compatibility) and just added a args property to the callback object I passed in.
When referencing movieclips below the current level, I like to keep using this.x so I have a better view of where I am.
But since both solutions are same thing, why is some special reason needed? I use both depending on the situation, and this is a situation I wanted to use this[].
i'm trying to get this to work with penner's color class so i can do a _brightness tween or tint or similiar. but it doesn't seem to work just by plugging in the value in the properties param. before i start messing with the code i wanted to see if anyone could point me in the right direction...
my intitial thought is to modify rp's brightness - MovieClip methods to the format seen here but i'd love to hear your thoughts.
tnx
msg19 {
zeh[+],
posted: 08.09.03 8p•08.09.03 8p,
top [^]
}
You could use some temporary property beeing tweened and an event to set its color based on this brightness property everytime, but that's not needed since the brightness is nothing more then a simple calculation used on setTransform...
So here's a "brightnessTo()" method, working in the same way the rest of the functions (slideTo, rotateTo, colorTo) are. It's just a shortcut/helper method which calls the colorTransformTo method.
I won't claim I'm the author of this since it's just a modification of Robert Penner's setBrightness prototype, but it will work.
msg20 {
sputnikenmeister[+],
posted: 08.11.03 2a•08.11.03 3a,
top [^]
}
very impressive...
there is a little bug in version 1.11.7. "rotateTo" is not hidden using ASSetPropFlags(), in line 292 and shows up in the for in loops. easy fix...
Oops, thanks for noticing that sputnikenmeister, I had messed my copy & paste work and was hiding scaleTo again.. :) fixed now.
msg22 {
wazungu[+],
posted: 08.12.03 9a•-,
top [^]
}
Gentlemen,
Love love love the tweening equations, it's changed the way I work!
One question:
Is there a way to pass an argument along with the function call? I note the existence of the 'extra[n]' args but those seem to be reserved for the 'bounce' tweens. I noticed the example where the function is defined in the 'callback' slot, but I have problems getting that to work.
In particular, I need to be able to call a different function (on callback) based on a variable. I could do this from another function if I could pass an argument along, or if there was a way to stick a variable in that callback argument.
Is this possible? Can anyone give me some insight here? Thanks much!
msg23 {
zeh[+],
posted: 08.12.03 9a•08.12.03 9a,
top [^]
}
@wazungu: it might seem weird, but since it's a real function parameter, you only need to do this:
Really,
the usefull prototype, i watch,
that s change my way of work, thx a lot, great job !!
msg25 {
zeh[+],
posted: 08.26.03 12p•08.26.03 6p,
top [^]
}
Ok, I've updated the prototype to version 1.12.7. This is in fact an update I've been
thinking of doing for quite sometime. I've revamped the way the tweening is controlled.
Before (1.11.7 and lower) one "child" movieclip was created for each property that you
wanted to tween. This had two problems: first, too many movieclips were created if you
had too many properties to tween (thus making playback slow AND using too much memory);
and second, you couldn't rely on all movieclips' onEnterFrame event to be fired at
*exactly* the same time/frame so you could have some unexpected results.
Now, I've integrated everything in one child movieclip only. When a new tween is fired,
it creates a child movie (if not created yet) which handles all property tweens. All
properties that should be tweened are added to this movieclip as objects with all the
parameters needed and processed from there, on only one onEnterFrame (the child movie
one's).
(In fact, I wanted to have only one "controller" onEnterFrame for the whole movie - at
the _root - but that'd create issues with the callback scope and not be compatible with
previous scripts that made use of it, so I'll leave it this way.)
Of course, the purpose of this was getting a faster speed *and* using less memory. I've
made some tests and although I can't give precise numbers, it's become some 5% faster
in average. It has become slower too in some aspects, but it's in *very* rare
circumstances (one single tween on a large ammount of objects at the same time). Yup,
not so fast as expected, but I think it's a victory for good memory maintenance.
One final comment regarding Flash MX 2004/7/MX 2. it looks like some tweening
actions/methods/classes are already implemented in Flash MX 2004 and we'll be able to
drop this (and others) "alternate" methods altogether and adopt some universal
standard. Or so the rumor mill says. So unless something weird happens, this is a final
version of the method.
msg26 {
eviltwin[+],
posted: 08.28.03 1p•-,
top [^]
}
You say this is the last version Zeh, but most of us production/client environments won't actually be using Flash MX 2004/7/MX/whatever for a good 8 months so I still think this script is absolutely essential to my everyday toolkit. Great work, thanks enormously!
msg27 {
kim[+],
posted: 10.01.03 7p•10.01.03 7p,
top [^]
}
bug in v1.12.7?
this.$_tweenPropList.lenght in StopTween function? "length" is spelled incorrectly.
Gosh, Kim, you're right. My mistake. Thanks for pointing that out.
Because of this, it was leaving a trace (the tween controlling movieclip) behind when tweenings were stopped using stopTween().
It's fixed now.
msg29 {
dark sylkro[+],
posted: 10.24.03 2a•-,
top [^]
}
Hey All, Thanks for this proto, yeah it changed the way i worked overnight too.... i've read all the comments just to be sure this hasn't been addressed, and i've noticed this in the changelog. Why have you changed the setInterval for the onEnterFrame method?
since there's only one child mc, is it not possible to re-introduce it?
Thanks and great great work! A.
msg30 {
zeh[+],
posted: 10.24.03 5a•10.26.03 9a,
top [^]
}
dark sylkro: basically running it with setInterval would make it run more times than needed, or less times than needed (you had to adjust the interval depending on the framerate), or having synchronization problems when having several property tweenings.
About the first problem: let's say you want to make a ball that moves to 10,10 using 300 frames, 10 seconds, at 30fps. You could use a setInterval of 33.3333ms and it would work. However, 1. you had to set an interval that was compatible with your framerate (each frame time = fps / 1000) and 2. even if you have one setInterval that should run on each frame, sometimes the setInterval function would run before or after the screen (frame) update, so you wouldn't see a correct update. This was hard to notice when doing simple animations, but when I ran some trail-enabled tests (click on "toggle rastro"], I ran into this problem. When moving a ball, for example, the balls would be drawn like this (one line = one frame):
So you can see one of the frames was updated with a different timing, and as such, it had a different position for the object. In the end, the effect was virtually impossible to spot, because having the object at 25% of its interpolation position at 25% of the interpolation time is not very different from having it at 50%/50%, but I wanted to ensure I'd have the most faithful movement if having trails or firing other events was needed. That's why I decided to stick with onEnterFrame and time checking.
Also, if the playrate is dead slow (say, 2fps), there's no need to fire 100 unneeded setInterval functions which will make playback slow and won't even be drawn anyways.
About the second problem: this was something I encountered when having multiple properties being tweened when they were, let's say, tied to each other. If I had X and Y being updated and an object being moved diagonally on the screen, sometimes X would get updated before Y and instead of doing a diagonal, straight line movement, the object would have an erratical movement path.
Of course, the main problem with this was the fact that I had multiple functions, one for each property, which I also had with the onenterframe version - it would work with one setInterval function for each movieclip only. But even so, it wouldn't with different movieclips, and the previous problem still existed, so in the end I switched to ontenterframe. Better be tied to the running speed since tweening is used mostly for visual updates.
Whew, I hope my english was good enough to explain that. :)
And yes, it's easy to reintroduce it by replacing the child "controller" movieclip with a simple setInterval. I wouldn't recommend it, though, save for some special cases (say, if you need one event fired on EVERY frame of a 30fps movie, or EVERYtime each 10ms). But since it also requires a modification of the interval parameter on each case, I don't think it would have a better playback if used on visual updating.
msg31 {
tom24569[+],
posted: 10.24.03 11a•10.24.03 11a,
top [^]
}
To make this work, it seems I have to set Flash MX 2004 to AS1 and Flash Player 6. Is there any way to run it with AS2 and player 7?
msg32 {
dark sylkro[+],
posted: 10.26.03 8a•-,
top [^]
}
hey, i have one question, do you rebwrite your protoype in as 2 ?
thx, and always great job ... :-)
msg34 {
zeh[+],
posted: 10.27.03 5p•10.27.03 5p,
top [^]
}
I don't think I'll rewrite that using AS2 in the near future. I'm not using MX 2004 so I won't try to make something I won't use everyday and won't be able to test. I'll probably do that in a few months though...
Anyways, MX2004 has a Tween class using Robert Penner's own equations, so it might be a good thing to try it.
msg35 {
orangechicken[+],
posted: 10.28.03 10p•-,
top [^]
}
Added a nifty little "weighted" tween called 'easeweighted' (uses logic from Robert Penner's pointOnCurve). It takes a single control point value. The control point can really be any value (if it's outside the starting or destination points it does an overshoot. You can also combine and _x and _y (separate .tween calls) to get an (uneased) bezier curve motion tween (I've attached a shortcut for bezierCurveTo - even though it's really a quadratic approximation of a bezier).
////////// add this somewhere near the shortcuts
MovieClip.prototype.bezierCurveTo = function (propDest_x, propDest_y, timeSeconds, delay, callback, controlPointX, controlPointY) { // NOTE:: No animType specified!!!
// Curves along an approximated bezier curve using a control point. Example: <movieclip>.bezierCurveTo(100, 100, delay, callback, 80, 40 )
this.tween( "_x", propDest_x, timeSeconds, "easeweighted", delay, callback, controlPointX );
this.tween( "_y", propDest_y, timeSeconds, "easeweighted", delay, callback, controlPointY );
};
ASSetPropFlags(MovieClip.prototype, "bezierCurveTo", 1, 0);
////////// and add this to the bottom of the switch in findTweenValue
case "easeweighted":
// returns a position on a straight line weighted to the control position (Uses Robert Penner's pointOnCurve code
c = _propDest; // we need the full destination to use the bezier point
return b + (t/=d)*(2*(1-t)*(cp-b) + t*(c - b));
msg39 {
wazungu[+],
posted: 10.29.03 9a•-,
top [^]
}
"Anyways, MX2004 has a Tween class using Robert Penner's own equations, so it might be a good thing to try it."[zeh]
So, can anyone shed some light on this? This is one MX04 feature I've not come across. I like the idea of using AS2 coding methods to do these things (good way to learn, good coding practices), but haven't seen any documentation on this subject. Zeh/others, any comments?
msg40 {
zeh[+],
posted: 10.29.03 9a•10.29.03 9a,
top [^]
}
wazungu: it's a bit hidden, you have to dig a lot to find, but it's there. On MX 2004, on the classes folder, somewhere, is the "tween" class. I don't know exactly how it works or how to use it (I'm not using MX 2004), but it's there. Unfortunatelly I haven't seen any documentation on it either, so I might not be the best person on earth to comment on it.
from the flashcoders list might have the answer, though. Just click the users name to see each message. There are zillions of other messages on the list on the subject too, so I believe searching the list for a specific doubt is the best way to go.
Here's a nice thread on FlashCoders about the tween class on MX 2004. Read Muzak's replies, he provides examples and explains the syntax quite a bit. Pretty handy.
msg42 {
openmind[+],
posted: 12.02.03 8p•-,
top [^]
}
This is with out a doubt the best work I have seen for a long time! Thank you and congratulations on an awesome tween class. I have tried quite a few before but found them all to be missing something that I needed. Your's however has all I require plus additional functionality that I was amazed to use!
Keep up the good work. Macromedia attempt in 2004 MX is a poor subsitute for your excellent work and like many others here am looking forward to an AS2 implementation.
msg45 {
sputnikenmeister[+],
posted: 12.09.03 4p•12.09.03 4p,
top [^]
}
zeh, laco!! please don't fork this great work!! proto.layer51.com works fine but, having thought about hosting this tweening class in sourceforge.net too? that way more than one person can contribute to the same project... On the other hand, I know all this is a very personal question...
Anyway, I can very well see this class as the beginning of an unofficial *standard library* for flash. On the other hand, again, this is a bit naive: Macromedia should provide a proper library, and pay you guys for that (this last thing is even more naive :).
Sorry beforehand to the list in case this is not the place for discussing this.
msg46 {
wazungu[+],
posted: 12.09.03 5p•-,
top [^]
}
Spunk: not sure you can avoid forking if you want to support both a AS 1.0 method with prototypes, and an AS 2.0 method with classes. Sourceforge might be a great home for this project, but that's up to zeh et. al.
Sputnik: that's an idea, sure, but, personally, I think it's more than enough to have it at proto.layer51.com. Sure it's an static project without too much of the fine stuff sourceforge can offer, but I think sourceforge would be... too big/complicated for one simple extension function.
It might make things a bit fuzzy, but I really like the way it works now - easy comment system, easy copy&paste.. there's always place for extensions suggested by people on comments, as 1stpixel's greatest addition (above), which I have saved on my include dir.. I do understand your concerns, but I think it's best for us flash developers to try and make proto.layer51.com the best place for any prototype/extension, not only for mine or laco's tweening functions but also many others.
Yes, there are lots of nice features that could be added here... MXP processing and downloading would be great, threaded comments ala esreality.com would help, better modification history would be cool and save space on the code, whatever, I could think of gazillions new features... the point is, I think the site works great, new features would be enough, so I don't think moving to any other place like sourceforge would help or make things less complicated.
(what I know is that a new version of this site was being coded and was set to be online sometime soon, but I don't know the status of it or which new features it'd have)
I do respect a lot your opinion and thanks for sharing it with me (us). Maybe I'm just a fan of php.net's-style comment system immense help, but right now I think it's best for all of us to stay here.
About macromedia: maybe many people won't agree with me, but I think what macromedia is doing now is right. If they chose to implement a tween method, for example, they'd have to cover all kinds of features people would want.. Then people would whine that either macromedia's tween() methods are too complicated and hard to use, or too simple and doesn't have enough features. There are so many ways of implementing property tweening on flash, it'd be a real drag for them to go for a certain implementation and have to deal with all the criticism. Look at the tweening solutions available now: mine (simple, method based), Robert Penner's own (very powerful, class based), and many others I forgot (sorry) but very different from mine or Penner's solution. Many people prefer classes so they can create their own powerful/dynamic timelines, and my solution is just a simple one-line tween trigger and not good for them to implement. On the other hand, many people don't like to use classes and new objects because you'd have 3 lines just to make a stupid button tween from alpha 100 to alpha 50 on rollover. So what's the better solution? There's no easy answer; It's very hard to tell, opinions differ a lot, and it's just natural that macromedia didn't go with a single solution with these and hundreds of others matters who affect flash. Heck, the whole reason I built this tween methods is because I didn't want to use 3 commands to execute one single dynamic tween, because that's what the solutions available at the date used...
I know this tween method has been, err, kinda popular (most visited/commented function on this site, and it has been here for 5 months only), so it means some people might like this way of issuing tweens, but that doesn't mean it'd be the perfect/final implementation.. if it was pushed as "the FINAL ULTIMATE" tween method in, say, FLASH MX 2004 SPECIAL ZEH++ VERSION, I know thousands of people would jump to my throat asking why the heck XYZ was done in the ABC way and not the JKL way, so being open as it's nowadays give people the freedom to use whatever they want the way they want. People who wants objects and classes use objects and classes, people who want one line tweenings use one line tweening methods. And everybody is happy..
But, well, it's just the way I see it.
msg48 {
bishop[+],
posted: 01.07.04 11p•01.07.04 11p,
top [^]
}
This may sound really dumb but I would love a better example than what you have already stated up there Zeh.
I have downloaded your files and have them in my include. (I can tell because the code hints show up.) I have included Rob Penners stuff as well. I dunno if I have completely missing something here but the instructions are assuming something I don't know.
I have named a MC "ball" (with the same instance name) in Flash Player 6, MX. I put the following code on the root timeline and nothing happens:
ball.tween("_x", 10); //Just like in your example.
I got nothing here..... what am I missing?
If any one has an FLA showing a bit of this magic that would be great!
bishop: you probably just need to include the file.
like:
#include "mc_tween.as"
ball.tween("_x", 10);
That #include must be anywhere on your movie, preferably on one of the first frames. Of course,
you must put the correct name you used (I use "mc_tween.as"). When you put stuff on the /include
directory, it's available for including, but it's not present on your movie until you explicitly
tells flash to add it.
This include .as file could be on your .fla directory too, but when it's the case with common-use
functions (like this tween), it's a better idea to let it be at the /include directory.
You don't need to include anything else.
The coloring syntax/tip displaying is dependant on other (xml) file which is installed in flash,
so it doesn't *necessarily* mean you have the tween() functions included or even installed.
Let me know if you can't get it to work.
msg50 {
bishop[+],
posted: 01.08.04 12p•01.08.04 12p,
top [^]
}
Thanx Zeh! I got it to work now. I assumed that the MXP file took care of everything. You were right on about the include. Thanks for putting up with us rookies.
By the way, thanks for being so fast. Thats really cool you are watching your thread this closely.
I am going to experiment a ton with this, thanks again.
Heh, you've got to thank proto.layer51.com's mail notification for the speed, not me. I'm just a nervous guy who doesn't like to have 1000 "todo" things on my mail list, and I try to eliminate them asap..
The MXP file includes it on your include directory, but it's up to the programmer to include it on each .fla file. Or else you'd have the tween functions included on all of your projects, which's not desirable since it takes some 10kb on the compiled swf...
Also, I'd like to ask you to check the version of the file that's in your /include directory. I don't know if the MXP file is up-to-date.
msg52 {
bishop[+],
posted: 01.12.04 1a•01.12.04 1a,
top [^]
}
If you mean version of the "mc_tween.as" file I have: Version: 1.12.9
By the way, is it tough to make those MXP files? Or is it just a complier sorta deal? (I guess I could look it up but I a short answer will do.) :-)
msg54 {
bishop[+],
posted: 01.13.04 10p•01.14.04 2a,
top [^]
}
Zeh,
I really hate to keep bugging you about your Method. I really dig'em, I am just trying to get them to do exactly what I want. Maybe I am going about it wrong. (because in theory its really easy what I am trying to do.)
Here is the problem:
All I want to do is tween a logo onto the screen on a button press. Then when another button is pressed the logo goes away, but then returns after a four second delay as follows:
I am not the best AS coder and sometimes my logic is sloppy. But if can't you apply the same kind of method to an object if the method is delayed?
Again, great work, I will keep working with this MC Prototype to see if I can get it to work as well.
msg55 {
zeh[+],
posted: 01.14.04 4a•01.14.04 4a,
top [^]
}
Bishop: that's because the tween methods don't allow for two tweens on the same property at the same time. Right now, one new _x tween (for example) overwrites the old one, even if the delay used make it play in different times.
Yeah, I know, it's not the best way. That's why the new version of the tweening I am working on allows people to animate it the way you did. But's a completelly new, faster, revamped version, even borrowing some concepts from laco's AS2 version, and it's not ready for release (not to mention it's not 100% compatible with the current version - callback is different), so I can't put it online.
On your case, you could make sequential tweenings with callback functions. Like this:
This is ugly, basically because there are some uses I haven't envisioned (sp?) when I first developed it. But it works.
Also, if you don't want to flood the comment system with questions :), you can always email me (zeh at fatorcaos dot com dot br) or talk to me via icq (1690056) or msn ("zeh_at_fatorcaos@hotmail.com").
msg56 {
rinse[+],
posted: 01.18.04 2p•-,
top [^]
}
How to get call back to work?
Zeh, how exactly do you get the callback function to work properly? When i do something like this:
the function I'm calling is like this:
function cloneTitle() {
titleString.duplicateMovieClip("titleString2", 1);
_root.titleString2.SectionName = _root.data_ds.Name.toUpperCase();
_root.titleString2.tween("_alpha", 50, 1);
_root.titleString2.tween("_x", 550, 1, easeOut, 0, this.cloneTitle2());
};
The callback function is not occurring after the tween is complete... in fact it is occuring before the tween begins because of the delaly parameter I am setting.
In msg number above you mention "Also, I think my callback implementation is a bit bad (functions need weird references when the tween is not done from _parent). Any suggestion or idea on a better way to implement that would be greatly appreciated."
What do you mean weird referneces? Is this why I am having problems?
That means that you need to use "this._parent" or "this._parent._parent" or etc inside your function to work properly. That's because of the way I've implemented the callback parameter when I first created the prototypes. I tried to make it work in a way but it couldn't most of the times, and in the end it's just a messy solution. My bad. There'll be a version it'll run from the movieclip scope itself, as stated some comments above.
msg58 {
rinse[+],
posted: 01.18.04 3p•-,
top [^]
}
Zeh,
Thanks for you answer. That was it.
As a side note... I am having difficulty getting the the prottype to work on dynaimcally loaded swf files.
When you issue a loadmovie on a movieclip, it erases everything in the movieclip, including any tweening action.
You have to assign the tween command after the content has been loaded. Which is in fact something you have to do anyways: if the above code worked the way you've wrote it, you'd still have to make the tween be executed after the content has been loaded, or else it'd only load locally (that is, if it was online, the tween command would be executed before the content had actually been loaded).
If you're trying to run things locally, though, and don't care for load times, just use the tween command one frame after the load command.
msg60 {
ephraimt[+],
posted: 02.05.04 10p•02.11.04 11p,
top [^]
}
Regarding orangechicken's code in msg12 & msg16 (callback) and msg36 (bezier motion):
msg12 & msg16: (callback):
A. It seems you left out the dollar sign prefixes on the $_callback.
B. For me it only worked if I passed func a string (the name of a function) instead of a function object.
36: (bezier motion)
Using your sample usage code I get a straight line motion, not a curve. Any suggestions?
msg61 {
Maxkuri[+],
posted: 02.07.04 11a•-,
top [^]
}
I'm seeing the same problem "ephraimt" explained with "bezierCurveTo()" too...
I'm not very experienced with code, and I would like to solve the callback problem, but when I want to pass some args after applying the changes mentioned in msg12 and msg16, it doesn't work...so, please, can someone post an example with the exact code to make it work the callback with args? Thanks a lot.
msg62 {
zeh[+],
posted: 02.17.04 12p•02.17.04 12p,
top [^]
}
Ok, people, it's me again. Listen, this is a heavy update, so it needs a bit of explanation.
First of all, the old versions are still available to download and installation here:
So if you don't like the new one, fine, just get the old one.
Ok, the new one has this:
mc.lockTween() and mc.unlockTween() methods. They're useful for buttons: for example, the user clicks a button and it fades out. But it also has a tween on the onRollOut() event. So instead of letting the onrollout event overwrite the fadeout tween, a lockTween() right after one tweening will lock the movieclip and it won't be able to accept new tweens anymore. The unlockTween() method does the contrary.
Sequential animation. Ok, this one is actually cool. Now, tweenings aren't automatically overwritten, they "recognize" the time they're being assigned and overwrite only when needed. So you can do complex tweening animations now in sequence witjout having to use callbacks. For example:
This will move ball to 10,10 in 1 second, then move it to 100, 100 on another second. Notice that the delay parameter is used to set the time it'll animate. This wasn't possible before, because the second slideTo() would overwrite the first one, but that's not the case anymore. This is something I've been wanting to do for ages - to allow more complex animations - but I didn't want to make it all that complex to the end user, this is the solution I've found.
Callback totally changed. Ok, this one is difficult.
My old callback implementation tried to use the scope from which the tween command was originally issued. That doesn't work. In the end people was left with the option of using "this._parent" to refer to the target movieclip. So instead of trying to accomplish the impossible, I end up using a explicit scope. This new scope is, naturally, the movieclip. This means that "this" inside a callback function will now refer to the movieclip itself, NOT a movieclip child. So, if you use this tween on your movies, it will BREAK callback functionality. That's why (1) this has a different name (mc_tween2.as) and (2) it has a global backward callback compatibility option (use _global.backwardCallbackTweening = true).
It's faster. It's also using ONE MOVIECLIP to handle all tweenings (on _root), instead of a child MC for each MC. This is something I've been thinking of doing for quite sometime (since I changed the "one child mc per property" functionality) but I didn't want to do because it'd fux0r the callback. Since now I screwed the old callback anyways, I decided to do this. This is good, because it'll use less memory, less onEnterFrames, less everything.
CONCLUSION: Although I've said a number of times "this will be the latest version", the truth is, this MC_TWEEN is evolving everyday. Since I *USE* it on all my jobs, I always add something new when I feel it needs it. That's what I did today with the lockTween and unlockTween methods, for example: I added them because I needed them, not because they were planned or anything.
Because of this, I took real pains to rethink and recode MC_TWEEN and bring it to this version 2. It's different, allows a lot more, and is much easier to learn, I think. I know it'll be bad for people that'll have to port old callback stuff (or set the compatibility option), but it's the best for the future.
Also, I know the help is nonexistant. I'm sorry. I intend to write an article explaining how to use it a bit better in the future. I still have some implementations to do on this tween so this is still a beta version of the final version 2.
As a final note, I'm still using Flash 6 so I don't think I'll do a AS2 version so soon. There's laco's version which seems ok anyways, and until I get an extremely light/fast prototype - on all situations - I won't drop development on this tween prototype.
Thanks,
zeh
msg63 {
ephraimt[+],
posted: 02.19.04 5a•02.25.04 1p,
top [^]
}
I need a function that is the inverse of findTweenValue: Given all the other args (but not time) and a target value, return the time when the value will be the target value.
Any takers?
------------------
UPDATE TO THIS MSG - Feb. 25, 2004: Robert Penner wrote to me as follows:
"Mathematically, most of the equations can be inversed, although it takes some work and some equations are much harder than others. For example, the inverse of quadratic easing, based on x*x, is a square root formula. To produce inversed equations would be a significant amount of work. The equations that cannot be inversed are those that fail the horizontal line test--a horizontal line through any part of the graph should hit the curve only once.
"I don't know of a straightforward way to produce the inverse of an arbitrary easing equation, other than creating a table of position/time pairs and using that to do a reverse lookup to the closest time."
msg64 {
Avengio[+],
posted: 02.20.04 2p•02.23.04 8a,
top [^]
}
Hi there
From what I have read mc_tween sounds awesome. A quick question though. Is it compatitble with Actionscript 2.0? [Later] Whoops! my question is answered two posts above sorry bout that. :)
thanks in advance
msg65 {
gragland[+],
posted: 02.25.04 10a•-,
top [^]
}
I am trying to use Rob Penners elastic equations, but the only way i can get a realistic elastic effect is if i set "extra2" to something really small like 1.001. Anying higher like 1.1 and it bounces back and forth wayy to fast, and if i set it to 1 or below it doesnt bounce at all. (it eases very slowely). "extra1" doesnt seem to do anything. Can anyone help me understand how to use these equations better?
msg66 {
theo7[+],
posted: 02.28.04 8a•02.29.04 9a,
top [^]
}
thanks a lot for sharing your efforts zeh the update sound great and is really welcome
now just add a motion blur switch to it and it might indeed save the world ;)
msg67 {
zeh[+],
posted: 03.01.04 9a•03.01.04 1p,
top [^]
}
2.16.11: added textfield tweening. Yay! All movieclip methods work with textfields, except for colorTransformTo(). There's also a new one (textfield only), scrollTo(). As usual, MXP files and XML files can be found on the url on the first comment, and help/explanation can be found on the .AS file itself, on the comments.
I was going to make it a separate #include file (to "add support" to textfields to the mc_tween include file), but it'd make it to complicated to the users and it's just a few bytes anyways, since most of the code is copied by reference (add minor code bytes or memory usage) and there's just a few lines of code added for compatibility.
msg68 {
niko[+],
posted: 03.01.04 12p•-,
top [^]
}
great !!!!
wonderful !
the best proto i ever see ... always ...
msg69 {
takemeaway[+],
posted: 03.01.04 11p•-,
top [^]
}
the most critical place in the code is the callback-handling.
I wish that I could set the scope, function, arguments within the
tween-call
I did a rewrite of your code.
I call the tween like this, notice the callback parameter that now is an array
this.MC.tween(["_x"], [tDist], 0.5, "linear", 0, [this, "onEnd", [1,2,3,4,5]] )
and in the prototype I have replaced your callback-executin line with this
objProp._callback[0][objProp._callback[1]].apply(objProp._callback[0], objProp._callback[2]);
Now i can do a lot of good things with it.
.. and for backwards compatibility you could check if the callback parameter submitted
is an instance of an Array or not.
/ martin klasson
msg70 {
WellDone[+],
posted: 03.09.04 1a•-,
top [^]
}
Hello,
First, good job for this proto.
I'm french web designer and i would like to read more information, use and example on the last three arguments :
Callback, Extra 1 & Extra 2.
Thanks.
msg71 {
bitfactory[+],
posted: 03.09.04 3p•-,
top [^]
}
zeh,
works great - but i have a question.
i installed using the EM installer. i also placed the .as file in the
same directory as the swf.
runs fine... but i thought the swf pulled from the .as file with the include call? (mc_tween_2_16_11.as)
but if i delete that file, it still runs fine... wth? is the code 'baked' in since i installed it as an extension? did i misunderstand your instructions that you should also have the .as file as well?
if you use the installed extension, is there no need for the external .as file when you go to publish it?
again - fantastic job.
msg72 {
zeh[+],
posted: 03.09.04 4p•03.09.04 5p,
top [^]
}
bitfactory: depends on what you installed or how you used it. do you mean the .mxp version?
If you're still able to compile it, that's because it's still on your .fla directory or (in MXP's case) in your flash /include directory.
Also, while it's saved as mc_tween_2_16_etc.as on the page I'm linking, that's just for logging purposes - I use "mc_tween2.as" as the filename on the mxp file, it's easier to remember (of course, anyone can name it as preferred).
And no, you don't need the .AS file when you're uploading it. The .AS file is only needed when you compile it on Flash. When it's on SWF form, the code from the .as file is already included on the compiled movie.
The mxp installs the .as file.. so if you installed it you don't have to copy anything. But of course you can install it yourself (copy the .as file to whatever place you want) and include it from any directory. You can also copy&paste the code above and use on your .fla file directly. The .as include file is just a helper, once you get used to include files it's better to use it that way. But if you're unsure on how to use it, just copy&paste the code to any frame on your fla file (anywhere before you use any .tween command), it's the exactly same thing.
msg73 {
bitfactory[+],
posted: 03.09.04 5p•-,
top [^]
}
thanks zeh - got it...
i'm used to seeing installed things as components - almost like they are tangible...
this makes sense, though. thanks again!
msg74 {
Raven[+],
posted: 03.17.04 12p•-,
top [^]
}
I am still confused! I installed the MPX file, mc_tween_2_16_11.mxp, using FLash MX. I can see the tween commands in my actionscript commands. I then created a simple movieclip, ball, then dragged it to the stage, and added the as, ball.tween ("_alpha", 0);. Nothing seems to be happening to the ball mc and no error messages are generated. I tried setting the ball mc's linkage (ball) but still no effect. Can someone please explain the basics for getting this to work?
Thanks in advance...
msg75 {
bitfactory[+],
posted: 03.17.04 12p•03.17.04 12p,
top [^]
}
if you are using 2004, make sure Actionscript is set to 1.0
that said...
ball.tween("_alpha", 0, "linear");
there are many more options (like delays, etc...) but this should get you up
and going.
EDIT: duh, forgot something...
make sure you get the include in there, too! obviously place it before anything of the tween actionscript - this pulls the code in that it needs.
raven: it adds the code as if you typed or pasted it at the #include location. In MC_Tween2.as's case, It's around 20kb of raw code, which then is tokenized into smaller byte codes and then compressed when the swf format itself is lzh-compressed. It adds 3.9kb to your final SWF. Next versions will be a bit smaller since I'm ditching the colorTransform code for a much better alternative.
msg79 {
turbohz[+],
posted: 03.23.04 2a•03.23.04 2a,
top [^]
}
Thanks for this great prototype, zeh! It's a real time saver!
I'd like to suggest a feature, useful for MCs or textfields with pixel fonts: pixel snapping.
Since the values applied to the different properties are not integer, pixel fonts, and other objects may appear blurry in some of the steps in the animation.
There could be a boolean parameter in the fuction to apply a Math.round() to the values before beeing applied to the MC.
Turbohz: oh, you are so correct. I have used something like this on the past, although I was tweening other properties (myX and myY for example) then applying them to _x and _y with an onEnterFrame event. Cool idea. I'll try adding it on the next version, probably as an additional boolean parameter after extra1 and extra2.
msg81 {
Raven[+],
posted: 03.24.04 12p•-,
top [^]
}
Usability Question:
Do the alpha tweens work from within multiple duplicated movieclips?
I can't get the alphaTo or tween("_alpha"...) functionality to work from within duplicated movieclips. I am creating a text animation effect using a dynamic text field to display each character of a text string. The controlling mc duplicates an effects mc which contains an mc which in turn contains the dynamic text field (non-html format). I am referencing these tween functions from within the effects mc, appling them to the textfld mc. The scaleTo function works fine but the alphaTo function has no effect. I am using the #include "mc_tween2.as" file.
Raven: yup, it does. All tweens should work on duplicated, instantiated, edit-time created, loaded or *ed movieclips without a problem.
In your case, since you're dealing with text, the problems seems to reside in the fact that flash can't apply alpha opacity to textfields when the font isn't embedded in the flash file: it either is not displayed (when you set alpha to 0) or is displayed at 100% opacity (alpha 1-100). Check to see if the fonts in your textfield are correctly embedded in the movie, or attach other graphic symbols to your movieclip just to check if the alpha problem is occuring on the text only but not in the movieclip as a whole.
msg83 {
Raven[+],
posted: 03.24.04 2p•-,
top [^]
}
zeh, you rock! Your idea to test the text mc with a non-text object was a great idea. Sure enough the alpha tweens worked fine. I embedded the font outlines and it works like a charm.
Does anyone else know of a work around without embedding fonts with dynamic text fields?
In your case, if you are *sure* you want to use non-embedded fonts (is there *really* a need in your case?), the *only* thing you can do is if you use a hidden mc on top of your text mc. Your text mc would always have 100% opacity, but the hidden mc would then fade from alpha 100% to 0%, so it'd look like your text mc was actually fading from 0% to 100%. This would only work if you have a flat, plane background (or if it's "copyable") though, because your top mc would have to be similar to the background.
msg86 {
sizzle[+],
posted: 03.26.04 12p•-,
top [^]
}
it tells you to add the .as " (with a command like #include "mc_tween.as2" in your .fla file)"
but it should be mc_tween2.as
i dont know if this had already been said but it was a bit confusing at first because i just copied and pasted it without really looking at it....then realized it was the reason it wasnt working at first :P
msg88 {
sizzle[+],
posted: 03.26.04 1p•-,
top [^]
}
thank man
brilliant work
msg89 {
bitfactory[+],
posted: 03.26.04 11p•-,
top [^]
}
zeh,
tweens have been working great... then i use them in _levels and they either CRAWL, or they don't run at all... i've been through every possible problem i can think of.
i have a stub file that loads a preloader AND the main movie.
// code in the stub file
loadMovieNum("preloader.swf", 1);
loadMovieNum("apafmain.swf", 2);
#include "mc_tween2.as"
everything loads fine, but when it gets to the tweens at the start of the apafmain movie, they crawl SO slow... all the files are being published the same way.
if i test just the apafmain movie by itself it runs great - when i load it in a level it runs terribly and sometimes not at all... experienced this?
If you want an immediate reset (no tweening), you just have to set its color transform properties, as in:
var ccc = new Color (myMC);
ccc.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0});
msg94 {
subblue[+],
posted: 03.29.04 1p•-,
top [^]
}
Thanks for the quick reply zeh, and many thanks for the script :)
msg95 {
JLM[+],
posted: 04.11.04 6a•05.03.04 6a,
top [^]
}
I have not read the thread properly or optimised these at all but they are something I created to use with penners tweening equations, it is not ideal to have the onEnterframe in the proto since it limits it to movieclips (unless it is modified) and really the dofunc needs to be generalized to allow either protos or functions to be passed. I have not bothered hiding it from for loops you can do that if it is usefull. The second two allow a two frame approach which is usefull allows a designer to use it to layout before and after great for building pages.
Without getting to all the detail I think my approach is similar to zeh that's why I posted it here. UPDATE: Add a "from" method which I found usefull.
JLM
msg96 {
gragland[+],
posted: 04.13.04 6p•-,
top [^]
}
Isn't the callback function supposed to wait untill the mc is done tweening? Its not doing that for me. The callback function is being called immediately, and if i set a delay, then the callback function is being called before the mc even starts tweening. WTH!? Anyone know what im doing wrong?
msg97 {
gragland[+],
posted: 04.13.04 6p•-,
top [^]
}
Isn't the callback function supposed to wait untill the mc is done tweening? Its not doing that for me. The callback function is being called immediately, and if i set a delay, then the callback function is being called before the mc even starts tweening. WTH!? Anyone know what im doing wrong?
You're probably passing the function return value as a parameter instead of passing the function itself. Flash runs the function and uses the return value as a parameter. Remove the brackets from the function name. If you have parameters you need to pass the function, use a wrapper function.
Watch for the scope on the parameter if you're using variables as the function parameters.
msg99 {
just_name[+],
posted: 04.14.04 3a•-,
top [^]
}
Hi! Confused...can anyone help??
I have an MC button which acts on rollOver and seems to work fine. However the mc contains links so I thought I could get around the problem of links on buttons etc, by doing a hitTest. I have an hitTest working fine elsewhere on my site and cannot figure out why this one won't.
If I rollover the hit area 'all' instead of scaling, it very slowly slides off stage to the left and 'contactMC' doesn't change _y position. Then when I rollOut the 'contactBtn' shrinks until it disappears and 'all' does not come back onto the stage.
To me it's very strange, but I'm sure it makes perfect sense to someone who knows about these things ;) Is there anybody like that reading this who can help??? Please-o-please say yes :)
Thanks in advance,
Justme
msg100 {
zeh[+],
posted: 04.14.04 6a•04.14.04 6a,
top [^]
}
Justname: you're calling the tweening functions on *every* screen update, not only when it's getting inside or outside the movie. That means that it'd call the tweening functions on *every* frame and since some of them start with a minor update on the values, the update would be extremely slow or you wouldn't notice it at all. This is not a tween issue, it's a logic issue because you're updating on every onenterframe instead of on every rollover/rollout event. It'd work if you were doing _alpha=100 or _visible=true, but just because the change would be immediate - it'd still be called on each frame and thus this is far from clean, your code would be much more processor intensive than it should. You need toggling values to know "where" the cursor was before and if it should be tweened or not (it should only tween when coming from outside to inside or vice versa). Like this,
msg101 {
just_name[+],
posted: 04.14.04 8a•-,
top [^]
}
Excellent Zeh, thanks for the response and a thousand thank you's for tween()!!!!
I figured it wasn't the tween, just me - just wasn't sure why it carried on doing the function beyond the pEnd setting when my other similar RO didn't. Oh well...I'm pretty new to all this AS stuff, so am always grateful to hear how it should be done :) What you've said sounds perfectly reasonable, so I will give it a go as best I can. I haven't really got my head around variables yet, but I know they come in very handy...I'll get there ;)
No doubt I'll be back, but in the meantime thanks for the advice.
msg102 {
just_name[+],
posted: 04.19.04 9a•-,
top [^]
}
Is there a way of checking when the tweens have finished before progressing to the following frame? Is it anything to do with the callback function? I've read the threads here, but I'm afraid I just don't follow it - sorry to be such a newbie pain.. :(
msg103 {
zeh[+],
posted: 04.19.04 10a•04.19.04 1p,
top [^]
}
just_name: sure, just stop the movie, tween something and use the callback to continue.
this will stop the current timeline, make ball disappear, and then proceed within the current timeline.
EDIT: even though I said "disappear", I had written "alphaTo(100".. I've corrected it to 0 now :)
msg104 {
just_name[+],
posted: 04.19.04 1p•-,
top [^]
}
Excellent!!!! Thanks zeh :) You're a lifesaver, I would never have worked that out - I fiddled with work arounds for this ALL day and your code did it just like that :)
Excellent, many thanks.
msg105 {
just_name[+],
posted: 04.20.04 1p•-,
top [^]
}
Just wanted to say thanks for the contact rollOver code - it worked lovely!!! I was bogged down stressing about other bits so hadn't tried the code until today, but it worked and I'm well chuffed, so thank you ever so much :)
msg106 {
Worldseye[+],
posted: 04.22.04 2a•-,
top [^]
}
Truly a work of art, crafted from the essence of creative ActionScript, many thanks for making such a useful and timesaving utility available to the Flash community, I had started on a class to do the exact same thing so it's already saved me hours of coding and your implementation is extremely easy to use whilst maintaining the versatility required for complex animation!! A great effort, I commend you.. :D
Regards
Dan
msg107 {
rkorfmann[+],
posted: 04.28.04 5a•-,
top [^]
}
I really love this tweening functionality but I need to use it in a project that is composed entirely of class files. The problem I am having is that I do not know where to add the include file. If I add it to any of the classes in which I want to use tweening, I get the error:
ActionScript 2.0 class scripts may only define class or interface constructs.
How do I get around this.
Thanks
Roger
msg108 {
Gregorin[+],
posted: 04.29.04 12a•-,
top [^]
}
Hi, im having a liccle problem with setMask() when used with tween(). Is there a conflict somewhere or am i doing this wrong? I have used setMask() in a test situation no probs but when i using it below then its no working. I have square box in my library called morph. Thanks in advance.
msg109 {
liquidd[+],
posted: 04.29.04 1p•-,
top [^]
}
Well Im not sure exactly what your trying to do, but there were a few syntax problems. the mask is now working correctly. I commented the couple places I changed your code. If this is not what you were looking for maybe you could give me some more details...
#include "mc_tween2.as"
var widthOne = 300;
var heightOne = 370;
var widthTwo = 270;
var heightTwo = 50;
this.box.morphMask_mc.tween(["_xscale", "_yscale", "_alpha"], [widthTwo, heightTwo, 60], 1);
//the line below: I changed _root.box.morph to _root.box.morph_mc: also removed the quotes from
//setMask("") <--- dont need quotes
rkorfmann: I don't know of issues with flash mx 2k4/as2 since I'm not using it that much, so I can't be much of a help, sorry. Have you tried laco's version though (up there on the comments)? He has a similar tweening extension for as2, and it uses the same syntax.
msg111 {
daveglanz[+],
posted: 05.02.04 8a•-,
top [^]
}
I'm trying a basic drop down menu using the tween prototype.
The problem is that nested buttons in a "dropdown" mc menu are not functioning when the tween is active.
I tried using "stopTween()" without success.
Well, this looks like a flash issue, not a tween issue: you can't have two symbols that accept mouse events on top of each other.. meaning you can't have an MC with onRollover() and then inside of it a mc with onPress(), the topmost one will be the one receiving all events (the mc on your case). You'll have to emulate the rollover/rollout events on the mc by checking the mouse position.
Coincidentally, there's something like this discussed in this huge comment thread. Check comments #100 and #101, I believe that's what you're looking for.
msg114 {
daveglanz[+],
posted: 05.02.04 10a•-,
top [^]
}
but one problem I see right away is the onEnterFrame has no way to delete itself. How would you do that here?
msg115 {
daveglanz[+],
posted: 05.02.04 12p•-,
top [^]
}
any ideas out there? right now, I have to have two enterframe scripts running-not sure of a solution to get them to stop when uneeded.
Here's the actual page I'm workign on:
dropdown menu works when you roll over the "catalog" button (the enterframe scripts are on the "catalog" button as well as the actual dropdown menu with all the catalog selections)....
if anyone has any ideas-feel free to share and help.
may depend on the rest of your code. My suggestion may not be optimal.
My tweener method has the onEnterframe built in if your tweening movieclips and may be easier to call it from this.onmouseMove and remove this.onmouseMove while it is moving? You can look into caller and callee they may help.
JLM
msg117 {
daveglanz[+],
posted: 05.04.04 6a•-,
top [^]
}
ah, that would make sense. I ended up rethinking the menu anyway-to be accessed by clicking:
www.daveglanzproductions.com/laj/
I'll try that though, thanks!
msg118 {
just_name[+],
posted: 05.04.04 5p•-,
top [^]
}
Hi, me again,
All your help worked brilliantly before, so I’m back.
I have a movieclip acting as a button; I want it to stay in it’s over/downstate when pressed (ie the button’s downstate) and then revert back to it’s upstate when not down. I can get locktween to work onRelease, which keeps the button in it’s downstate when pressed. But I can’t get the button to unlocktween and revert back to it’s upstate.
I started by reusing the hittest code you gave me in msg 101, which again works fine. Then I added an if statement to check if a variable set onRelease is not equal, in which case unlocktween. That worked too, but I thought by having the rollover/out controlled by the hittest, that once the tween had been unlocked, that the mc would go back to it’s upstate on the next enterframe (hittest actioned onenterframe) – but it doesn’t. What am I missing?? I’ve tried it in all sorts of ways, but none of them will reset the button when the next button is clicked. FYI the buttons move the playhead of another mc to the specified frame, containing text only.
I’m trying really hard to stick to actionscript as often as possible to get more practice, I’m also really trying to keep my code manageable and efficient (as every developer should), but it’s really hard :( An up, over and down state shouldn’t be so difficult in as, should it?? Can anyone help?
Many thanks in advance!!
msg119 {
gragland[+],
posted: 05.22.04 7p•-,
top [^]
}
I'm having a problem, and im not sure if its something I can fix or if its a limitation of this prototype. I made a frame that resizes depending on the demensions of a dynamically loaded jpg. The frame is made of 8 mc's, one for each corner and one for each side. So the side mc's tween their _height, _x, and _y so that they make a frame around the jpg, the top and bottom side mc's are the same except its their width that tweens, and the corner mc's just tween their _x and _y. The resulting effect is a frame that tweens to fit whatever size jpg is loaded. The PROBLEM is that the corner mc's and the side mc's dont always move quite in unison, if i set the whole frame tween to take one second its very apparent. The side is 5 or so pixels ahead of the corner mc'x that are above and below that side. Is this because its just too CPU intensive???
msg120 {
JLM[+],
posted: 05.22.04 7p•05.22.04 7p,
top [^]
}
Have you tried using _xscale and _yscale they can be more reliable than _width and _height but maybe not as easy to use.
Are the distances for the movieclips different?
JLM
msg121 {
gragland[+],
posted: 05.22.04 8p•05.22.04 8p,
top [^]
}
Go HERE and click the left square button towards the bottom to see the frame resize. Notice the right side is slightly ahead. Its even more noticeable if i set the tween to happen faster.
I'm not sure how _xscale and _yscale would work. The sides resize according to the width & height of the loaded jpg... Yes, the clips do have to move different distances, depending on the demensions of the jpg that is loaded.
msg122 {
wazungu[+],
posted: 05.22.04 11p•05.22.04 11p,
top [^]
}
What kind of processor are you running? Running a 2.4Ghz P4/WinXP SP1/latest F. player, looks great. I don't see any lag on my machine. I wonder if it's something that only shows on slower procs. Just a thought.
...
Nevermind, just checked it on a Celeron 650Mhz, seems just as smooth. You find a fix?
_xwidth and _ywidth are definitely the way to go, I don't think the usage is that different.
I also saw some speed tests that Laco did for his AS2 class based on this one, and it seemed to perform better. Not as up-to-date as mc.tween(), but pretty useful nonetheless, if you're using AS2/FP7.
msg123 {
JLM[+],
posted: 05.23.04 2a•05.23.04 2a,
top [^]
}
I notice it on a Duron 650Mhz (using fp7) suggest you could try scaling a frame and a mask frame you could script all the drawing since the frame is simple! The inner edge of the mask would be the inner edge of the frame but the outter edge of the mask would be larger. Alternatively you could draw the frame every frame with drawing api but maybe a little heavy on the cpu.
JLM
msg124 {
ephraimt[+],
posted: 05.23.04 2a•-,
top [^]
}
I also have been noticing some delay issues that I was planning to write in about.
When I set up tweens for several movieclips, they end up out of synch with each other. The more tweens applied in sequence, using the delay parameter, the further out of synch they get.
Is there a way to set up all the tweens, but tell them not to start until a specific time, so they will all start in unison?
I have not had problems with the prototypes that I suggested and I have been trying some complex stuff, you could try mine and let me know if they suffer the same problems, since different structures offer different advantages?
Gragland: this is know/common issue and it's not CPU issue. Basically, when you change _x, _y, _width and _height at the same time, sometimes _x is changed before _width (for example) so you can notice the seams between the slices.
I had this same problem on a few similar "resizing" boxes I've done in the past, and I had changed the code in a way that I thought that had been solved, so it's funny that you're having it but I'd like to know why.
Do you mind to post the tweening code you're using, or sending me through email? It might be something in the order or the way you're setting your tweens. It's easily solvable either way.
msg127 {
JLM[+],
posted: 05.23.04 6a•05.23.04 6a,
top [^]
}
I think in that case you should try to change all the properties for each mc in the same loop (onEnterFrame or setInterval) if you have different ones for each mc but want them to move together then setup the tween functions to be all in the _parent so you would need to make something that you call something like this;
Well my syntax is off but hopefully you get what I mean drive it from where the mc's are rather than individually for each mc, there maybe some savings for only using one function.
JLM
msg128 {
gragland[+],
posted: 05.23.04 1p•05.23.04 1p,
top [^]
}
The left square button at the bottom is what starts the frame resize.
All the frame resize code is on the layer called "imageloader."
msg129 {
zeh[+],
posted: 05.23.04 2p•05.23.04 3p,
top [^]
}
gragland: ok. there were two ways you could solve this problem when it happens
1. using everything on one tween only... this would make the start time be the same for all properties (in fact, this is NOT possible on your case, since you were using several different movieclips; it's only when using two or more properties from the same mc/object at the same time but in two different lines)
2. tweening "private" properties (example: x, y, w, and h) then issuing an onEnterFrame event to update the properties (_x, _y, etc) on each frame based on this x y w h values
However, both solutions would be working around to make the tween work like it whould have already worked from the very start. BECAUSE of this and because there was no easy way to make it work for you (you'd need the new onEnterFrame thingy), I went ahead and implemented a fix on the different time issue for the tween (version 2.16.12 now). This is, actually, a workaround Laco has suggested me (he actually sent me the code) a few months ago, but I never had the time to test and implement it properly. I've done it now, since I'll be using it soon; just update your tweening prototype code and you should be fine.
With this new time control code, your tweening start will be dependent upon the frame you are, not the real time you issued the tween (the time is updated on each enterframe). It means that on the first tween update, it will actually be a bit further down the tweening value than it was on the previous version. It's like acting on a time grid that snaps to the framerate. This is not even noticeable though; it's better this way. If anyone find any problem, please let me know.
msg130 {
gragland[+],
posted: 05.23.04 2p•-,
top [^]
}
Awesome! Fixed the problem as well as a similar problem that heppened to my nav.
Thanks so much!
msg131 {
ephraimt[+],
posted: 05.24.04 2a•-,
top [^]
}
And you solved my synch problem too! Thank you so much!
msg132 {
gragland[+],
posted: 05.25.04 6p•-,
top [^]
}
I just wanted to mention, there are still some very minor sync problems.
If you go here: http://ragland.tk/ and go to "weddings>intro", and then to "about me" you can notice that the seams at the corner becomes visible a little bit. It's not a big deal at all.
I may be wrong (I did notice it but very slightly), but I'd bet it's happening because of the way Flash itself handles graphics; meaning that, even if both graphics (corner and middle, for example) are exactly positioned, it'd still show holes where there's none. For example: the corner is x = 0.4 and width = 5, and the middle is x = 5.4... it's correct, but since the corner end and the middle beginning are on a non-rounded position, aliasing ends up being miscalculated and creating seams. I've noticed that several times with boxes perfectly aligned to one another, simply because they're not on perfect (rounded) pixel coordinates.
Of course, I may be wrong on that and there may be some calculation error. I'll do some numeric testing later to see if there's anything wrong with the end values themselves (ie, middle piece's X should be the corner X + the corner width, on my example).
msg134 {
wired[+],
posted: 06.10.04 4p•-,
top [^]
}
Has anyone noticed that any of the tweening functions are rendered useless if you are loading an .swf (which contains these functions) into a blank movieClip?
wired: why? unless you're loading from different domains and not setting allowdomain correctly (ie, you're trying to control a loaded SWF from a non-local url from within the flash IDE and haven't set allowdomain), it works. otherwise, it doesn't, since one movie (loader) can't control the other (loaded) in any way.
msg136 {
wired[+],
posted: 06.10.04 9p•-,
top [^]
}
Zeh-
Thanks for your response. I'm not really clear on the autoDomain aspect you mentioned. However, I can tell you that both files will exist on the same directory level and on the same server. Can you take a look at an example? I really appreciate it. Your protoype is an amazing piece of work.
msg139 {
zeh[+],
posted: 06.11.04 11a•-,
top [^]
}
Uh, it still isn't working.. the domain isn't resolving, as if it never existed. It's registered (the whois on the domain returns valid information) but I just can't see it. Can you send me the server ip or send the files to my email (z [AT] zeh.com.br)?
msg140 {
wired[+],
posted: 06.11.04 12p•-,
top [^]
}
Zeh-
Sent to your email. Thanks.
Wired
msg141 {
wired[+],
posted: 06.16.04 11a•-,
top [^]
}
I know that it has been touched upon briefly here and there in this thread concerning the elastic and bounce functions. No matter what I do, I am unable to affect or alter the rate of elasticity by using the extra1 and extra2 variables.
Can you paste a line of code that works here?
Thanks Zeh. .
msg142 {
just_name[+],
posted: 06.18.04 1p•-,
top [^]
}
Hi,
I’ve got a conflict going on and I wondered if anyone can help me sort it out...(working in MX btw)?
All my tweens have been working perfectly and I just love the prototype!!! However this one is giving me grief and behaving very oddly… I have an MC with attached AS which works fine both when I preview from the actual fla and when I’ve loaded the swf into its container MC on my main stage. Now when I try to tween it into position using the following code, it goes all funny:
The code on the MC to be tweened is a drag function (among other things). The drag function and _y tween work fine when I preview the fla, but when I test the swf in its container MC it appears to ‘drag’ the mc to the specified _y position and then lets it spring back (which is part of the MC’s code – but should only work on mouse drag, not on _y tween).
I wondered if it was something to do with the path I’ve used (above), but then I’ve also tried writing the complete path and I get the same effect. Is there some other conflict going on that I have missed?? Anyone got any ideas??
Many thanks in advance!!
msg143 {
just_name[+],
posted: 06.20.04 6a•-,
top [^]
}
Just discovered another problem... I want to play a sound during a tween - does anyone know how best to do it? I wasn't sure how to do it during the tween, so I tacked it onto the end of the previous tween, using the following code:
But it doesn't work, what am I doing wrong? The sound works fine when I attach it to a button, but not during a tween (even if I change the path) Can sounds be played during tweens (I couldn't see any reference to it here)??
Can anyone help??
Cheers!!
msg144 {
just_name[+],
posted: 06.22.04 7a•-,
top [^]
}
addition to previous comment...
Sorted out the sound problem...opps, my mistake - sorry! Still having the same problem using the tween _y on animated mc. I've tried it using slideTo and got the same effect - stretches the movie but doesn't move it into position.
First: I have updated mc_tween to version 2.16.14. This adds a few optimizations I've been thinking of adding a while ago (better, more natural movieclip colorTransformTo handling, and better textfield colorTo handling) and, much more importantly, it fixes an error pointed out by Martin Klasson on the flashcoders list today: multiple colorTranformTo calls weren't working like they should (in sequential tweenings). The new ones were overwriting the current ones. It has been fixed now, and the code is a lot better.
Because of this, and because of a few other optimizations, a part of the code (that handles the special __special_*__ variables) will look weird because they're very similar lines. It could have been better looking with a nifty ["ra", "rb", etc] array, but it's faster this way. Since it has to check the variables on every property value update, it was important to make it as light as possible. So please bare with me and let the code be this way. :)
Also, since the code was optimized, the compiled bytecode is actually 4.53% thinner (from 3947 bytes to 3768 bytes)!!!! Yeah, I know, just kidding.
You can easily install the MXP extension from this link. More information here too.
Second: wired, did you get the email I sent you with your fla a few minutes after you sent me it? I haven't heard from you since. It was a bug on the way you called the movieclip (you were referring to a nonexistant _root movieclip), so it wasn't a tween issue. Let me know if you haven't received it, I can send it again.
Third (#142): the important thing about the extra elastic and back properties is that you have to use small numbers on it since the equations are calculated using radians. Most of the times you'll have to use low values so you just have to experiment with it until you find what does what. The source code has some explanation on that - I've mantained Robert Penner's comments on the equations but I agree most of it is black magic, as I don't know exactly what kind of values it uses. I know that extra1 for back can alter the ammount it goes back, but extra1 and extra2 are still strange to me. I have been able to change the way the curve works on this case, but not much, it just kinda breaks and make a boring expo-like line.
Bounce doesn't take extra functions.
Here's an example of how BACK works, though. It's a comparison between two balls (place a movieclip called ball1 and another one called ball2 on a flash document and run the code).
Fourth: (#143, #145): just_name, it's for for anyone to say without seeing the actual code. But I'd bet its some simple syntax mistake somewhere.
And fifth (#144): well, to play a sound DURING a tween, you just start playing it when the tween starts (on the same code, separate from the tween itself). It'll start the tween and start the sound. Using callback should play the sound at the end of the tween so probably it's not what you want.
msg146 {
stellarid[+],
posted: 06.23.04 9a•02.23.06 11a,
top [^]
}
hi everyone,
i got following problem:
im including the tweening prototype in my main movie. in external (loadmovie) clips i use tweenings as follows:
these clips are just a kind of slideshow thing. the preloading routine works also very well. it plays the clip when its loaded. the trouble is when i click the next slide to be loaded, sometimes the tweening of the loaded clip kind of overlaps. as you see the above code lets an mc bounce down and after a while it goes up again. when i click the next slide while the mc goes up its shure the next slide has overlapping tweens.
i tried to reset the tweens on the beginning of every slide (stopTween) without success.
is the problem when using external clips which contain tweened mcs with the same instance name? the container which is used for loading the clips should be replaced when another is loaded, right? how can i "kill" pending tweens? are there some overlapping controllers? please help!
msg147 {
zeh[+],
posted: 06.23.04 10a•-,
top [^]
}
I don't think I've understand the entire scope of your problem, but stopTween() is really the method used to kill tweens.
msg148 {
just_name[+],
posted: 06.23.04 12p•-,
top [^]
}
Fourth: (#143, #145): just_name, it's for for anyone to say without seeing the actual code. But I'd bet its some simple syntax mistake somewhere.
Good point Zeh! Sorry - wondered if there there might be a simple answer… Okay, code – here goes:
The animated mc gets loaded into contentMC on the main stage, it’s position is:
_level0.all.content.
Code to position animated mc, located in swf to be loaded (works correctly when previewed in flash)
:
questionMC.tween ("_y", 37, 3, "easeOutElastic", 2.5);
The animated mc to be moved is broken down as follows:
_root.questionMC.(invisible button)
The swf to be loaded contains all the code to control the animated mc:
The code on each of these mcs is as follows and works fine when previewed in the main movie via a browser:
When this code gets loaded into the main movie, the tween function stretches the mc and then releases it, but does not change it’s original starting position. The code on the animated mc makes it go all wobbly when the user drags it, so I guess this is the part that causes it to stretch, but why does it stretch and not move?? I’ve tried writing the full path to move the animated mc, thinking maybe it was getting confused which level it was on, but that didn’t make any difference. You’re probably right that it’s something about syntax, but I don’t know what… :(
just_name: Thanks for the code, but it's still a bit hard to understand.
If you haven't fixed it yet, send me the source files and I'll look into it. Email is z (AT) zeh dot com dot br.
msg150 {
Saitedoh[+],
posted: 06.30.04 10a•-,
top [^]
}
Hi Zeh, have a question you (or someone out there) might be able to answer. I am wondering what the best method for this situation would be. The situation is this : I have multiple clips tweening from point A to point B. I want to be able to hault all the tweens with a command (stopTween()) simple enough. I then want to be able to start those tweens from where they where stopped from as if they had never stopped. Any suggestions? I have made a simple diagran to illustrate what I'm doing
X------>X------>X
A B C
Clip starts at A
On mouse press clip moves towards C
User hits mouse at point B and tween stops
User hits mouse again and clip proceeds to C
Thanks in advance
msg151 {
Saitedoh[+],
posted: 06.30.04 11a•-,
top [^]
}
I figured out my own problem.. for those who are wondering how to "pause" a tween the method I found was this...
record the starting distance to the target tween location and time
begin the tween
on mouse down stop the tween
when it resumes the tween calculate use a proportion equation to calculate how long the remaining tween should take
for instance
ClipMC starts at 0, 0 with target tween 200, 0 for 10 secs
say your clip travels to 50, 0 and the person stops the tween
when it starts again you can calculate the new tween time by doing
distanceLeft*initialTime/destination;
thus (200-50)*10/200 = 7.5 secs on the new tween.
If anyone has an easier method, lemme know!
msg152 {
laco[+],
posted: 07.04.04 3a•-,
top [^]
}
hi Saitedoh,
try this link to similiar proto http://proto.layer51.com/d.aspx?f=1165 and copy the code from msg #2, and then you can use for pausing all running tweens function:
$tweenManager.pauseAll()
msg153 {
BrianWaters[+],
posted: 07.17.04 12p•-,
top [^]
}
I've been using the mc_tween prototype for some time now (it's FANTASTIC!), and just noticed a little issue: in Flash MX 2004, when the Publish Settings are set to output a version 7 SWF file (either AS 1.0 or 2.0), the various "elastic" easing equations don't function properly. For example, if a movieclip's _x property is tweened, the clip just appears at the new position at the end of the specified duration, with no visible intermediate steps and no visible elasticity as well.
All other animation types work as expected, and if I set MX 2004 to generate a version 6 SWF file, the "elastic" animation types work again. Is this a known issue, or is there a fix? I'm using the latest mc_tween version, 2.16.14. (I'm also aware of various AS2 tween classes, but would like to continue with Zeh's prototype for now.) Thanks!
BrianWaters: um, it looks like it has something to do with the fact that it wouldn't work on flash 7 if the amplitude parameter (extra1) was missing -- it'd think !(undefined < (anyvalue)) while flash 6 would behave differently. Penner has changed that on his equations when he ported them to as2 (he verifies if amplitude is undefined before verifying if amplitude < (anyvalue)..) so I replicated that on the equations I used and got it to version 2.16.15.
Unfortunatelly, I don't have MX 2k4 at home :P So I can't test it until monday... but it's probably working.
I haven't updated the MXP installer yet as it's not a 'stable' release yet. Since I'm still working on the sound fading stuff too (yeah, I'm slow, I have so many other stuff to work on my spare time... I still have to skin an ut2k4 vehicle!) this fix will probably be added to the next mxp but it'll take some time (because, again, I have to finish the sound stuff properly).
msg155 {
BrianWaters[+],
posted: 07.17.04 6p•-,
top [^]
}
Zeh, the elastic equations are indeed working again in version 7 swfs. Thanks for such a quick update!
msg156 {
bitfactory[+],
posted: 07.28.04 3p•-,
top [^]
}
Zeh - am i missing the link to (2.16.15) ? have you released it yet?
msg158 {
bitfactory[+],
posted: 08.08.04 10a•-,
top [^]
}
great, thanks zeh!
msg159 {
bitfactory[+],
posted: 08.08.04 11a•-,
top [^]
}
zeh,
i'm really interested in running functions within the tween like discussed with wazungu above.
is there any way of doing this without running a tween?
in other words, my line is:
mask.tween("_x", -376, .2, "Linear", .6, function() { gotoAndPlay(_level0.whereami.model); } );
which is really just me waiting .6 seconds before going to and playing the value of _level0.whereami.model. the actual tween is just a waste there, though - is there anyway of calling the delayed function without having to use the tween before it?
did that make sense? ;-)
msg160 {
laco[+],
posted: 08.08.04 12p•08.08.04 12p,
top [^]
}
bitfactory, use flash built-in setInterval or setTimeout
http://proto.layer51.com/d.aspx?f=640 setTimeout(function() { gotoAndPlay(_level0.whereami.model); } , 600);
msg161 {
bitfactory[+],
posted: 08.08.04 12p•-,
top [^]
}
thanks laco -
couldn't get setTimeout to work for the life of me...
but i was able to get setInterval to work as long as i cleared the interval...
function wait() {
gotoAndPlay(_level0.whereami.model);
clearInterval(myTimer);
}
myTimer = setInterval(wait, 600);
the setTimeout function would just not work correctly... weird.
thanks again...
msg162 {
zeh[+],
posted: 08.17.04 11a•08.17.04 11a,
top [^]
}
// not blury
your_mc.tween(["_rx","_ry"],[500, 200],1)
msg165 {
elchangito[+],
posted: 11.15.04 1a•11.15.04 1a,
top [^]
}
This is working great for me! Thanks for posting. Is there any kind of comprehensive list of all the built in functions/parameters or is this best found by searching through the code?
msg166 {
petsounds[+],
posted: 11.17.04 3p•-,
top [^]
}
Great tween methods. I'm having problems with the alpha tweening, though (using version 2.17.15). For instance, tweening a mc which contains a bitmap from 0 to 100 often causes the mc to increase in brightness, and often it won't even finish tweening all the way.
elchangito: reading the code would be the best. it's all commented there with examples.
petsounds: that's strange. first because an alpha tweening actually works, and second because it always finishes the tweening normally no matter the computer speed or processing power.
if you're having weird colors on an alpha tweening, I'd say it's usually because doing an alpha tween on flash is always applied to all objects on a movieclip, not on the movieclip itself (so if you have a completelly hidden black box below a white box, tweening the movieclip to alpha 0 will always result in a grey tween because the black box will be shown).
regarding the tweening not actually finishing, it's either something that's stopping the tween before it ends with stopTween() or something that is changing the movieclip's _alpha after the tween has ran.
from time to time, I have had several problems with the tween extension that I work hard to finish as soon as I notice then (although it still has some other optimization issues I want to address), but not finishing tweenings or doing incorrect alpha transitions have never been one of them.
msg168 {
octoc[+],
posted: 11.20.04 11p•-,
top [^]
}
Hey Zeh,
Firstly I would like to thank you for the great prototype. I've been using it for 6 months and it works great for me.
Although recently I came across a problem when orking on my dynamically generated box-engine as I call it. I've noticed that when generating bigger number of boxes, your tween slows down the performance dramatically. I'm not sure if it's the way how i use it or there might be another way by stop tweening...If you could find a minute to have a look what i'm working on and give some feedback or possibly asolution, it would be greatly aprreciated.
msg169 {
zeh[+],
posted: 11.21.04 4a•11.21.04 4a,
top [^]
}
Martin,
All tweening engines have a problem when starting tweening way too many properties on too many movieclips at the same time. This was one of the issues I tested the most and while I am still able to get flash player to slown down to a crawl with my testing movies, I think this would hardly be the case with that example...
I ran your compiled movie... from what I've noticed, it's running smooth here, but maybe it's because of my computer (p4 2.55) and because I'm using Flash Player 7. I couldn't do a fps measurement, but I didn't notice any real slowdown.
I don't see any problem on your code either; you're only tweening the properties that need to be tweened, and it should be working alright.
Sure enough, if you had a very big number of squares (I think that's what you meant), performance would really suffer. I don't think there's much to be done in this case; you may test it with other tween engines, but I think it'll be difficult to get much faster.
In cases when I need that kind of behaviour - one asset getting bigger and the other ones getting smaller, like on animated menus - I usually do a little trick... instead of tweening every item's width/height and x/y where needed, I just tween the width/height and then I create an onEnterFrame() function that re-position all movieclips based on their sizes.. like he puts box 1 on the left corner, counts 10 pixels, puts the second box on that position, counts 10 pixels, etc. When the tween function ends, the onEnterFrame function is deleted.
Maybe that wouldn't help that much on your case, and it can easily transform your code into a mess if not done well. But it's just something that I felt like pointing out since that's what I use myself.. not because I've ran into huge slowdowns with my tween (when I'm in a hurry I do all by tweening), but because I know it's cleaner and faster this way.. and since I do websites for mac players too, I need all processing out of my flash movies.
msg170 {
octoc[+],
posted: 11.21.04 4a•-,
top [^]
}
hey Zeh,
Thanks for the fast reply. I did try with other engines (laco) and came across the same problems. In the ammended expample, whene run it with 16 boxes, it works fine on most machines...but when increase it to 26 or more, the problem starts.
Anyway, I will definitely try split it with onEnterFrame, we will see what happens. Thanks, anyway.
cheers, M.
msg171 {
ass[+],
posted: 11.22.04 11a•-,
top [^]
}
hi zeh, im newbie in as1 scrpt, so im think if you post a tutorial for the newbies like me , please.
ass: I'm finishing up a new MC Tween website with tutorials and better documentation/explanation. Should be up soon.
Basically you just need to include the tween file,
#include "mc_tween2.as"
Then use the 'new' commands. Like
myMovieClip.tween("_x", 10);
msg173 {
rdoyle720[+],
posted: 11.24.04 2p•-,
top [^]
}
It looks like you answered this above, but it'd be really handy to be able to pass the color set Transform tween an object rather than specifying values.
msg174 {
elchangito[+],
posted: 11.24.04 7p•-,
top [^]
}
So even after digging through the code, its not that clear to me what all the possible parameters are, and I want to make the most of this.
Is it me or does almost all of this documentation apply to your code?:
rdoyle720: thats a good and simple idea. I'll add it to next iteration; although it's really simple, I don't want to simply paste it now and cut my current on-work version in half.
elchangito: more or less. this is the help to laco's version, and while the *syntax* was inspired on my mc_tween, it's a different extension. Most of the descriptions apply, but not all.
msg176 {
hsoares[+],
posted: 12.06.04 12p•-,
top [^]
}
hello
My question is very simple.
Can i make a menu in xml and make a tween alpha in the menu?
hsoares: yes, of course. However, remember this: this tweening extension is only related to, well, tweening. It won't read a xml file, it won't create your menu dinamically, it'll only animate your menu items on whichever ways you can think of. Actually, I think half of my time using this extension is used for animating dynamically created menus at my workplace. Most of the rest is done with slideshows I guess. :)
msg178 {
hsoares[+],
posted: 12.07.04 3a•-,
top [^]
}
hugo: I can't say without seeing any code. I can say there's 99.9% of chances it's not mctween-related.
Mail me at z [AT] zeh.com.br so we can check that easier (and in portuguese if needed) without using this comment system for chatting.
msg180 {
hsoares[+],
posted: 12.07.04 8a•-,
top [^]
}
ok,
Thanks i will send this to you.
hugo
msg181 {
takemeaway[+],
posted: 12.12.04 11p•-,
top [^]
}
Hi Tweeners!
I wonder how to solve this using Zeh's tween class.
I am having a bitmap in which I want to use brightness to..
it will go to be white... and later it will tween back to
its original look.
I tried using the brightnessTo prototype that was suggested by Zeh,
but it doesnt work, perhaps there is something wrong in it..
but it doesnt work.
I thought I would use the .ColorTo instead of the .tween, so I could color it
to white.. but I wouldnt know how to use colorTo to tween back to the original one..
So please do tell me the solution you happy tweeners!
// mk
msg182 {
takemeaway[+],
posted: 12.13.04 12a•-,
top [^]
}
Now it works!
I used colorTransformTo now, and it works as sweet as it should..
I know why it didnt work for me the first time..
-I was to quick with the copy/paste
The help-comments under the colorTransformTo is calling the colorTo-method,
though with paramaters suiting for the colorTransformTo.
Sorry for not noticing that until after my previous comment..
but now Zeh probably knows about it anyways.
Thanks and bye for your time.
msg183 {
zeh[+],
posted: 12.30.04 5a•12.31.04 5p,
top [^]
}
takemeaway: now that's funny! I noticed that comment error *yesterday*, it must have been wrong for over a year now, hah. It's fixed now, thanks.
ANYWAYS. I finally finished the new version of MC Tween - 2.19.23. Nothing fancy, just a bunch of mini-changes, some fixes, and some minor near-stupid shortcuts additions. Oh, colorTo() also accepts a null parameter (resets the color) and colorTransformTo() can accept one single colorTransformObject as a parameter too (as suggested by #174). The biggest change, for me, was the redesign of the tweening deletion handling. It made the code a bit more organized and fixed some variable leaks on speacial tweenings (color, sound, etc). Again, nothing very fancy. I've tested it and it seems to work fine, but let me know if anyone finds any mistake - I'm always afraid after deep changes like that...
The biggest news is that now I've finished the new mc tween website, complete with help/documentation and some ultra-simple examples to download.
destro800: I usually do that using a callback. For example, let's suppose I want my current timeline to stop, animate some stuff on screen, and then move on. I usually do it like this:
Since the callback is called after the last animation ends, you just need it to tell the movieclip's _parent (that is, the movie timeline itself) to move on.
msg186 {
destro800[+],
posted: 01.03.05 8a•-,
top [^]
}
Thanks for the fast reply!!!
Ok, why are you saying undefined in there instead of just skipping the argument?
Because using undefined is the only way to skip arguments within Flash. Differently from other languages, you can't do this in actionscript:
doSomething (1, , 2);
If you need to skip the second argument, you have to do this:
doSomething (1, undefined, 2);
msg188 {
ass[+],
posted: 01.03.05 11a•-,
top [^]
}
wow man im shoked!! , just thanks for the help! im just a playing with my favorite toy!!!
yahooooooooooo... sorry
thanks buddy!!!
msg189 {
rdoyle720[+],
posted: 01.03.05 1p•-,
top [^]
}
2.19.22 works for me, 2.19.23 introduced a bug into a movie I'm using it on.
Basically I have code that drops a bunch of cubes, and when you click a new menu item all the current cubes fly up, and when that finishes, a new set of cubes falls. It appears that stopTween() isn't working correctly. If I comment out my stopTween() action, 2.19.22 works the same way as 2.19.23.
msg190 {
zeh[+],
posted: 01.03.05 2p•01.03.05 4p,
top [^]
}
Thanks for the fast check rdoyle720. I just noticed it a few hours ago, and already fixed it -- 2.19.24, I'm just testing it a bit more and will upload and add it to the site soon. There was an issue when using stopTween with no parameters - it would delete all references to the tweens of a movieclip but not the tweens themselves, so a tween followed by a stoptween with no parameters followed by another tween on the same property would incorrectly perform the second tween but later revert to the final value of the first tween.
EDIT: changed and uploaded. I've tested on my own test stuff and it seems to be good, so hopefully it's working fine.
I might as well start some longer beta testing in the future when changing stuff that changes the way it works so much.
msg191 {
rdoyle720[+],
posted: 01.04.05 6a•-,
top [^]
}
New version looks like it works, thanks!
msg192 {
Dario[+],
posted: 01.14.05 2p•-,
top [^]
}
Hey guys,
COOL Prototype!
I'm quite new at this but have succeeded on my first try :)
Now, on to the second and more complicated effort, I'm failing :(
My goal (a pop up menu system) is to alpha tween a background rectangle from 0 to 100% AND, at the same time color tween some text that's on/in the rectangle from 000000 to 990000. This would occur on a mouse/roll over. The opposite would then happen on a mouse/roll off. Not too hard, or so I thought. (Eventually I'll have submenu items pop up on the roll overs but I can't even consider that until I get past this.)
Here's what I have:
An instance of a movie clip (homeMenu_mc)-the rectangle.
This mc contains a child mc (home_mc)-the text.
On the instance I have this AS:
onClipEvent (load) {
All the code works execpt the
home_mc.colorTo(0x990000, 0.5); and home_mc.colorTo(0x000000, 0.5);
I can get the colorTo to work (independantly) but not when coded like this (referencing a child mc).
So, that's the problem: how would I reference a child mc in this situation?
The 'correct' way to refer to it would be this.home_mc.* . However, since your function is getting called from inside the movie itself, there's *no* problem in using home_mc.* , it will work just the same.
To me, it looks like either it's working and you can't notice it (because it's working at the same time the parent movieclip itself is appearing, you would barely notice a color change on a child movieclip inside of it), or there's some other issue with the names. Try this: instead of doing home_mc.colorTo(etc), do
trace (home_mc.colorTo);
If it traces to "[type function]", it's because the reference is correct, the movieclip exists, and the method exists - there's no reason for it not to work. If it doesn't, there's an scope issue and it can't find the child movieclip, so double check the instance name.
If it works, try adding a delay to the colorTo function. This way it will only change its color after the parent movieclip has already faded to 100% opacity and it will be easier to spot if it's working. Also try adding a delay to the alphaTo on the rollout function - this way, it will also wait for the colorto to end before fading back to transparent, and again making it easier to spot the color fade.
- zeh
msg194 {
Dario[+],
posted: 01.14.05 7p•-,
top [^]
}
Thanks Zeh,
Well I added the trace and I get [undefined]. Strange that the trace only reveals when I roll over the 'box' that I'm doing the _alphaTo on. It displays nothing at all when I roll over the home_mc. This is what I put in: trace (home_mc.colorTo); The mc is named home_mc and its instance name home_mc is as well.
I do however see the color change in home_mc now.
The mc (a mc of the word 'HOME') changes to red (#990000). The box mc (homeMenu_mc) only alpha tweens when I roll over the part of the box that is not covered by the home_mc. So, I can't get both to change at the same time.
I wonder, would I do this better by creating a transparent 'box' over both mc's and using that for the rollOver and rollOut?
Wait, so you have onRollover functions on home_mc? There's some other issues then. And if it's yelding undefined, it's because your mc doesn't exist at that position and the scope is actually wrong.
Mail me off this page - use the address z [AT] zeh.com.br - with a simple version of your fla if possible and I'll tell you what's wrong and what to do to fix it.
msg196 {
Dario[+],
posted: 01.14.05 8p•-,
top [^]
}
Thanks again for the reply and the offer of help.
Well, whatever you said in the last post got me thinking.
It turns out that I had not named the instance of home_mc within homeMenu_mc!
Man do I feel like an idiot :(
I guess that's what happens when you set this aside for 6 months huh.
So, rather than clog your server with another 5k of useless info, I'll leave you with my thanks and appreciation.
msg197 {
clandestin0[+],
posted: 01.18.05 9a•-,
top [^]
}
hello zeh,
your tween library made life a lot easier. thanx a lot for that great work.
i just wanted to let you know that i found it useful to replace your _alpha tweening by senoculars _opacity prototype as seen on http://proto.layer51.com/d.aspx?f=973 . the effect is, tweening opacity to 0 or below will set _visible = false . just a minor suggestion, maybe you find it useful, too.
greetings
msg198 {
Dario[+],
posted: 01.22.05 5p•01.22.05 7p,
top [^]
}
Hi Zeh,
Well I'm still having problems with my fla.
I made some changes to the format which seems to have broken the fix I managed earlier.
At this point I have a parent mc (Training) which contains a child (Nehemiah). The parent tweens work but the childs don't. When I put the child (Nehemiah) on it's own, it works fine.
this.nehBut_mc.onRollOver = function() {
this.hlButN_mc.alphaTo (100, 0.5);
this.hlButN_mc.colorTo(0xffffff, 0.5);
neh_mc.colorTo(0x990000, 0.5); (? I'm not sure where is this)
}
Send me the fla (z AT zeh.com.br) and I'll have a better look. It's something quick, don't worry.
msg200 {
Dario[+],
posted: 01.23.05 8a•-,
top [^]
}
I spent 9 hours yesterday trying different permutations, seriously. Without a doubt it's something like a missed "." or instance name. I just can't see it anymore. Clearly the tweens work but not when I'm targeting the child or the child of a child. Arrrgh!
So, I'll e-mail (with great appreciation) and title the e-mail 'Frustrating Tween."
msg201 {
raulzzito[+],
posted: 01.28.05 8p•-,
top [^]
}
aim tráim tu taipe in ín-glich!
hehehe maybe only zeh will understand that...
my english is sUx
your mc tweening is the opositte zeh!
tks fellow (or fAllow?)
hey, let's just keep in touch...
carrasco
msg202 {
Grimace[+],
posted: 02.18.05 1a•02.18.05 2a,
top [^]
}
Maybe I haven't read the 202 comments too well (the term callback comes back quite a lot), but I have a remark about the callback.
From what I can see, the callback (objProp._callback) is done just before the animation properties on the tweened object are set. This means that in the callback, you cannot use the final tween values from your object (which I'm doing in an animated menu that expands another menu right after it's sibling collapsed).
Do I see this wrong, is this not an issue, or does anyone agree this is wrong?
msg203 {
zeh[+],
posted: 02.18.05 3a•02.18.05 3a,
top [^]
}
Grimace: the callback is ran after the last update.
If you're having some problem getting it to work, well, it's hard to say what's wrong with your code without seeing it, but much probably it's because you're calling the function instead of passing it as parameter. Remember it's this:
The latter will simply call your function and pass the return value as a parameter to the tween, that is, pass no callback at all.
msg204 {
Grimace[+],
posted: 02.18.05 4a•-,
top [^]
}
Hmm... thanks for the quick reply.
I guess you know your library best, so I you're probably right: my code might be wrong at some point :)
I'll have to dig into this to get to the actual problem. Right now, I have the full dynamic hierarchical menu working with your tween lib (swell stuff!). Only, to get around the error I experience, I have built in a stub callback in my own code that introduces a short delay, and subsequently calls the real callback.
Hmm.. come to think of it, regardless of my problem, would a post-animation-callback-delay make a nice feature? :)
Well, stub callbacks would be one of the easiest ways to solve this. The reason that mc tween doesn't have anything like this builtin is because rather then a timeline controller with the feature of firing functions on whichever time you want, it is supposed to be just an extension for creating property(ies) transitions - anything more than that would just stray out of its focus. I prefer people to use whichever kind of method they like for their delayed functions.
When I need something ran after callbacks myself, I use some other simple time controlling code to fire events after some time. As in,
The 'triggerfunction' function I use is this, just an one-time setInterval, like setTimeout on javascript:
On the other hand, I'd like so see what kind of code you're using, because if you're doing some call on the callback and the property doesn't have the value it's supposed to have, something unexpected might be interfering with the tweenings and I'd like to know what it is. If you want, mail me at z [at] zeh.com.br with the code and I'll look into it.
msg206 {
zeh[+],
posted: 02.19.05 3p•02.19.05 4p,
top [^]
}
* Added pauseTween() and resumeTween(). Pretty self-explanatory. They work for one property, a series of properties, or all properties of an object.
* Added onTweenUpdate() and onTweenComplete() event handlers, also pretty self-explanatory. They're called once for each property!
* stopTween() now also accepts several properties as a parameter (doesn't need to be an array).
* Added "outin" animations too (so, besides easein*, easeout*, and easeinout*, you also can use easeoutin* now). This is kind of weird, but some of them are actually usable. Oh, and non-valid animation types now trigger a warning message.
* Compiled code size shrinked from a huge 6.1kb to a tiny 5.3kb. WOW!
msg207 {
mshaheen[+],
posted: 04.22.05 11a•-,
top [^]
}
The pause tween is great, but is there a way to pause/resume ALL current tweens?
msg208 {
zeh[+],
posted: 04.27.05 1p•04.27.05 1p,
top [^]
}
mshaheen: hm.. good question. Officially, no, but this would do the trick:
I just wrote this now and haven't tested, but it should work.
Maybe I'll test it out and add it to the next version.. there's a way to pause all tweenings on all objects more efficiently (on a lower level), but I think having the ability to set the nest of objects you can pause (the first in the tree) is a good enough reason to do it at this 'higher' level, just reusing the pauseTween() method.
msg209 {
mshaheen[+],
posted: 04.29.05 9a•-,
top [^]
}
now that I've seen it, it seems so simple. thank you. but, the typeof comparison is case-sensitive, and will the typeof ever be "TextField"? I think textfields return a value of simply "object". So, I'm wondering if the edits I made to your script will have any negative effects that you can think of.
msg210 {
zeh[+],
posted: 04.29.05 8p•04.29.05 8p,
top [^]
}
Oh yeah, good call. My mistake(s).
Your versions will work fine. However, in this case, they'll try stopping *any* object at all, it'll just skip strings and other simple variables; it'll fail when it tries to do a pauseTween() on an object that doesn't have a pauseTween() method, so in the end it will just *try* calling the method a few more times.
In this case (since my original code had the typeof flaws), it's better to just check instanceof instead, as in
New version, 2.26.67. This has been done for a while but I hadn't released yet because I didn't have the time to finish the new methods' documentation. Since this fixes a nasty bezierCurveTo() bug, though, it's already public.
msg212 {
loveguitarncomp[+],
posted: 05.08.05 4a•-,
top [^]
}
Hi Zeh,
Excellent prototype, it gives me the complete flexibility to do things in Flash which I could never do before. Although I just have one question... Let's say if you want to tween a box_mc clip on root from 0 to 100 on _x upon click of a button and then execute a callback function ondone. The problem is that if the box_mc is already on 100 on the _x axis, there is a delay of "x" seconds. This "x" seconds is the same time that we had defined to move the box_mc on _x axis..how can we work around this.
What MC Tween does is completely ignore the current position of an attribute; time is passed as an absolute parameter. Its function is fairly straightforward: it sets the new value (starting from the current value) in the desired ammount of seconds. If you want to do an animation with the same speed indendently from the starting point - meaning an animation from 0 to 100 would take <x> time, from 100 to 100 <0> time, and from 50 to 100 <x/2> time - it's up to developer to implement such functionalities to the code. I think this is beyond the MC Tween scope and would only lead to confusion.
In your case - if I understand what you want - the solution would be something like
var timeToSpend = Math.abs(myMC._x - 100)/100;
myMC.xSlideTo(100, timeToSpend);
This would ensure that it'd take 1 second of time for each 100 pixels it's distant from the desired X position (100). 50->100 would take 0.5 seconds, 300->100 would take two seconds. This is the best way to achieve regular constant speed based on ammount of change needed.
In the same vein, if you just want to check if the MC is already at the right position, you just need a simple check.
if (myMC._x != 100) myMC.xSlideTo(100, 1);
HTH,
zeh
msg214 {
loveguitarncomp[+],
posted: 05.09.05 1a•-,
top [^]
}
Hey Zeh,
Thanks buddy. This solves the issue for sure...btw...I had tried passing the time parameter as a variable in past but had no luck....let me try this time...
Cheers,
Dhaval
msg215 {
petsounds[+],
posted: 07.13.05 11p•-,
top [^]
}
hey zeh,
So for a long time (since the early v1 days when it was still called ztween), I've used a modified version of your script which adds a callbackRef parameter to the tween method. I did this so that I could pass in any object reference and call them when the tween is done, not just the tweened clip itself. I used this line of code to replace your calling code:
this._callbackRef[this._callback]();
That way I can do stuff like:
--------------
MovieClip.prototype.fireMissile = function (callback_mc) {
this.tween("_x", end_x, time, "easeOutCubic", 0, "onMissileHit", callback_mc);
}
asteroid_mc.onMissileHit = function () {
this.destroyMe();
}
// this will tell the asteroid to blow up
spaceship_mc.fireMissile(asteroid_mc);
-------------
Now I know you've tried not to get too complicated with the options, but I feel like being able to call another movieclip is pretty useful (unless I've overlooked some way to do it with your current implementation).
Once again, great work on this stuff.
msg216 {
petsounds[+],
posted: 07.15.05 12a•-,
top [^]
}
Oh, to clarify, the above code is what I used in your v1 code.
This is what I use in the v2 mc_tween:
if (objProp._callbackRef == undefined) {
// no callback obj reference was passed in, so just use the normal callback behavior
objProp._callback.apply(objProp._targ, null);
} else {
// here's my code which allows for a callback object reference
objProp._callbackRef[objProp._callback]();
}
msg217 {
loveguitarncomp[+],
posted: 07.19.05 1a•-,
top [^]
}
Hi,
While we are at it...is there any way we can pass parameters in the callback function.
Whenever anything is tweened, I then want to use the callback function with the parameter...is that possible...? Another issue, currently I have the below function in the root timeline
No matter where(any movieclip deep down) I call this function as a callback, it plays the _root timeline, how can this be corrected?
Cheers,
D
msg218 {
atif[+],
posted: 08.28.05 8a•-,
top [^]
}
I use Zeh's work on almost all of my sites. I am looking forward to making some flash components and was wandering if I could use these functions in those components, anyone, please suggest some pros ad cons of using this stuff in MXPs etc. and how shud i package the file "mc_tween2.as", Thanx!
Atif: your best choice would be to copy the prototype source (the .as file text itself) and paste them inside your component. That way, you wouldn't be dependent of external files or including, so the user could simply copy the component from one .fla to another and it would still work.
This would also give you the ability to cut down on byte usage, because you would be able to strip out the mctween methods or functions that you didn't need. Not that ~5kb per compiled SWF is a lot, but anyways...
msg220 {
booga[+],
posted: 09.06.05 8a•09.14.05 9a,
top [^]
}
in msg 2 you gave a sortof 3d example but not the source. i could not find this example on your site either. any chance of posting it here?
msg221 {
zeh[+],
posted: 09.06.05 10a•-,
top [^]
}
It's not that public because the source is a mess (and the tweening is used on the camera movement only, it's pretty straightforward). Anyways, the code is adapted from an old '3d' engine of mine I've done on 1994 in QuickBasic 4.5. That alone speaks a lot about the lack of organization of the code. It was just a test/prototype anyways.
msg222 {
wired[+],
posted: 09.09.05 8p•-,
top [^]
}
Zeh (or anyone else in the know)-
First off - your prototype is invaluable. I think you so much for its creation.
Is it possible to use MCTWEEN alongside a motion guide? I want my animation to follow a certain animation path.
Can I do this with frameTo()? If so, just how do I go about doing that? Do I have to physically account for 20 frames in the timeline (that is have the symbol that i'm trying to animate occupy the entire 20 frames), do I have to use two keyframes for the beginning and end position?
Your help and guidance is greatly appreciated. i'm in a bit of a death crunch here!
Thanks!
msg223 {
zeh[+],
posted: 09.10.05 7a•09.10.05 7a,
top [^]
}
Wired, when animation on a motion guide, unless your position can be determined mathematically, the best solution would be to use frameTo().
In this case, you'd create a normal timeline tween using a line as a guide. Say it starts at frame 1 and end at frame 20. This is a standard motion tween, so you'd need a keyframe on the first and on the last frame, and use ease "0" on the motion tween you create on the timeline.
Then you'd make it gotoandstop(1) and use mctween to make it frameto(20). However, frameTo() is not a playback control, but rather a seek control; your frameto() tween will still respect the time you specified on the parameter, still using the same animation type, delay, etc. It will just "snap" to the correct frame depending on the time position the animation is at.
Because of this, unless you're using a linear animation, some of the frames will be skipped and some will be repeated. So I'd advise you to create a lengthy animation (say, 100 frames) so you can have a more smooth movement.
All this timeline animation would probably be nested on another movieclip, so doing a frameto() on it won't mess with your main movieclip timeline.
It sounds kind of complex, but it's easy and works fine in the end. I introduced frameto() when I needed it myself (I had a weird shape tween on the timeline that I wanted to control), and it worked wonders on my case, and I don't see a reason for it not to do the same for you.
seg: MC Tween works normally with Flash 8, I've just tested it. When installing it, just be sure to properly select "Flash 8" from the MM Extension Manager combo box, or else you'll just reinstall it on some previous Flash version. Depending on how your Flash installation has been done, you might have to download and install the MM Extension Manager, although it's unlikely.
You can also manually copy the .AS and .XML files to their respective locations, it's the same thing.
In a nutshell, it works as it should on Flash 6/7/8, on both AS1 and AS2, so there's no need for a 'special' version.
The only problem with MC Tween is that, when using it and compiling using AS2, the Sound object tweenings stop working. This isn't an error, though; AS2 doesn't let you extend non-dynamic classes by prototyping them, so there's no "fix" to be done. It's a paradigm shift; a 'fix' would require changing the syntax itself.
The other tweenings work because the other classes (Movieclip etc) are dynamic and can have methods added on runtime.
--
<personal_rant>
Personally, while I believe the main task I wanted to accomplish with MC Tween was successfully achieved - powerful and simple to use, one command only - I also believe there's not much to be changed from now on. In my opinion, when using AS2, another whole different 'format' is needed, to maintain the strict oop code "rules", let's say.
Because of this, I've been developing what I'm calling "zTweener" (for now) for quite a while; it's an AS2 "MC Tween like" extension, really simple to use and really powerful, but not relying on any kind of prototyping (at least not at author time, heh). It's not solid enough for public release yet though, but you can think of it as a "native" AS2 version of mc tween (a real class).
As usual, I develop this stuff mainly because I need them, so I'm not in a rush to release anything unstable that will be broken a few versions later. I'm already using it as my tweening extension of choice on my daily work though so I think it'll be cool enough soon, I think.
</personal_rant>
msg226 {
bitfactory[+],
posted: 09.14.05 9a•-,
top [^]
}
zeh - your tweening extension has been an invaluable tool for me over the past couple of years. I look forward to seeing what you have in store for 'zTweener.'
You rock.
msg227 {
astolitu[+],
posted: 09.17.05 6a•-,
top [^]
}
mc_tween doesnt work in flash 8, how to fix that?
msg228 {
astolitu[+],
posted: 09.17.05 6a•-,
top [^]
}
it works fine with flash 8,sorry, iam so stupid, anyway...tnx for mc_tween
msg229 {
rinse[+],
posted: 10.03.05 9a•-,
top [^]
}
Zeh: Is the new version that your are working on capable of tweening the new Flash 8 filters and modes? Blur, Drop shadow, etc... I think that is the only real way I could think of truly improving it now.
msg230 {
zeh[+],
posted: 10.03.05 10a•10.03.05 11a,
top [^]
}
Rinse: ..more or less. What I'm calling "ZTweener" for now is the new one I'm doing, and it's very early, but yes, I do plan to add filter tweening to it some day (right now it only does simple property tweening).
*However* I believe ZTweener and MC Tween are two different things... filter support is something I've been adding to MC Tween on the past few weeks and, coincidentally, it's finally ready for public usage.
Ok, onto it: I've updated MC Tween to version 2.27.28. This adds/changes a few things:
1. The syntax coloring/helper has been reorganized, specially regarding the menu positioning. Since Flash itself changes the menu disposition on each new version, I changed all MC Tween related stuff to a new submenu instead of trying to keep up with the 'correct' places for each object type. I recon almost no one uses this, but just in case, know it has been changed. Here's a screen grab of the new menu organization. Unfortunatelly, no, the help is still missing. I'm planning to make it available inside the IDE too... soon.
2. Now, creating a tween with 0 (zero) or undefined time immediatelly applies the tweening. Originally, 0 or undefined would be replaced by the default time (2), but because of an old bug, this didn't happen. Instead of fixing it, I decided to embrace it as, yes, sometimes it's better to do an immediate 'apply' via a tweening. It's not useful to do that on properties like _x or _alpha, as it's easier to just set it directly, but on some more advanced tweenings that would require several lines to set it to a new values, you can just use a tweening with no time parameter.
3. I've added Flash 8 filter support for Flash movies exported as version 8 and above, as both AS1 and AS2. Okey, this works nice, but due to the way the filters work, some explanation is advised.
*Inhales..*
You can create a filter normally and "add" it to a textfield/movieclip via a tweening. This tweens the existing object filter (if any!) or creates a new one and then tweens it.
The way the filter tweening is done, it's pretty much non-destructive, so it doesn't erase the filters already applied to the object (I don't know if anyone is aware of it, but you can't *CHANGE* the filter applied to an object - you have to reapply it, but it erases the filter list already applied. So you have to make a copy of the filter list, change what you want, and reapply). Again, this is pretty transparent and it works wonders with MC Tween so you don't have to worry about anything, but it also means that if you have two different filters applied to an object AND they are the same kind of filter (ie, two blur filters), the tweening will only apply to the first one since he can't "know" which one you're referring to.
You can also create in-line filter tweenings without having to create anything. This is kind of odd sometimes, however, as some filters take a LOT of arguments so it can look pretty weird.
This is a kind of a beta release. It's working nice and stable, and it doesn't crap over the rest of the extension's functionality, but I've just added a few of the filters as a test. I'm deciding if this is the syntax that suits it better, and the way the code is done (it does it job fairly well and quick, but it's a bit hardcoded). So for now, what's added are Glow, Blur and Bevel tweenings; DropShadow, GradientGlow, GradientBevel and the new AdjustColor are still out but will be added soon.
Anyways, I've changed the code here, and uploaded it on MC Tween's website. Installing the MXP is advised, of course, because of the syntax highlight and code hinting that's installed with it.
Of course, the website also has the new syntax explanation (blurTo, glowTo, bevelTo, as well as xBlurTo, yBlurTo, xyBlurTo, xGlowTo, yGlowTo, xyGlowTo and xyBevelTo).
Oh, here's the test file I used when making it (Flash 8).
* Be aware that if you have MC Tween installed on two different versions of Flash via MM Extension Manager, you'll first need to disable both of them, uninstall the extension, and reinstall the new one.
* The new one has a bigger SWF footprint. It takes 7.8kb of space after compilation.
Feel free to test, point out what doesn't work (if any), and suggest stuff.
msg231 {
bitfactory[+],
posted: 10.03.05 11a•-,
top [^]
}
Was wondering if you were going to add the filters to a pre-ZTweener release. AWESOME! Going to work with the new release heavily for the next few days.
Thanks again for all your hard work, Zeh!
msg232 {
rinse[+],
posted: 10.03.05 11a•-,
top [^]
}
Wow, ask and you shall receive! Thanks Zeh. You certainly rock!
msg233 {
rdoyle720[+],
posted: 10.03.05 11a•-,
top [^]
}
Maybe this is a dumb question, but no shadow filter tweening?
rinse: yeah, it's funny because after hours of editing the new documentation and checking for errors, I came to the site to *finally* post the thing and you had just posted your comment. :)
rdoyle720: yes... like I said, DropShadow, GradientGlow, GradientBevel and the new AdjustColor are missing. This is a kind of a public test, so I only implemented glow, bevel and blur, and released it on this stable but 'limited' state instead of sitting on it until I have time to add the other filters.
(thankfully, the way filter support is done on mc tween makes it easy to expand on it from now on, but I've been on a weird schedule as of lately and I haven't had the time to add it yet. So I figured some public testing and suggestion/critique could do it some good for now)
msg235 {
jeremytai[+],
posted: 10.10.05 7a•-,
top [^]
}
Hi,
I'm wanting to have a shape pulse using alpha and scale but not quite sure how to do it. The pulsing should stop when the mouse rolls over the shape. There us to be an example on here but can't find it.
Any help would be greatly appreciated
msg236 {
just_name[+],
posted: 10.12.05 5a•-,
top [^]
}
Poor little me, I'm still working with MX, no shiny new 2004+ for me just yet :( So a quick question, sorry to drag you back to the 'dark ages' ;)
I built a site a while ago using mctween version 2_16_15. I'm now using version 2_26_27 I've recently had to amend the site and found that when publishing/playback, it now locks Flash and asks to abort the script. The strangest thing is, I'd amended a couple of pages and published them loads before any of this started and it was working absolutely fine. I can't imagine what happened to change that...? To get around it, I've had to remove the current tween version, do the amends I needed and will then put the new version back on... I hadn't realised there was a backward compatibility problem - has anyone else had this problem or is it just me?? ;)
The latest versions shouldn't cause any problem - if anything, some stuff (like the flash 8 filters) won't work, but won't cause compilation errors and much less locking up.
I can't verify it right now - I don't have Flash 6 installed - but I'll look into that as soon as possible.
msg238 {
takemeaway[+],
posted: 11.15.05 6a•-,
top [^]
}
Hi Zeh.
I do love your work. But I have used Laco's for some projects as well now.
What I dont like is that you have to addin lines in MovieClip.as, the file that Macromedia shipped.
I doesnt like adding in lines in MovieClip.as, that shouldnt be needed.
That is how Laco recommends to do to avoid compile-errors when having tween-engine in as2-classes.
BUT, I havent seen you writing on how to use your MovieClip.tween inside as2-classes, but I guess it would be need to have the same solution as Laco proposes for 'his' tween? But you havent written about this in your documentation, why?
I found that you used $addTween, which gave me a little bit of a smile.
WOW, I can use the tween-engine without having to call it through the instance of a movieclip (textfield, sound..)
BUT, then there is one problem of course. it is methods that require the "__special*"-string. This must be sent in the $addTween as well (as if I want to use it in classes)
I could of course use the line that is in the MovieClip.protoype.xyGlowTo. But that is a REALLY REALLY long line.
What I would like, is to use the _global.$addTween in my as2-classes, so that I can prevent as2-compile errors when doing as2-classes.
I would something like this
_global.$addTween(..) (( this takes care of the non "__special"-props
_global.$addAdvancedTween(myMC, "xyGlowTo", otherprops...) // this is for "__special"-props
the "xyGlowTo" is then a key-identifier to the really really long addTween that has the "__special" and such in them.
cause I dont want to use "__special*" in the $addAdvancedTween, since that is a "private" string which can be changed and altered, therefore sending in "xyGlowTo" will be a nice public friend ;)
switch(func){
case 'xyGlowTo':
_global.$addTween(this, ["__special_glow_c..." (the command on line 1109)
break;
}
}
I wrote and thought about this just as I wrote my comment here and now, which perhaps makes the code full of syntax-errors. But it is just there to point out a eventually good way to call the methods in a as2-compile-friendly way?
What I want is really to have an all-static as2-class of this tween-engine.
So that you can "import zeh.br.tween".
But just as for now I could propose the use of $addTween and $addAdvancedTween to make this being free from editing the MovieClip.as as well as preventing compile-errors
Yeah, I guess it could be done... the $addAdvancedTween would just have to have a long check for the 'special' variables and mimic what their prototype methods do nowadays.
But to be honest, right now I don't like how mctween works with the "special" variable names. It works and is as fast as possible, but it looks like a mess. It's because of the way the whole thing was built, without those 'special' vars in mind.
That's why I'm just working on the new version. It's better fit for that kind of stuff (get and set functions/methods for all additional vars) and easier to work with. I'll still finish the rest of the flash 8 filters and some minor tweaks on mc tween, but I can't focus on changing much of the inner workings anymore. Splitting to $addTween and such was something that helped a lot in the code organization, but there's only so much one can do without rewriting the entire thing.
So in the mean time, if you're not willing to wrap around mine, laco's or mm's tweenings, I really think you should check Fuse Kit like I said on my email.
msg240 {
cruci[+],
posted: 12.06.05 5a•-,
top [^]
}
Loving this class, thanks for all the hard work.
Just a quickie, is it possible to use these on a video object? The one that you create from your library - New Video Object. (Flash 8 Pro)
I haven't done a lot of testing, but I couldn't get it to work. Is it perhaps not a "true" movieclip?
I don't think you can - yes, a video object is not a movieclip. You'd need to wrap your video with a movieclip.
msg242 {
cruci[+],
posted: 12.06.05 6a•-,
top [^]
}
ok, thanks, no problem.
msg243 {
petsounds[+],
posted: 01.13.06 4p•-,
top [^]
}
hey zeh,
I love MCTween..use it all the time. But it is becoming really bloated. I do a lot of interactive banner work, where filesize is of huge importance. I would love to see an MCTween Lite, with core tween types supported and things like onTweenComplete, but really as optimized and small as possible while still being as dependable as the normal version is.
petsounds - You're right, this has been a concern for me for a while too. the ~7.8kb used by mctween is a problem with bannersnowadays.
The idea of a 'lite' version is good, but unfortunatelly it's hard to achieve a 'right' lite version. Some people will want slideTo, some people won't, etc. Initially I thought of creating a server-side script that would let you 'build' your own version of mctween.. actually adding what you needed and removing what you didn't, and making sure the core code was left intact... it's a good idea, but each new version would have to be re-coded into the script, and it'd be more work than it's worth (imo).
In the end, this is much of a case-by-case scenario, so *personally*, I think the idea of editing mc_tween2.as and getting rid of all methods that aren't needed (like colorTo, colorTransformTo, bezierSlideTo, that kind of stuff) is the better choice for people looking for a 'lite' version of the thing. It's pretty easy to do and then it can just be renamed as mc_tween2_lite123.as or something and used on whichever project, then changed later to fit any other project's need.
On my own account, the only time I needed to use mctween on a banner project myself, I deleted almost all methods and functions. I left the core intact (the $-stuff), but the only public method I was still using was tween(), because, really, that's all it takes.
msg245 {
hsoares[+],
posted: 02.08.06 4a•-,
top [^]
}
Hello Zeh.
Can i use this class to make a preload animation?
Best Regards, and keep the good work
msg246 {
jgraup[+],
posted: 02.21.06 5p•-,
top [^]
}
Ok, this rocks and I use it for everything.
That being said, something came up recently where I need to tween over 100+ objects at the same time, and currently MC_Tween2 being time-based (with intervals), I miss most of the animation because by the time the processor catches up it's already been 1/2 a second. Everything is dynamic and scripted motion with transitions and sorting each new run of the animation sequences. Far too intensive with the current implementation of MC_Tween2.
While I find MC_Tween2 is perfect for a minimal set of items, do you have suggestions/solutions for tweening say; 500+ items at the same time? Same time being key ( delay = .05 * i ) helps stagger the animations but isn’t a solution to the problem.
This weekend was the first time I cracked into your actual prototype along with Robert Penner’s equations and whipped out a frame-based version of the tween. I noticed a significant increase when trying to see the full scripted animation (since each frame position is rendered) but I am wondering if there is a better way (from not me)? I know I am definitely not the ‘tween master’ and with respect to those who are, do you see yourselves developing a frame based version of the tweens?
Thanks.
function frameTime ( t ):Number{ return Math.round( t * FPS ); } // time * frames per second
function timeTravel ( d , s ):Number { return Math.abs ( Math.round( ( d / s ) * FPS ) ); } // ( distance / speed ) * frames per second
msg247 {
bitfactory[+],
posted: 02.23.06 9a•02.23.06 9a,
top [^]
}
zeh - as always - still using this thing ALL the time.
Have a question about callbacks - I'm setting the callback as a variable name so I can reuse a certain function, but I can't get it to execute.
the 'nextItem' variable is set - and I can trace it, but it isn't executing the function. If I substitute (nextItem) for the correct function name it works fine - but I obviously can't resue that function if I hard wire the nextItem name. Am I using the parens wrong?
Thanks again zeh!
msg248 {
jgraup[+],
posted: 02.23.06 9a•11.25.06 1p,
top [^]
}
Simply, throughout the script I want to be able to change the variable 'nextItem' so that when the fadeCallout function runs, it will trigger the function that is equal to 'nextItem'. The above example will only trigger the function called 'callBack' - while I want to call function of the variable 'nextItem' is equal to.
Thoughts? Thanks again.
msg250 {
jgraup[+],
posted: 02.23.06 10a•11.25.06 1p,
top [^]
}
(249)
_global.nextItem ="myGreatFunction";
_global.myGreatFunction = function() {
trace("This is the Greatest Function Ever... until the next one comes along");
}
msg251 {
bitfactory[+],
posted: 02.23.06 10a•-,
top [^]
}
Perfect - exactly what I was looking for - I tried the [ nextItem ] earlier, but didn't include the _global before it. I thought that was the idea behind setting a _global variable - was that you don't have to always use the '_global' when you're calling it.
Oh well - it works great now - THANKS AGAIN, I appreciate the timely answer.
msg252 {
jgraup[+],
posted: 02.23.06 11a•-,
top [^]
}
bitfactory - you're welcome.
I think it's less about the _global, and more about giving scope["toAString"]();
msg253 {
sjoland[+],
posted: 04.08.06 6a•-,
top [^]
}
I just switched from Laco to MC_Tween2 for all my upcoming projects. THIS ROCKS! I just love it, however I'm missing the function to use relative values, like in Laco's "'-20'". Is that in the plans or are there already some workaround available?
/Thanks
msg254 {
rinse[+],
posted: 04.08.06 7a•-,
top [^]
}
I suppose you could just a do a
myMC.xSlideTo(myMC._x - 20, 1);
Just guessing.
msg255 {
sjoland[+],
posted: 04.08.06 8a•-,
top [^]
}
rinse: hehehe, that was toooo easy for me to even try myself... thanks alot, works perfect... AND props again to ZEH!
msg256 {
rdoyle720[+],
posted: 04.08.06 9a•-,
top [^]
}
great stuff.
msg257 {
therookie[+],
posted: 05.03.06 12a•-,
top [^]
}
never understood why people use laco and not this mctween... why did you switch? (@msg253)
msg258 {
therookie[+],
posted: 05.03.06 12a•-,
top [^]
}
... from laco to mcTween?
msg259 {
pbasto[+],
posted: 05.24.06 5a•-,
top [^]
}
Hi, and great work Zeh!
I always have problems while using a preloader and exporting classes to frame (4). The weird thing besides the persistency of some elements on screen is that the flash IDE streaming player renders different results from the standalone player.
Here is my setup:
//1ST FRAME ///////////////
//////2ND and 3RD FRAME EMPTY//////////
//////4TH FRAME///////LAYER2
///////4TH FRAME//////LAYER1
//////PROBLEM: both the loadPercent and loadBar movies refuse to fade away
// EXPORT SETTINGS ARE AS2.0 FLASH 8 and CLASSES ARE EXPORTED IN FRAME 4 ///////
I've been cracking my head on this for days and cant find a solution, maybe there's a workaround?
I tried every possibble combination export setting and loading sequence of frames.
PS: I just put these for others who doubtedly bump with the same problem since i'm such a newbie i didn't figured that the layer stack was the issue.
By the time I was writing this I realized that the #include "mc_tween2.as" statement had to be on the 1st TOP layer for the thing to work since obviously everything on a top layer appears first right? The same goes for AS. ( still hitting ctr+Enter worked fine because classes already loaded after first run )
msg260 {
electric retina[+],
posted: 07.07.06 12p•-,
top [^]
}
MC Tween is the bomb!
I have one question. I have a AS2 class that uses mc tween on attached movieclips and I wondering is there is a way to use a variable in the tween values:
Hm, apparently this site stopped emailing me about new comments added, so sorry for not replying to some posts before. Here it goes:
@hsoares, 245: yes, you can use it for preload animations. I use it all the time. The only drawback is that you need the #include line before any call to a MC Tween method is done, do this means having those ~7.8kb on your SWF before the preloading is even shown.
@jgraup, 246: MC Tween doesn't use 'intervals' (I guess you mean setInterval), but yes, it's based on time only.
The problem with issuing a high number of tweenings at once is a big discussion and it's not relaed to being based on time or on frames. Overall, because MC Tween is "safe" - ie, it tries to check if you already have some tweening executing for that property for that object, it tries to see if it's some kind of special tweening, etc - the adding time is higher than simply pushing a new item to a list. This means it is FAST, but having hundreds of new tweenings called at the same time can be a problem.
In cases like this, you don't want to issue a bunch of tweenings, whatever tweening extension/class you're using. The best thing is to use ONE tweening on ONE variable (say, F goes from 0 to 1) and that a function updates all those 500 movieclips on each new frame based on the F value. This would be much faster for both updating and starting - in fact, the fastest solution. Of course this implies that all your animations will also finish at the same time, so other solutions may be needed depending on what you're trying to do.
Special solutions to special cases. MC Tween is a good generic solution for generic cases, but everything that's too out of the ordinary (updating 100 items on screen is a bit out of the ordinary for me) would always need a specialized solution.
With that said, I don't plan MC Tween to be based on frames, specially because doing animation with a frame count is a much, much worse way of doing animation. You will have inconsistent performance and time over different systems and is overall a step back. There are some special cases where frame-based animation is needed, but they're *VERY*, *VERY* rare and can be done manually instead anyways.
@jgraup, 250: thanks for answering bifactory's question.
@sjoland, 253: this is a great idea, but I don't think of adding it to MC Tween. While I think MC Tween works nice now, it'd be hard going back to it and rewriting that part; I'm creating a new AS2-based tweening extension, and I'm still struggling to find time to make it more stable and 'public-ready'.
rinse's solution is of course a good one (thanks!), but there are certain cases where the ability to create delayed tweenings with 'dynamic' destination values would be desired, hence why this kind of relative value seems cool.
@pbasto, 259: the problem might be due to the fact that actionscript is executed from bottom to top, if I remember correctly. You can use the #include line on the same layer as the rest of the code (immediately before it). Just remember the #include has to be before any mc tween method call (alphaTo, slideTo, etc).
Using AS1 or AS2 and the class export frame would make no difference to how MC Tween works on that aspect.
@electric retina, 260: thanks for the solution, but this is quite strange. The _global functions don't refer to the value - they receive the number as the parameter right away without having to resolve it. Weird.
msg263 {
ignitrix[+],
posted: 08.23.06 1p•-,
top [^]
}
Any plans to port this to ActionScript 3?
msg264 {
cuzman[+],
posted: 09.04.06 5a•-,
top [^]
}
Though I only scanned through, I didn't see this covered here. But I need some advice on how to handle a simple xSlideTo method for a mc that contains a wide jpg. Problem is if you rapidly press the buttons to slide the mc its x values become off, meaning not in 395px increments (see code below). I think I understand why — because the mc is still tweening when the calls are made, thus adding the 395 to its current _x position. How can I make the mc only slide 395px either direction. I assume it would involve some sort of checking if the mc is tweening??
Any help would be greatly appreciated.
Thanks.
Example:
mask_mc: 395px wide mask for loader_mc
loader_mc: contains a wide jpg
fwd_btn: controls the slide forward (moves loader_mc to the left)
bck_btn: controls the slide back (move loader_mc to right)
//Code for the BTN
//fwd_btn's code
on (release) {
if(loader_mc._x > -790) {
loader_mc.xSlideTo(loader_mc._x-395, .5, "easeOutExpo");
};
trace(loader_mc._x);
}
//bck_btn's code
on (release) {
if(loader_mc._x < 0) {
loader_mc.xSlideTo(loader_mc._x+395, .5, "easeOutExpo");
};
trace(loader_mc._x);
}
msg265 {
tobijas20[+],
posted: 09.06.06 1a•-,
top [^]
}
Hi!
I have this problem:
How to stop animation in the midle of interval (before end of delay)?
I've tried with clearInterval() and delete onEnterFrame, but nothing happend.
Example:
this.frameTo(10, 0, "linear", 3);
delay is 3 sec. How to stop this function before it starts in 3 sec.
I have some animation that should have timeline control with "pause" "play", but it can't work if thera are functions with delay.
The same problem is when the function lasts some time like:
myMC.alphaTo(100, 5, "linear");
How to stop this after 2-3 sec.(before the end of 5 sec)?
msg266 {
tobijas20[+],
posted: 09.06.06 1a•-,
top [^]
}
stop.Tween(); works :)
msg267 {
cuzman[+],
posted: 09.06.06 1a•-,
top [^]
}
using a simple delay on my tween seems to have answered my problem. Though it may not be the cleanest way... seems to work. I put a .2 delay which is enough to prevent the rapid fireing of the button actions and not really notice the delay.
tobijas20, for your problem, would look into the stopTween method.
I think a simple if/else condition may work.
example:
if (something == true) {
myMC.stopTween;
}else {
//do something else;
}
Its just a thought... nothing tested. Good Luck.
--Cuzman
ignitrix: giving the way AS3 works, there's no actual porting to be done - the use of prototypes goes totally against the 'laws' of the language (similar to AS2, where it went against the laws of the language, but without the hacks that were possible because AS2 was just AS1 written in a different way). You would never be able to do mymc.slideTo() on AS3 unless your mymc is not a movieclip but rather a new class that extends it. Which in itself makes coding more frustrating.
However, right now, for all my projects, I'm using a new tweening/transition class (a real AS2 class) that aims to replace MC Tween entirely. Due to the syntax/prototype "problem", however, it uses a different syntax - it's a different solution (although it's a different solution for the *same* problem - easier tweening with code). It's reaching a 'stable' state right now, so much that I use it on all my day-to-day work (although it's still far from what MC Tween does and all the corners it covers) and, given that's a correct AS2 class, it's also easier to port to AS3 (syntax would be the same).
Again, since it's reaching stable state, I'll release it soon. As soon as I have time, because my available time has been close to nil on the past few months so I didn't have the chance to make things right yet (ie, writing documentation and examples). And when I do, there will be AS3 releases at the same time of the AS2 releases. In fact there's already an AS3 version, ported by Nate Chatellier (who has also been helping me with invaluable suggestions and feedback on the way the AS2 version works), but I still want to change a lot of stuff on the structure of the AS2 version that should mean the AS3 one will be rewriteen (to make source code of the two versions closer to each other).
msg269 {
rebeltrooper[+],
posted: 10.04.06 8a•-,
top [^]
}
zeh hi, im using your prototype for a long time , but something i never do, is a loop on timeline animation, please if you post a example of this i appreciate, this is my code, a container mc and 3 images mc called "uno" "dos" "tres". i tried to make a loop but dosent work.
Well, rebeltrooper, what you need to do is to create functions that are then repeated. On this case, it's better to have everything on a separate place, instead of having the code each on its own movieclip (too confusing to maintain). On your case, it would be something like this, with your code on the parent movieclip timeline:
You might have to fix the movieclip references and the final "phase" time, so I can't say it will work with a simple copy&paste. Mind the concept, not the face value.
Use this to stop the loop:
this.stopTween("phase");
msg271 {
rebeltrooper[+],
posted: 10.04.06 9a•-,
top [^]
}
Zeh Works fine but a little problem i have, the animation on every MC not work, the "ySlide" part not work on the loop, only the fade, of the rest is ok!
msg272 {
zeh[+],
posted: 10.04.06 10a•-,
top [^]
}
It's because you're not setting it to the original value; you're just moving there but never going back. You have to either set the original _y value on the function, or add a few tweens to make it go back in place, to the original value (like how you did with the fade).
msg273 {
rebeltrooper[+],
posted: 10.04.06 10a•-,
top [^]
}
i dedeuce it myself, (for me its a great thing), thanks zeh, and hope soon one new version of your precius tool. (^^)/
msg274 {
zeh[+],
posted: 10.04.06 10a•-,
top [^]
}
msg275 {
helios[+],
posted: 10.05.06 8a•-,
top [^]
}
I can't wait!
msg276 {
cuzman[+],
posted: 10.05.06 1p•-,
top [^]
}
I thought I had solved this issue (post below), however I am working on another project with a similar effect and the simple delay that I used before isn't working out too well. If anyone has any helpful pointers I would be ever indebted.
Thanks.
--Cuzman
original post
-------------------------------------------------------------------
Though I only scanned through, I didn't see this covered here. But I need some advice on how to handle a simple xSlideTo method for a mc that contains a wide jpg. Problem is if you rapidly press the buttons to slide the mc its x values become off, meaning not in 395px increments (see code below). I think I understand why — because the mc is still tweening when the calls are made, thus adding the 395 to its current _x position. How can I make the mc only slide 395px either direction. I assume it would involve some sort of checking if the mc is tweening??
Any help would be greatly appreciated.
Thanks.
Example:
mask_mc: 395px wide mask for loader_mc
loader_mc: contains a wide jpg
fwd_btn: controls the slide forward (moves loader_mc to the left)
bck_btn: controls the slide back (move loader_mc to right)
//Code for the BTN
//fwd_btn's code
on (release) {
if(loader_mc._x > -790) {
loader_mc.xSlideTo(loader_mc._x-395, .5, "easeOutExpo");
};
trace(loader_mc._x);
}
//bck_btn's code
on (release) {
if(loader_mc._x < 0) {
loader_mc.xSlideTo(loader_mc._x+395, .5, "easeOutExpo");
};
trace(loader_mc._x);
}
---------------------------------------------------------------------
cuzman: a check would suffice (using isTweening() and not letting it tween if _x is already tweening), and you also could use calculations to "snap" to multiples of 385, but I'd say the right thing to do is this: instead of controlling the abolute _x position of the thing, you have an additional variable that stores the current "page" that is being viewed (say: 0, 1, 2, 3, 4, etc). Movement just increases (or decreases) that number, then when that happens, you move the _x of the image relative to that number, by multiplying the current page to the page width: (page number) * 395.
msg278 {
matefive[+],
posted: 10.30.06 8a•-,
top [^]
}
hey zeh, great script!
I just got one problem with it.. you know when I use it local, everything eases perfekt and smooth, but when using it in opera or firefox it shutters like if there are to less frames..
I checked your own site in opera too and it doesnt shutter.. so what am I doing wrong.. is there
any special tricks when exporting it to flash 8 ?
Thanks a lot in advance for any answer that helps me out of that!
Matefive: hm... no, there's no problem in that aspect. As long as your movie uses a good enough framerate (I usually use 31, 40, 45, 50 or 60), there's no reason it should stutter on any browser or player version at all.
msg281 {
Grimace[+],
posted: 02.26.07 11p•-,
top [^]
}
Allright zeh! This looks really promising. I had I quick look, and I have the feeling that the new event architecture would have saved me some headaches in the past ;)
msg282 {
sjoland[+],
posted: 03.05.07 7a•-,
top [^]
}
Thanks Zeh! Looking forward to try it out on some new projects. Do you have any idea on when the flash 8 filters will be included in the special properties? I'm using the blur-function in almost all projects, so thats whats keeping me from switching. Or do you have any suggestions on how to modify the properties temporarily right now?
Thanks again,
/Sjoland
Sjoland: they will be added next... the current version (1.21.36) will be made 'stable' this week (current stable is 1.20.32) and then I'll implement the filters. I've already done most of the work so I just have to move it to Tweener itself and then test. It's not difficult, but considering the way the filters work, there's a number of implementation and syntax caveats (like MC Tween have them itself) that I'm trying to solve so developers won't have to scratch their heads too much when writing Tweener code for filters.
There will be two approaches, one with special properties (working a lot like MC Tween) and other one with tweening the filter properties themselves (more 'powerful').
I usually don't like having two approaches for the same thing, but the second one is because of the way Tweener will allow 'deep properties' to be tweened (like filter properties, transformation matrix properties, array items), etc.
So all in all, if work allows, I think filters will be available next week on the SVN version.
msg284 {
sjoland[+],
posted: 03.06.07 4a•-,
top [^]
}
Zeh! That sounds great! I guess it will take some time to get used to the new parameters, but I feel the pros are worth it.
Another thing I've been struggeling with is a reliable "pause"-function. I built a few different ones based on your .frameTo, like this one for example:
The goal is to use a simple cut'n'paste wait/pause functions on different moviclip timelines simultainously. The problem is that it's not reliable, because sometimes the different Callbacks triggers eachother. I know I'm not a savvy coder, but I tried to make it easy to use.
So my question is if you have any built in pause/wait function in Tweener, or if you could suggest a function/property that could be customized for this?
sjoland: usually on actionscript settimeout or setinterval do the job.
When using MC Tween I had a separate piece of code - triggerFunction() - that would create delays. It worked like setTimeout, but on top of setInterval, and it was a bit cleaner and safer, and had a slightly simpler syntax.
Nowadays, with Tweener, I just use Tweener itself, with no actual tweening property.
MC Tween users will like to known that now a reference installation is available, thanks to Alfredo Santamaria. This installs the reference website itself inside of Flash, or any other help reader.