Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problem Creating Tween



I am fairly new to flash, but have had no problems creating tweens until now. For some reason when I try to add a tween, the line from keyframe to keyframe is dashed. And some contents disapear inbetween the keyframes. I simply insert keyframe and change the location of the graphic and add tween. and i am going crazy because i have made many tweens in the past. any ideas as to what may be going on? thanks!



FlashKit > Flash Help > Flash Newbies
Posted on: 01-11-2006, 04:50 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[F8] Help Need With Creating A Tween
i am trying to add a fade in and fade out effect as images are loaded from an xml file but i am stuck an dont know how to go about doing this properly.

here is the code i have up to now.


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

pauseTime = 5000;

xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
randomImage();
}
}
function randomImage() {
if (loaded == filesize) {
var ran = Math.round(Math.random() * (totalImages - 1));
picture_mc.loadMovie(imageFileName[ran], 1);
pause();
}
}
function pause() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
randomImage();
}
}
//this is the section of code i am not sure how to implement
piture_mc.onLoad = function(){
fadeMovieClip(100, 0);
}
picture_mc. = function(){ //dont know how i would call this part of the function here
fadeMovieClip(0, 100);
}
function fadeMovieClip(startAt:Number, endAt:Number):Void {
var myTween:Tween = new Tween(myMovieClip, "_alpha", mx.transitions.easing.None.easeNone, startAt, endAt, 3, true);
}
any help with this would be much appreciated.

Creating A Shape Tween With AS?
is it possible to create a shape tween with actionscript? perhaps like drawing? i haven't ventured onto this area until now..

it's like i wanna draw a rectangle, then color the inside area.. is this possible? could anyone give me an example?

thanks, everyone. cheers!

Creating A Shape Tween With AS?
is it possible to create a shape tween with actionscript? perhaps like drawing? i haven't ventured onto this area until now..

it's like i wanna draw a rectangle, then color the inside area.. is this possible? could anyone give me an example?

thanks, everyone. cheers!

Creating An Alpha Tween
How do you create an alpha tween?

I have tried using the motion tween, that doesent work. And when I try the shape tween it also does not work.

Thank you.

~Brendan

Creating Images To Use In Shape Tween...
hi,

i am try to make a button in photoshop with transparency around it which when rolled over will shape tween to a different shape.

i can get the transparency to work fine when i save it as a png but then when i try to break it apart so that i can use it in a shape tween, it still has the box around it (it shows transparent, but is still there) which makes the shape tween not work because the box hides the difference between the two shapes i am trying to shape tween.

does anybody know if there is something i can do to get around this?

im sorry if this is worded confusingly...

Creating Functions With The Tween Class
I'm working with the Tween class in Flash 8. It's great stuff, except I find my ActionScript is getting excessively lengthy. For example, I have ten instances of buttons on stage. They all utilize this particular bit of code, which makes the buttons pop upward:


ActionScript Code:
button1.onRollOver=function(){
//initailizing the Tween
var popBtn:Tween=new Tween(button1, "_y", mx.transitions.easing.Elastic.easeOut, 0, -20, 2, true);
//calling the tween object
popBtn.start();
}

The only difference for any of the buttons in the script is the name of the instance. When i set this up as a global function, using "this" instead of a specific instance name, the script fails to execute. So I have to hammer out all those lines of code for each button instance.

Thanks in advance for any help!

Creating Functions With The Tween Class
I'm working with the Tween class in Flash 8. It's great stuff, except I find my ActionScript is getting excessively lengthy. For example, I have ten instances of buttons on stage. They all utilize this particular bit of code, which makes the buttons pop upward:

ActionScript Code:
button1.onRollOver=function(){
//initailizing the Tween
var popBtn:Tween=new Tween(button1, "_y", mx.transitions.easing.Elastic.easeOut, 0, -20, 2, true);
//calling the tween object
popBtn.start();
}




The only difference for any of the buttons in the script is the name of the instance. When i set this up as a global function, using "this" instead of a specific instance name, the script fails to execute. So I have to hammer out all those lines of code for each button instance.

Thanks in advance for any help!

Creating Motion Tween Query...
Hi,

I am creating a motion tween on the timeline with a number of different frames. The aim of this is to create a fade in effect which is working perfectly. The problem is when I create a tween on the layer that just contains three buttons it knocks the black line off the left side of the keyframe to the right. This is shown below.



Any ideas?

I have only created the tween between frame 20 and 39 on each of them.

Creating A Motion Tween Btwn Two Photos. Help
I am trying to do a motion tween between to photos. The photos show hands
holding a clump of earth which he breaks up leaving a trail of dust. I want to
try and get the movement of the dust using two photos. But it's not working
.What am I doing wrong?

make a keyframe in frame one

Insert first photo in timeline at frame one

Make first photo a symbol

select a frame further into the movie, say frame 30 and insert a keyframe

insert second photo at frame 30

make second photo a symbol

go to frame one and add a motion tween

The above actions aren't producing a motion tween. What am I doing wrong?

Tween Class Transitions Creating Weird Visual Glitches?
Hullo fine people

I've been knocking together a wee image gallery app, and I've used the new AS3 Tween Class to swish the images left and right with cute little scaling and alpha eases.

The coding of such transitions is indeed vastly improved (random garbage collections stopping the transitions aside ) over AS2 ... however, I can't help but notice that there's an awful lot of flicker and visual glitching on the end result.

See my work in progress example to see what I'm on about - when the transitions are in motion, there's very noticeable flicker and glitching until it settles into the ease and finishes:

http://chris-beaumont.com/temp/ImageGallery.html

Does anyone know why this is or what I can do about it?

I was thinking about writing custom functions to manage the transitions and ditching the Tween Class alltogether, but wanted to know if this was likely to have any effect before I start.

Many thanks!

Chris

Problem Creating Duplicate Movie Clip But Changing One Motion Tween
Hi I am currently having a problem creating movie clips.

I have created a movie clip which is an animation containing 5 different layers and 3 different motion tweens. I duplicate this movie clip and wish to change one of the motion tween's but when I change the motion tween in the new movie clip, it also changes the motion tween in the old movie clip.

I have tried removing the motion tween in the new duplicated movie clip, and creating a new motion tween but this still gives me the same problem as above where the original movie clip now contains the new motion tween.

Please help.

Thanks,

Dan

[tween Class] Creating Multiple Tweens And Assign Variable Names
Hi there:

I'm trying to create various tween for various movies, comething like this:


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

function fade_anim(mc, max, min, tempo) {
var bot_alpha:Tween = new Tween(eval(mc), "_alpha", Regular.easeIn, max, min, tempo, true);
bot_alpha.onMotionFinished = function() {
fade_anim(mc, min, max, tempo);
};
}

fade_anim("barra3",90,20,1);
fade_anim("barra4",30,80,1);
this code works without problem.

My problem is how to call a specific tween to stop it, for example: onrollover stop the tween assigned to "barra3" mc for example

I can't use bot_alpha.stop() it doesn't work. I think it's because i have multiple "bot_alpha" tweens, i need something to dynamic create bot_alpha1; bot_alpha2; ... ...

Thanks for the help!

Tween Class: Can One Tween More Than One Property Using The Same Tween
I want to scale both the _xscale and the _yscale properties of a clip, using a single execution of the Tween Class. See example below:


Code:
import mx.transitions.Tween;
var myTween:Tween = new Tween(myMovieClip_mc, "_xscale", Strong.easeOut, myMovieClip_mc._xscale, 300, 5, false);

Since one property at a time must be passed as a string to the constructor, I tried the following code, but it does not work quite as flawless as I expected:


Code:
myTween.onMotionChanged = function() {
//trace( this.position );
myMovieClip_mc._yscale += (300 - myMovieClip_mc._yscale)/12;
};
Any suggestions?

Using Stop(); On A Shape Tween Of A Swapped Movie Clip Symbol Within A Motion Tween
Thanks a lot for your time. I'm new to actionscript, and language syntax and I never really got along to begin with so I appreciate any help in the matter.

Basically the title says it all - I made a motion tween in the main scene, made a movie clip symbol (to shape tween a gradient) and added a stop(); inside the gradient-tweened-symbol. I then swapped the movie clip symbol with the motion tween in the main scene, and got exactly the effect I wanted (the item moved, then tweened itself) but the stop(); seems to have no effect.

I know this looks like one of those "that idiot didn't google before posting" questions, but I've been looking for about a half hour with different permutations of stop, doesn't work, actionscript, and flash, and I haven't found anything that seems to target this problem specifically.

If you've got any idea what's going wrong, please feel free to respond or show me how to better seek help on my own. Thanks again.

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Actionscript Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

I am trying to do a intro loader for my front page controlling around 7 boxes. So I need to repeat this a few times.

Regs,
Jacko

Tween Class If Moved Mc Passed Point Start Another Tween
Hey Kirupa Flash Gurus

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate.

ie starting the second mc moving while the first tween is still moving.

Regs,
Jacko

Laco Tween Engine Versus Flash Native Tween
i am wondering if there is a way to put a delay (seconds) on the flashs' native tween class like you can on the laco tween engine... such as

Code:
#include "lmc_tween.as"
my_mc.tween("_x",100,1,"easeOutStrong",1.5,callbackFunction)
where "1.5" is would be the one and a half second delay before the tween starts. this is very useful to me because i dont have to use a callback function or an onMotionFinished function to start a new tween.

thanks in advance to anyone who can teach me

-frankf

Tween Class Scaling Breaks Motion Tween?
I have a movie clip which uses a motion guide to animate the entry (and eventually the exit) of a bunch of other movie clips. These smaller clips contain buttons, and animate on rollOver and rollOut using the following code:


Code:
on(rollOver) {
this.swapDepths(2);
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Back.easeOut, this._xscale, 100/.6, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Back.easeOut, this._yscale, 100/.6, .5, true);
play();
}
on(rollOut) {
ParentxScale = new mx.transitions.Tween(this, "_xscale", mx.transitions.easing.Bounce.easeOut, this._xscale, 100, .5, true);
ParentyScale = new mx.transitions.Tween(this, "_yscale", mx.transitions.easing.Bounce.easeOut, this._yscale, 100, .5, true);
stop();
}
However, once an object has been moused over, it doesn't exit with the others. Any ideas why it seems to "fall off the track" of the motion guide?

Shape Tween Like A Motion Tween, Using Guide Layer
How if possible, can i make a shape tween behave and follow a set path (like using a guide layer)while morhping/tweening?

So far it seems as each time i try it always goes in a straight line from a to b and in this case that's not what i'm after.

Diference Between Motion Tween And Shape Tween
What exactly is the difference between a motion tween and a shape tween?

What's The Best Way To Do A Motion Tween And A Shape Tween At The Same Time?
Hi all,

I'm having some difficulty doing this. I have tried motion tweening a movie clip containing a shape tween but it just doesn't look right. Anybody have any ideas?

Cheers

Do I Use A Shape Tween? Mask? Motion Tween?
How do I make this arrow grow into shape? I want it to slowly appear...but not fade in...

it's hard to explain...but here is the arrow, hopefully you will understand what I want...

I tried using a mask, but instead of revealing the arrow little by little, it dissapeared little by little...(basically the exact opposite)...

I also tried putting a white box over it & motion tweening the box to reveal the arrow...but that didn't look good...


any ideas?...suggestions?

thanks in advance...

What's The Difference Between A Shape Tween And A Motion Tween?
Hi!
I just wanted to ask that what is the difference between a shape tween and a motion tween???

Not to bother you.

please reply me back

[MX04] Shape Tween And Motion Tween
Why do Flash doesn't allow ungrouped objects into motion tween and symbols into shape tween?

After Tween, Jump To New Frame (using Tween Class)
I need some help with using the tween class (among other things).

See my attached test file. It's clearer than my description.

You're supposed to be able to click the "next" or "prev" buttons and see the movie clip move forwards or backwards. It works, but only on the first click of the button. After the initial click I need the timeline to jump to frame label "2", and after the second click I need the timeline to jump to frame label "3", and so on, so that I can implement a new set of perameters. Is that clear? I'm so annoyed with this. Please help!

Thanks.

Tween Class Problem. Tween Freeze?
I am using the tween class to do an alpha tween on some jpgs that get loaded into a movieclip. Everything thing works great until the user rapidly clicks on the 'next' arrow to jump forward to a new picture. If the user clicks too quickly something happens and the tween function stops working.

Here is the tween code:

Code:
//set up tweening
import mx.transitions.easing.*;
import mx.transitions.Tween;
var tweenAlpha:Tween;
function alphaTween(object,duration){
easeType = mx.transitions.easing.Regular.easeIn;
tweenAlpha = new mx.transitions.Tween(object, "_alpha", easeType, 0, 100, duration, true);
}
http://12dogsofchristmas.com/12_dogs_menu2.swf

You'll notice that if you click slowly on the arrows the pictures load correctly with the story. However, if you click fast they stop tweening.

thanks for the help.

Change From Motion Tween To Shape Tween
I am trying to have a motion tween of some text move on the page and then change into a shape (i.e, a shape tween). I can't seem to make this work. I put a keyframe at each end of the motion tween and that works fine. Then I add another keyframe, delete the text and replace it with my shape. Then I select just those frames and add the shape tween but nothing happens. How do I accomplish this successfully?

Thanks.

Shape Tween / Motion Tween Problem
I must be missing something very obvious.

I have created a movie that draws a box, fills in the box with color and then is supposed to have the menu swoop in from the right. Mind you this is for learnnig, not cosmetic appeal Why is it when I use tweens I get the dotted line versus a solid line in the time line?

If you take a peek at the FLA it is obvious what I am referring to. I must be using the tween function or symbols in an improper manner.

I have attached the FLA.
Any help appreciated.
Thanks,
Kerry
www.skurz.com

Tween.stop(). Part Of The Tween Class?
I need to know if tween.stop() is part of the Tween class in Flash 8 or if it's related to an extension I installed (ie. TweenExtended).

How To Programmatically Begin A Tween When Another Tween Ends?
Hey everybooody,

In this example, I'm trying to programmatically fade-in the alpha of menu items created from xml data. Using the tween object, I'm trying to start the next tween once the first or previous tween has finished.

Clearly in my attempt below, the “if” statement isn't cutting it because it's not waiting for the tween to be finished.

Using the oListener.onMotionFinished method, I tried using a Boolean to return true when finished, and then to start the next tween. But clearly I haven’t figured out the proper control flow for this.

I also tried a 'do while' statement, attempting to creating a waiting-loop until the bCheck returned true, but that just created a series of open loops, and crashed the program.

The big problem here is that I'm trying to figure out how to do this while looping through an array of menu items, so that I triggure the fade in of each menu item...



Has anyone had experience with this? Thanks!!!

Here's what I was trying to do:

function fadein_menu() { var bCheck:Boolean = false;
var oListener:Object = new Object();
oListener.onMotionFinished = function(twObject:Tween):Void {
bCheck=true;
};
for (var i = 0; i<totalMenuItems; i++) {if (i==0) {var twMenuAlpha:Tween = new Tween(menuitems[i], "_alpha", Strong.easeIn, 0, 100, 3, true);
twMenuAlpha.addListener(oListener);
} else if (i>0) {if (bCheck==true) {bCheck=false;
var twMenuAlpha:Tween = new Tween(menuitems[i], "_alpha", Strong.easeIn, 0, 100, 12, true);
twMenuAlpha.addListener(oListener);
};
};
};
};

Tween Class Not Always Fulling Complete Tween
I have a switch statement that is a part of the tween effects found on the header of http://gfxcomplex.com/blog.

the problem is this case will change the rotation of a sprite and then tween it to zero. The funny thing is some times ("not all the time") some of the tween stop in the middle and do not complete leaving the sprite with a rotation somewhere in the middle of 180 to 0. My question is, is there something in my code that could be the reason for this or is this a bug??

You may have to watch the header for a long time to see this bug happen as it seems to be more a fluke then a true code bug.


PHP Code:



case 7 :            var u:uint = 0;            test1.getChildAt(0).rotation = 180;            test1.getChildAt(1).rotation = 180;            test1.getChildAt(2).rotation = 180;            test1.getChildAt(3).rotation = 180;            test1.getChildAt(4).rotation = 180;               intervalId = setInterval(function myFunction(){                                                          myTween1 = new Tween(test1.getChildAt(u), "rotation", Bounce.easeOut, 180, 0, 3, true);                                                          u++;                                                          if(u == 5){                                                                                                                      clearInterval(intervalId);                                                                                                                        }                                                          },                                                          150);break; 

Shape Tween / Motion Tween Problem
I must be missing something very obvious.

I have created a movie that draws a box, fills in the box with color and then is supposed to have the menu swoop in from the right. Mind you this is for learnnig, not cosmetic appeal Why is it when I use tweens I get the dotted line versus a solid line in the time line?

If you take a peek at the FLA it is obvious what I am referring to. I must be using the tween function or symbols in an improper manner.

I have attached the FLA.
Any help appreciated.
Thanks,
Kerry
www.skurz.com

