Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Tween Problem?

Contributor ,
Apr 14, 2013 Apr 14, 2013

I'm loading up images dynamically and trying to get them to tween, but it isn't working as expected (or the way it should)

Once Ive creted the empty movieclip, and load the movie it appears on stage. I have a set interval and then the tweens activate. The problem is only one of them activates (and its the last one). Id like an animation that would move the image off the stage in two directions at the same time (diagnal with a bit of rotation if possible).

Here is the code,

import mx.transitions.Tween;

import mx.transitions.easing.*;

import flash.filters.GlowFilter;

import flash.filters.DropShadowFilter;

import flash.filters.BlurFilter;

import flash.filters.BevelFilter

stop();

TopShelf_mc.swapDepths(100);

this.createEmptyMovieClip("mcHolder", 1);

var myLoader:MovieClipLoader = new MovieClipLoader();

mcHolder._xscale=85;

mcHolder._yscale=85;

mcHolder._rotation=3

mcHolder._x=15;

mcHolder._y=-13;

myLoader.loadClip("Pool.png", mcHolder);

mcHolder.forceSmoothing = true;

var timerone = setInterval(frameOne, 4000)

function frameOne()

{

          var sideways:Tween = new Tween(mcHolder, "_x", Strong.easeIn, mcHolder._x, 312, 3, true);

          var updown:Tween = new Tween(mcHolder, "_y", Strong.easeOut, mcHolder._y, 230, 3, true);

          clearInterval(timerone);

}

Can a movieclip created like I have be tweened ke I want (or would I need to go into some code to do it)

TOPICS
ActionScript
825
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 15, 2013 Apr 15, 2013

use an onMotionFinished handler (applied to your tween) to detect when a tween completes.  in that handler use setTimeout() to call another function that starts the next tween.

Translate
Community Expert ,
Apr 14, 2013 Apr 14, 2013

1. you should wait until loading is complete to start your setInterval.

2.  you should clear your interval before setting it (to prevent run-away intervals).

3. you're only loading one image with that code so your comment about the only one activating makes no sense.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 15, 2013 Apr 15, 2013

I'm trying to understand ways to use setInterval (a simple concept I can't seem to work with =]) Simply Id like to know the best way to tween one object into another with a pause inbetween. I can get one transition to work, when I use another the setinterval gets in the way.

My understanding of inerval: it needs to be set outside a function, and then calls that function in a time set (with a clear), So It starts at launch. When I've tried to place it in a function and then clear it in another function. it didn't clear.

example above:

I can get that first tween to work. The image sits on the stage for 4 seconds and then tweens. When I try to repeat the action it messes up or dosent work, because I've set a setinterval outside a function and triggers but at the wrong spot or inside the next called function (onMotionFinished), but wont clear.

Can you give any clarity on what to do to get the set interval to work properly

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2013 Apr 15, 2013

use an onMotionFinished handler (applied to your tween) to detect when a tween completes.  in that handler use setTimeout() to call another function that starts the next tween.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 15, 2013 Apr 15, 2013

THANK YOU!!! Some new useful code to use. I'll experiment with this.

I went to adobe resource to get a quick view of the code and its use/syntax. It appears that the set inteval in a general timer best used for repeatative (single actions/functions) settimeout is used to switch/delay different functions.

Thank you again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2013 Apr 15, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines