[Tweener] Adding tween
Jeremy Davis
jwdavis1981 at gmail.com
Mon Jan 25 04:57:09 PST 2010
//Arrays to make your life a little easier, just add to the arrays and your
functions will work
var arrayOfClips = ["my_mc1", "my_mc2"];
var arrayOfDirections = ["up", "down"];
var arrayOfDistance = [20, 100];
//No need for onEnterFrame, Tweener handles that for you.
function moveClip_move(p_clip:MovieClip, p_dir:String,
p_distance:Number):Void {
switch(p_dir){
case "up":
Tweener.addTween(p_clip,{_y:this._y-p_distance, time:1,
transition:"Linear"});
break;
case "down":
Tweener.addTween(p_clip,{_y:this._y+p_distance, time:1,
transition:"Linear"});
break;
}
}
//Do your loop on your button to keep your animation function generic as
possible.
my_but.onRelease = function() {
for(i = 0; i < arrayOfClips.length; i++) {
moveClip_move(this[arrayOfClips[i]], arrayOfDirections[i],
arrayOfDistance[i]);
}
}
On Sun, Jan 24, 2010 at 12:13 PM, Adrien <realeon at hotmail.com> wrote:
> Hello,
> I'm sorry i'm still trying to add a tween to this without success...
> Last time I posted I didn't include the bit at the end with
> my_but.onRelease (I guess it's maybe more understandable now)
> The purpose of this code is to click on my_but and it will move multiple
> mcs at the same time...
>
> I've tried Zeh's solution but I can't get it to work (thank you Zeh for
> having looked at it)
>
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> function moveClip_move(p_clip:MovieClip, p_dir:String,
> p_distance:Number):Void {
> p_clip.count = 0;
> p_clip.onEnterFrame = function() {
> p_clip.count++;
> if (p_dir == "up") {
> this._y -= 1;
> }else {
> this._y += 1;
>
> }
>
> if (this.count == p_distance) {
> trace(this)
> delete this.onEnterFrame;
> }
> }
> }
>
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> my_but.onRelease = function() {
> moveClip_move(my_mc1, 'up', 20);
> moveClip_move(my_mc2, 'up', 100);
>
> }
>
>
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> Regards
> Adrien
>
> Le 16 janv. 10 à 16:00, Zeh Fernando a écrit :
>
> I'm not sure exactly why you're trying this, but if you're tweening, you
> don't use onEnterFrame. It'd be something like this:
>
> function moveClip(p_clip:MovieClip, p_dir:String, p_distance:Number):Void {
> if (p_dir == "up") {
> Tweener.addTween(p_clip,{_y: p_clip.y - p_distance, time:1});
> }else {
> Tweener.addTween(p_clip,{_y:p_clip.y + p_distance, time:1});
> }
> }
>
> Zeh
>
> On Sat, Jan 16, 2010 at 8:52 AM, Adrien <realeon at hotmail.com> wrote:
>
>> Hello I'm trying to add a tween to this
>>
>> import caurina.transitions.Tweener;
>>
>> function moveClip(p_clip:MovieClip, p_dir:String, p_distance:Number):Void
>> {
>> p_clip.count = 0;
>> p_clip.onEnterFrame = function() {
>> p_clip.count++;
>> if (p_dir == "up") {
>> this._y -= 1;
>> }else {
>> this._y += 1;
>> }
>>
>> if (this.count == p_distance) {
>> trace(this)
>> delete this.onEnterFrame;
>> }
>> }
>> }
>>
>>
>> I've tried this but doesn't work... do you know what I'm doing wrong? it
>> has something to do with the minus and plus but why?
>>
>> import caurina.transitions.Tweener;
>>
>> function moveClip(p_clip:MovieClip, p_dir:String, p_distance:Number):Void
>> {
>> p_clip.count = 0;
>> p_clip.onEnterFrame = function() {
>> p_clip.count++;
>> if (p_dir == "up") {
>> Tweener.addTween(this,{_y -:1, time:1});
>> }else {
>> Tweener.addTween(this,{_y +:1, time:1});
>> }
>>
>> if (this.count == p_distance) {
>> trace(this)
>> delete this.onEnterFrame;
>> }
>> }
>> }
>>
>> Regards
>> Adrien
>> _______________________________________________
>> Tweener mailing list
>> Tweener at lists.caurinauebi.com
>> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
>
--
Thanks,
Jeremy Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20100125/4be3c32b/attachment.htm>
More information about the Tweener
mailing list