Seperating Motion Tween From Alpha Tween
I am trying to fade in the alpha on a graphic symbol rather quickly at the same time the symbol scrolls very slowly up the stage, but the two seem linked, so that a very slow scroll means a very slow opacity gain. How can I fade the photo in quickly while the photo motion tweens slowly?

Laco Tween Pause/Stop Tween
Hi There,

I am using laco tween to move dynamic text that is taken from XML. I need the text to pause when the user rollsover the text, is there anyway of using the stopTween() function, then on rollOut getting flash to continue with the tween?

Thanks.

Dabush

Jerky Tween- How To Get A Smooth Slow Tween- Help
I'm working with a very slow tween of an image (800 by 350px and 50 kb) over a time of 60 seconds and it's jerky.

Code:

Tweener.addTween(pic, {x:pic.x-100, time:60, transition:"linear"});

I tried upping the frame rate to 30, then 60, but it didn't seem to make a difference.

I also tried using TweenLite, Tweener, and the built-in Tween class. None really performed better than the other. Another thing I tried was importing the image as a swf, masking it, and then tweening it. None of those really made a difference, still jerky.

Any ideas?

How To Motion Tween Thats Not Linear Using Script Or MC Tween?
If you wanted to do an animation of a ball that goes from A to B but not linear, how would you do it by code or Mc tween. How would you make the ball go in a curve line for example instead of a straight line from A to B?

I understand you can use a guide to get all types of non linear motion tweens on a timeline, but how would you do it using MC tween or coding.

Motion Tween & Shape Tween In Same MC? How?
I have created a shape tween on my first layer. On my second layer I would like to create a motion tween. But the motion tween says it will not occur with layers with shapes or more than one group. Can anybody enlighten me a little bit on this.


Thanks for any help that is given.

Derek

Make Exit Tween Do Into Another Tween
okay here's the deal. for every button i have on a flash menu. i have a lil animation tween that plays when the specific button it's set for it clicked on.

what i would like to do is add an exit tween for each of these animations that does the reverse of the animation before starting up the new animation.

now... this could probably be done using gotoandplay actionscript with frame labels, but i would have to make special sets of buttons for each section...

is there another easier why for the button to play the exit tween when pressed then go to the tween of whatever button was pushed??

please let me know...

K-Fresh

Tween Class Vs Custom Tween?
I have searched for info on the Tween class, gave up when I found little to nothing on it, so here I am with some questions.

1 - Can I use this class in MX 2004 or is it in 8 only? If so, what is the invocation script?

2 - How flexible is the easing of the Tween class? Can it do more than just fast/slow in/out (fully customizable time curves)?

3 - Can you specify a finite amount of time in which the current invocation of Tween must be completed, or do you have to calculate and apply values to enforce this?

Thanks,
+Q__

[F8] Mx.transitions.Tween Set Quality During Tween
Code:
function tweenull(clip:Object, targetX:Number, targetY:Number, seconds:Number):Void {
new mx.transitions.Tween(clip, "_x", mx.transitions.easing.Elastic.easeOut, clip._x, targetX, seconds, true);
new mx.transitions.Tween(clip, "_y", mx.transitions.easing.Elastic.easeOut, clip._y, targetY, seconds, true);
}

this is my tween function. How can i set the quality to low during the tween action ?

Tween Class - Tween Lines
I have 5 seperate movie clips that each contain 5 lines, which are contained within their own individual movieclips, each with their own instance name.

I have written a function, included below, that uses the tween class to make one set of lines move/morph to the location of the second set, contained within the other movieclip.

It's basically a transition.. it's for the navigation of a site I'm working on. When you click a different navigation link, the lines that the nav & content are based around morph/change.

The problem I'm having is not all the lines tween to the right location/position. I've attached a 2 screenshots to show..

I've tried the function with the addition of the _xscale, _yscale, and _rotation properties, but they don't change anything.

Heres the function:


Code:
function moveLines(begin, end) {
//this moves the MC that holds the 5 lines to the x/y pos of the other MC.
var x_container:Tween = new Tween(_root[begin], "_x", Regular.easeOut, _root[begin]._x, _root[end]._x, 10, false);
var y_container:Tween = new Tween(_root[begin], "_y", Regular.easeOut, _root[begin]._y, _root[end]._y, 10, false);


//this is the loop that gets the start/end variables and creates the tweens
for (i=1; i<=5; i++) {
x_begin = _root[begin]["l" + i]._x;
x_end = _root[end]["l" + i]._x;

y_begin = _root[begin]["l" + i]._y;
y_end = _root[end]["l" + i]._y;

height_begin = _root[begin]["l" + i]._height;
height_end = _root[end]["l" + i]._height;

width_begin = _root[begin]["l" + i]._width;
width_end = _root[end]["l" + i]._width;

var x_tween:Tween = new Tween(_root[begin]["l" + i], "_x", Regular.easeOut, x_begin, x_end, 15, false);
var y_tween:Tween = new Tween(_root[begin]["l" + i], "_y", Regular.easeOut, y_begin, y_end, 15, false);
var height_tween:Tween = new Tween(_root[begin]["l" + i], "_height", Regular.easeOut, height_begin, height_end, 15, false);
var width_tween:Tween = new Tween(_root[begin]["l" + i], "_width", Regular.easeOut, width_begin, width_end, 15, false);
}
}
Now here are the screenshots. The first is before the tween occurs, and the second is after. As you can see, some of the lines don't fall into the right position. Any help is greatly appreciated! I have a deadline for this this week and I'm freaking out!

before tween:
http://sagebrown.com/before.jpg

after tween:
http://sagebrown.com/after.jpg

How To STOP A Tween With The Tween Class?
here's my code....


Code:
function generalTween(mc, attr, begin, end, time, func, easeType)
{
if (easeType == undefined) easeType = mx.transitions.easing.Bounce.easeOut;
var myTween = new mx.transitions.Tween(mc, attr, easeType, begin, end, time, true);
if (func != undefined) myTween.onMotionStopped = func;
}
function onReleaseFunc()
{
myBall.stopDrag();
generalTween(myBall, "_x", myBall._x, (Stage.width / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
generalTween(myBall, "_y", myBall._y, (Stage.height / 2), 2, undefined, mx.transitions.easing.Elastic.easeOut);
}
myBall.onPress = function()
{
myBall.startDrag();
}
myBall.onRelease = function()
{
onReleaseFunc();
}
myBall.onReleaseOutside = function()
{
onReleaseFunc();
}
To test this just make a movieclip on your stage and give it an instance name of "myBall"

you'll notice that the problem is, if you try to click and drag the movieclip again before the tween is completed finished, then it doesn't work.

How can you force a stop on a tween?

thank you so very much in advance!!!!

Tween Vs Non-Tween Which Is Intensive On Processor
Im working on a Real time strategy game in AS3 currently, and for unit movement I need to decide whether or not I should use Tweens or looping functions which update the .x and .y parameters of the movieclips on screen.

Currently the game uses Tweens from the start position to end position, with a speed variable defining how fast it should move, but currently there are very few units moving at once. I could however use a looping function which checks to to see which units need to be moved each cycle and moves them accordingly.

The question is which with considerable amounts of units on screen at once would be less processor intensive? OR is there some other method I could use?

End 1st Tween Start 2nd Tween {Newbie}
Hi

I'm thinking of that close all day long I can't find an answer for it.
I want that the mc clip 'rahmen' play's the tween 'move' first and than when the move tween is finishe start to play the 2nd tween 'mover'.

How could I do that?

PHP Code:



stop();

MovieClip.prototype.mover = function(distX, distY, breite, hoehe, speed) {
    this.onEnterFrame = function() {
        this._x += (distX-this._x)/speed;
        this._y += (distY-this._y)/speed;
        this._width += (breite-this._width)/speed;
        if (this._width === breite); {
            this._height += (hoehe-this._height)/speed;
        }
    };
};

MovieClip.prototype.move1 = function(ys, al, tar) {
    this.onEnterFrame = function() {
        this._y -= ys;
        this._alpha += al;
        if (this._y <= tar) {
            delete this.onEnterFrame;
        };
    };
};
    

_root.attachMovie("mc_rahmen", "rahmen", 100, {_alpha:100, _x:200, _y:400});
rahmen.move1(2, 10, 200);
rahmen.mover(200, 200, 200, 100, 40); 




I hope somebody could help me please.

thx a lot

Newbie_AS

Playing Another Tween As The Other Tween Ends
Hi,

I am currently working on a web site and i cannot run a another tween animaton when i click on another button.
i have a main MC( with 4 buttons on it) on the stage and when i click on a button it animates 2 blocks that have been created at runtime and goes from right to left.
What i want is when i click on another menu button, the boolean changes and i must be able the rewind the animation and do another but it does not work.I must click twice, once it rewind and the 2nd one it shows the animation..

Please help as it is quite urgent.

jerome.chevreau@gmail.com

Please please

Thanks

Tween Multiple MovieClips- Some Tween, Some Don't
Hello Kirupa,

here's the class i use:


Code:
package com.fornicode.tween {

import gs.TweenLite;
import flash.text.TextField;
import com.fornicode.utils.*;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.Event;

public class MultiTween {

var $objList:Array = new Array();

public function MultiTween($target, $duration, $vars:Object)
{
for each ( var $obj:MovieClip in $target ) {
var $props:Array= new Array();
$props["x"] = $obj.x;
$props["y"] = $obj.y;
$props["alpha"] = $obj.alpha;
$props["scaleX"] = $obj.scaleX;
$props["scaleY"] = $obj.scaleY;
$props["rotation"] = $obj.rotation;
$props["width"] = $obj.width;
$props["height"] = $obj.height;
$props["obj"] = $obj;
$objList[$obj.name] = $props;
$vars.onComplete =this.tracer;
$vars.onCompleteParams = new Array($props["obj"]);
$vars.persist = true;
TweenLite.killTweensOf($props["obj"], true);
}

for each (var $obj_t in $objList)
{
TweenLite.to($obj_t["obj"] , $duration, $vars);
}
}
public function backToOrigin($duration, $ease)
{
for each ( var $obj_r:Object in $objList ) {
TweenLite.to($obj_r["obj"], $duration, { ease: $ease });
}
}
}
}
all i do is pass an array of movieClips and some tweenLite vars to it, and it should do a mass-tweenLite move to all clips. the problem is only two of eight clips actually "mass-move" the others do nothing. I've exhausted my scope of actionscript. I've tested all sorts of angles: linkage-all the same; "export to first frame" - all the same; tweenlite vars ( killTweensOf all clips before running, persist=true to all). All mc's are place on the stage.

any ideas whatsoever? Thank you in advance to whomever answers!

Caurina Tween - Delay Tween
Hi,

For example if i use caurina tweening class in as3 and i tween my circle, i want to apply multiple tweens, but each tween stage will come after 1 second, here is my code:
Code:
mc.addEventListener(MouseEvent.MOUSE_OVER, function() {
Tweener.addTween(circle, {x:100, y:100, time:1, transition:"easeout"})
Tweener.addTween(circle, {x:150, y:150, time:1, delay:0.1, transition:"easeout"})
});
but my tween second tween is not delaying, can anyone help me with this?

and how could i loop these different tween stages?

MOTION TWEEN Vs. SHAPE TWEEN
What slows down a .swf file more?

I have a site I'm re-doing from scratch, and I see quite a few places I got lazy and used a lot of Movie Clips. I could use shapes and have the same result. The main .swf did suffer from a little slow down...

I've read most of the literature there is on the net [on this subject], and I was wondering what first hand experience some of you had?

I know you're going to say, "It depends...", but I mean...

as a rule... which plays faster/more taxing on the browser?

G

Motion Tween, Tween Back
hey guys, its been a while.

i have a pretty strange problem, strange in the way that i dont understand why its happening, any help would be appreciated.

im creating a bejwelled game.

what im doing is:

when you click on two adjacent blocks, i call a function that uses a motion to swicth them. This works great. The i call a function to test whether the move has resulted in a combintion of >2 blocks. If it returns false, i recall the previouse tweening function to reverse the blocks to their original positions, this is where my script breaks down, it executes the function but nothing moves !

Heres the relavent code:

ActionScript Code:
import mx.transitions.*;
import mx.transitions.easing.*;
 
var bt1:Tween;
var bt2:Tween;
var initBlock:Object = new Object();
var b:Board = new Board(); //external classes no issues here
var g:Game = new Game(); //external classes no issues here
var counter:Number = 0;
var x1:Number;
var x2:Number;
var y1:Number;
var y2:Number;
 
initBlock.onEnterFrame = function() {
    this.onRollOver = function() {
        this.gotoAndPlay("rollOut");
    };
    this.onRollOut = function() {
        gotoAndPlay("rollOut");
    };
    this.onRelease = function() {
        var s:String = this._name;
        getClickCoord(s);
        _root.counter++;
        if(_root.counter == 2){
            _root.x1 = g.fromX;
            _root.x2 = g.toX;
            _root.y1 = g.fromY;
            _root.y2 = g.toY;
           
            if(g.isValidInput()){
                swapBlocks();
                updateMcName();
                updateBlockArray();
                if(isValidMove()){
                    /* ommited for space */
                }else{
                    trace("no combination");
                    //switch position variables
                    var m:Number = _root.x1;
                    _root.x1 = _root._x2;
                    _root.x2 = m;
                    m = _root.y1;
                    _root.y1 = _root.y2;
                    _root.y2 = m;
                    //change everything back
                    swapBlocks();
                    updateMcName();
        updateBlockArray();
                }
            }
            //reset variables
            _root.counter = 0;
            g.fromX = g.fromY = -1;
            g.toX = g.toY = -1;
        }
    }
};
/* ********************************************
* Display blocks
******************************************** */
function display(a:Array) {
    var k:Number = 1;
    for (var i:Number = 0; i<6; i++) {
        for (var j:Number = 0; j<6; j++) {
            var blockName:String = "Block"+k;
            var blockDepth:Number = this.getNextHighestDepth();
            this.attachMovie(a[i][j].__type, blockName, blockDepth,initBlock);
            this[blockName]._x = j*50+100;
            this[blockName]._y = i*50+50;
            k++;
        }
    }
}
/* ********************************************
* Get co-ord of click block, from block name
******************************************** */
function getClickCoord(s:String):Void{
    var x:Number;
    var y:Number;
 
    if(String((Number(s.substring(5)) / 6)).length == 1){
        y = (Number(s.substring(5)/6) - 1)+1;
    }else{
        y = (Number(String(Number(s.substring(5))/6).charAt(0)))+1;
    }
    if(Number(s.substring(5) % 6) == 0){
        x = 6;
    }else{
        x = Number(s.substring(5) % 6);
    }
    if(g.fromX > 0 && g.fromY > 0){
        g.toX = x;
        g.toY = y;
    }else{
        g.fromX = x;
        g.fromY = y;
    }
}
// i knows it an insain way to do it, but it works fine for the moment
/* ********************************************
* Swap Adjacent Block
*      - From (x, y)
*      - To (x, y)
* ******************************************** */
function swapBlocks():Void{
   
    var s:Array = b.getBlock();
    var block1:String = "Block" + String((_root.y1-1)*6 + _root.x1);
    var block2:String = "Block" + String((_root.y2-1)*6 + _root.x2);
   
    if(_root.x1 == _root.x2){
       
        var blockTween1:Tween = new Tween(this[block1], "_y", None.easeNone, this[block1]._y, this[block2]._y, .5, true);
        var blockTween2:Tween = new Tween(this[block2], "_y", None.easeNone, this[block2]._y, this[block1]._y, .5, true);
   
    }else{
       
        var blockTween1:Tween = new Tween(this[block1], "_x", None.easeNone, this[block1]._x, this[block2]._x, .5, true);
        var blockTween2:Tween = new Tween(this[block2], "_x", None.easeNone, this[block2]._x, this[block1]._x, .5, true);
 
    }
   
}
/* ********************************************
* Update MC names
******************************************** */
function updateMcName():Void{
    var s1:String;
    var s2:String;
    var block1:String = "Block" + String((_root.y1-1)*6 + _root.x1);
    var block2:String = "Block" + String((_root.y2-1)*6 + _root.x2);
    s1 = block1;
    s2 = block2;
    this[block1]._name = "bob";
    this[block2]._name = block1;
    this["bob"]._name = block2;
}
// working fine
/* ********************************************
* Update block array
******************************************** */
function updateBlockArray():Void{   // working fine
 
    var s:Array = b.getBlock();
    var t:String = s[_root.y1-1][_root.x1-1].__type;
    s[_root.y1-1][_root.x1-1].__type = s[_root.y2-1][_root.x2-1].__type;
    s[_root.y2-1][_root.x2-1].__type = t;
}
 
display(b.getBlock()); // working fine
 


sorry for the size, i trie to cut out as much as possible.
ive debugged the code a hundred times everything else dose its job, as far as i can tell the tween AS just isnt working.

Thanx in advance.

Copyright © 2005-08 www.BigResource.com, All rights reserved