Can't Seem To Get The OnMotionFinished Working
Never used this forum before, so don't even know if I posting in the right place or what I'm doing, sorry! Essentially I'm attempting to make a flash slideshow (yep, YAWN!!, but i've never done it before!).
I'm loading the images externally, there'll be 10 images in total, and numbers 1 to ten listed down the bottom. When a user clicks on a number, the existing image fades out and the one that corresponds to that number fades in. I've only just started with actionscript, below is what I've pieced together so far. The first image fades out, but the second isn't fading in - any ideas why? Many Thanks if anyone can help.
import mx.transitions.Tween; import mx.transitions.easing.*;
this.createEmptyMovieClip("container_mc", this.getNextHighestDepth()); this.createEmptyMovieClip("buttons_mc", this.getNextHighestDepth());
buttons_mc.attachMovie("two","two_mc",buttons_mc.g etNextHighestDepth()) buttons_mc.two_mc._x = 5; buttons_mc.two_mc._y = Stage.height - buttons_mc.two_mc._height - 5;
container_mc.loadMovie("images/firstimage.jpg");
function fadeIn() { var MyfadeIn = new Tween(container_mc,"_alpha",Strong.easeOut,0,100,3 6,false); }
function fadeOut() { var MyfadeOut = new Tween (container_mc,"_alpha",Strong.easeOut,100,0,36,fal se); }
buttons_mc.two_mc.onRelease = function() { fadeOut();
MyfadeOut.onMotionFinished=function(){ container_mc.loadMovie("images/secondimage.jpg"); fadeIn(); }
}
FlashKit > Flash Help > Flash Newbies
Posted on: 07-26-2008, 03:08 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
OnMotionFinished Not Working
I've done a search and looked at posts from others with the same problem but I can't seem to find the fix for my code.
I've created a set of movieclips that I want to play one after the other but I want them to fade in, play then fade out. So I've written some code to do this but it doesn't seem to call the fadeout.onMotionFinished function.
Any help is most appreciated, my code is below:
PHP Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
this.stop();
var cf:Number;
var tf:Number;
var target_mc:MovieClip;
var link:Object;
var fadein:Object;
var fadeout:Object;
mcfinish = new Object();
addListener(mcfinish);
mcfinish.onEnterFrame = checkplay;
this.createEmptyMovieClip("container", this.getNextHighestDepth());
target_mc = container.attachMovie("mc", "mc_1", this.getNextHighestDepth(), {_x:0, _y:0});
fadein = new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 1, true);
this.createEmptyMovieClip("btn", this.getNextHighestDepth());
link = btn.attachMovie("link", "btn_1", this.getNextHighestDepth(), {_x:0, _y:0});
link._alpha = 0;
link.onRelease = function() {
getURL("", "_self");
};
fadein.onMotionFinished = function() {
target_mc.gotoAndPlay(2);
};
checkplay = function () {
cf = target_mc._currentframe;
tf = target_mc._totalframes;
if (cf == tf) {
fade();
}
};
fade = function () {
fadeout = new Tween(target_mc, "_alpha", Strong.easeIn, 0, 100, 1, true);
};
fadeout.onMotionFinished = function() {//this function isn't called!
trace("The tween is dead! Long live the new tween!");
};
OnMotionFinished() Not Working Anymore?
Ok, for my site i have a preloader that slides in, then it slides out once it's finished. I decided to change a couple things, now the same file with some unrelated changes is giving me syntax errors when publishing it. Heres some code:
ActionScript Code:
import mx.transitions.Tween;preloader.bar._visible = false;container._x = container._y=0;var preloadTween:Tween = new Tween(preloader, "_x", mx.transitions.easing.Regular.easeOut, Stage.width+100, 428.9, .5, true);preloadTween.FPS = 30;preloadTween.onMotionFinished = function() { my_mc = new MovieClipLoader(); preload = new Object(); my_mc.addListener(preload); preload.onLoadStart = function(targetMC) { container._visible = false; preloader.bar._visible = true; preloader.border._visible = true; }; preload.onLoadProgress = function(targetMC, lBytes, tBytes) { preloader.bar._xscale = (lBytes/tBytes)*100; }; preload.onLoadComplete = function(targetMC) { var preloadDoneTween:Tween = new Tween(preloader, "_x", mx.transitions.easing.Regular.easeIn, 428.9, Stage.width*0.1-500, .5, true); preloadDoneTween.FPS = 30; preloadDoneTween.onMotionFinished = function() { container._visible = true; preloader.border._visible = false; preloader.bar._visible = false; }; }; trace(container._x); my_mc.loadClip("jj.swf", "container"); container._lockroot = true;};
Im getting this in the output window:
Code:
**Error** Scene=Scene 1, layer=actions, frame=1:Line 6: There is no property with the name 'onMotionFinished'.
preloadTween.onMotionFinished = function() {
**Error** Scene=Scene 1, layer=actions, frame=1:Line 21: There is no property with the name 'onMotionFinished'.
preloadDoneTween.onMotionFinished = function() {
Total ActionScript Errors: 2 Reported Errors: 2
[F8] Whaaat..? OnMotionFinished Just Stopped Working? Or Am I Blind And Miss The Bug?
hi!
now this may seem a silly supernoob problem, but i've used this command a thousand and two times. now it suddenly stopped working. It's an onMotionFinished function, code below. i've included a fla for you to take a look. never mind about the clumsy graphics, i stumbled into this problem before i even got started with the site. if i don't get it right, i never get further. pleeeeeease help, i'm really puzzled with this one!
Code:
stop();
myTween = new mx.transitions.Tween(boy, "_xscale", easeType, 44, 100, 65);
myTween = new mx.transitions.Tween(boy, "_yscale", easeType, 44, 100, 65);
myTween = new mx.transitions.Tween(boy, "_x", easeType, 77, 199, 65);
myTween = new mx.transitions.Tween(boy, "_y", easeType, 138, 125, 65);
myTween.onMotionFinished=function(){
gotoAndStop("turn");
boy.gotoAndStop("boystop");
}
code explanation: i have this mc with an instance name boy. after the tween, the walking boy comes to a halt (frame called boystop in boy_mc), and then i basically wish the main timeline move forward. in this example to a frame called "turn". the problem: boy halts ok but main timeline never moves forward.
OnMotionFinished
Hi,
I tried to use onMotionFinished two times, but it doesn't work when I do it like this (the third tween doesn't happen):
code:
lineTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
lineTween.onMotionFinished = function() {
linebackTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 0, 200, 1, true);
}
linebackTween.onMotionFinished = function() {
linebackagainTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
}
Does anyone know why not, or have a solution?
Thanks!
Jerryj.
OnMotionFinished In AS 3.0
Hi, I've just finished taking a 5 week Flash course and am having major Action Script issues with my final project!
I need to use a loader to load my homepage content onto an element that has slid into place using a transition. Below is the code for this transition. I was told that using
the onMotionFinished function is the best way to go, but it doesn't seem to exist in 3.0?? Either that or I'm writing my code incorrectly - Entirely possible!
So, my question is: How can I add a child to the stage in a specific position after a transition has taken place?
If I'm adding an event listener, how do I call the function if I just want it to happen automatically when the transition is finished?
If I then want the loaded element to slide to another position (upon loading - not from a mouse click or anything), how do I do this?
Please help!
Many thanks,
Scott
import fl.transitions.*;
import fl.transitions.easing.*;
function homeClick(myevent:MouseEvent):void{
this.home_btn.mouseEnabled = false;
var home_up:Object = new Tween(homelp_mc, "y", Strong.easeOut, 310, 15, 1.5, true);
this.homelp_mc.play();
}
this.home_btn.addEventListener(MouseEvent.MOUSE_UP , homeClick);
OnMotionFinished X 3? Possible
Im trying to get a shutter to come down, then pause for 2 seconds once its down. Then raise back up off the stage and onMotionFinished gotoandPlay a key frame on the root.
I know this is a very messy way to do it (shamefully), but its not working because of the x3 onMotionFinished I think. Does anybody know of a much cleaner way to make this happen?
on (release) {
Shutterdown = new mx.transitions.Tween(shutter, "_y", mx.transitions.easing.Regular.easeOut, shutter._y, 225, 2, true);
Shutterdown.onMotionFinished = function() {
Shutterpause = new mx.transitions.Tween(shutter, "_y", mx.transitions.easing.Regular.easeIn, shutter._y, 225, 2, true);
}
Shutterpause.onMotionFinished = function() {
nextframe = new mx.transitions.Tween(shutter, "_y", mx.transitions.easing.Regular.easeIn, shutter._y, -220, 1, true);
}
nextframe.onMotionFinished = function() {
gotoAndStop("1stscene");
};
}
Help With OnMotionFinished
I have a series of MovieClips that Tween either horizontally or vertically. When one of the clips reaches the outer edge of the stage, the Tween is finished, onMotionFinished is called and the MovieClip is removed from the stage using
Code:
instanceName.removeMovieClip();
However, if one of the horizontally moving clips happens to collide with a vertically moving clip, I want the clips to be removed at that point instead of once they reach the edges of the stage. So far I'm accomplishing that with the following
Code:
if(instanceName.hitTest(instance2Name)){
instanceName.removeMovieClip();
instance2Name.removeMovieClip();
}
The problem is that even when I delete the MovieClip due to a collision, the Tween seems to still exists and once the removed MovieClips reach the end of the stage (even though they arent visible, there is an obvious delay that seems to indicate that they still exist and are still Tweening) the onMotionFinished function is called and therefore tries to remove the MovieClip a second time.
When there is a collision do I need to delete the Tween object as well as removing the MovieClip?
Does anyone know why this is happening?
Help's appreciated.
Cheers.
OnMotionFinished = Help Please
I am using onMotionFinished for my functions that are being declared with local variables and everything is currently working; however, I am wanting to play another movie clip AFTER the one that is already being executed from the onMotionFinished function ...
If you take a look at my code below, you can see how I set it up.
I will make a notation in the area in which I want the next movieclip played out with >>> symbols.
----------------------------------------------- thanx a bunch -------------------------------------------------
Attach Code
//pieces of code or capabilities of code that need to be called in order to work
import mx.transitions.Tween;
import mx.transitions.easing.*;
var AEL1:Tween =new Tween(A_mc, "_y", Regular.easeOut, 34.9, 44.9, 0.3, true);
new Tween(A_mc, "_y", Regular.easeIn, 44.9, 34.9, 0.3, true);
AEL1.onMotionFinished = function(){
var AEL2:Tween =new Tween(U_mc, "_y", Regular.easeOut, 34.9, 44.9, 0.3, true);
new Tween(U_mc, "_y", Regular.easeIn, 44.9, 34.9, 0.3, true);
AEL2.onMotionFinished = function(){
var AEL3:Tween = new Tween(T_mc, "_y", Regular.easeOut, 34.9, 44.9, 0.3, true);
new Tween(T_mc, "_y", Regular.easeIn, 44.9, 34.9, 0.3, true);
AEL3.onMotionFinished = function(){
var AEL4:Tween = new Tween(O, "_y", Regular.easeOut, 34.9, 44.9, 0.3, true);
new Tween(O_mc, "_y", Regular.easeIn, 44.9, 34.9, 0.3, true);
AEL4.onMotionFinished = function() {
email_mc.play(); //same thing as gotoAndPlay(2)
// >>> here is where i want the next movieclip to play
// >>> man_mc.play()
// >>> but how do i get it to play AFTER the movieclip, email_mc.play() is finished?
}
}
}
}
stop();
OnMotionFinished
Hi,
I tried to use onMotionFinished two times, but it doesn't work when I do it like this (the third tween doesn't happen):
Quote:
lineTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
lineTween.onMotionFinished = function() {
linebackTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 0, 200, 1, true);
}
linebackTween.onMotionFinished = function() {
linebackagainTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
}
Does anyone know why not, or have a solution?
Thanks!
Jerryj.
OnMotionFinished
Hi there,
I seem to have used a rather odd-working onMotionFinished handler. When I trace something inside it, it works fine. But when I call another function, nothing happens. Any ideas?
ActionScript Code:
t.onMotionFinished = function() {
trace("hooah"); // works fine
}
but!
t.onMotionFinished = function() {
anotherFunction(); // doesn't do anything
}
Help With The OnMotionFinished
Code:
private function scaleMc(mc:MovieClip, a:Number, z:Number):Boolean {
var elasticWidth:Tween = new Tween(mc, "_width", Elastic.easeOut,a,z,3,true);
var elasticHeight:Tween = new Tween(mc, "_height", Elastic.easeOut,a,z,2,true);
elasticHeight.onMotionFinished = function () {isFinished = true}
trace(isFinished);
return isFinished;
}
This function is declared in a custom class.
Is that true that the onMotionFinished cant work within a custom class? (isFinished always return false which is its default value)
Any helps would be great
.onMotionFinished()
hello hello.
I have this giant animation which follows sub-animation after sib-animation -- all using the .onMotionFinished() function.
If you check out the version which I've uploaded, they all follow the .onMotionFinished() process. However, is their a way to start the NEXT animation before the PREVIOUS one finishes? I want to create a quick flow to it.
FLA: http://www.tsaconas.com/harminder/ro.../flash/top.fla
SWF: http://www.tsaconas.com/harminder/ro.../flash/top.swf
Thanks.
OnMotionFinished Help
I have this function
Code:
function createLoader(i, data, num) {
thisLoader = eval("container_mc.loader"+i+"_mc");
thisLoader._alpha = 0;
thisLoader.loadMovie(data[num].path);
c.capela.text = data[num].cap;
watcher_mc.onEnterFrame = function() {
var picLoaded = thisLoader.getBytesLoaded();
var picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes<4) {
return;
}
if (picLoaded/picBytes>=1) {
swapPlace("container_mc.loader2_mc", 1);
c.alpha(data[num].fadeTime, 100);
thisLoader.alpha(data[num].fadeTime, 100);
timerInterval = setInterval(imageGen, data[num].timer, data);
delete this.onEnterFrame;
}
};
}
I want movie clip c to fadein "data[num].fadeTime" after thisLoader. and Fade Out data[num].fadeTime before thisLoader fade out. theLoader duration is "data[num].timer" so we have all requided vars.
e.g. fade = 2, timer = 8,
image fadein duration fadeout
2 + 8 + 2
How can I say to movieclip c wait "data[num].fadeTime" then fade in "data[num].fadeTime" + stay "data[num].timer" minus "data[num].fadeTime * 2 " and fadeout data[num].fadeTime.
I bold that paret where I try it but this can be out of this function too.
its a bit complicated, but for a AS coder, not so. Im designer not coder.
OnMotionFinished
Hi,
I tried to use onMotionFinished two times, but it doesn't work when I do it like this (the third tween doesn't happen):
Quote:
lineTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
lineTween.onMotionFinished = function() {
linebackTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 0, 200, 1, true);
}
linebackTween.onMotionFinished = function() {
linebackagainTween = new mx.transitions.Tween(lijnMC, "_x", mx.transitions.easing.Strong.easeOut, 200, 0, 1, true);
}
Does anyone know why not, or have a solution?
Thanks!
Jerryj.
Tween + OnMotionFinished
I've got the following code in my actionscript class. When the onMotionFinished is run, it is not referencing my class to execute the slide() method. How would I properly do this?
Code:
var tween = new mx.transitions.Tween(target, "_y", easeType, beginPos, endPos, slideSpeed);
tween.onMotionFinished = function() {
this.slide();
}
Of course I can always go through the instance of my class like the following example, but that is not good practice.
Code:
_root.myInstance.slide();
[F8] OnMotionFinished And Globals
I'm trying to call something when a tween motion is finished. However it isn't working. I believe it is because the tween is being created in a function. I tried assigning global to it, but flash doesn't allow that for strict data types according to documentation. I call the glideup() function from a button. That part works, but the trace("finished") doesn't.
Here is my code:
Code:
//makes the logo glide up
function glideup() {
var yMove:Tween = new Tween(mylogo, "_y", Bounce.easeOut, mylogo._y, mylogo._y - 160, 2, true);
}
//after glideup() is finished, this is called
yMove.onMotionFinished = function() {
trace("finished");
}
[F8] Array Into OnMotionFinished
Hi
I've have made an array which doesn't go into the onMotionFinished function, can anyone tell why???
Code:
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var my_arr:Array = new Array();
my_arr.push({name:mc_1, x:050, y:100, duration: 20});
my_arr.push({name:mc_2, x:150, y:175, duration: 100});
my_arr.push({name:mc_3, x:250, y:225, duration: 40});
for (i=0; i<3; i++) {
var tween_1:Object = new Tween(my_arr[i].name, "_y", Elastic.easeOut, my_arr[i].y, my_arr[i].y+100, my_arr[i].duration, false);
tween_1.onMotionFinished = function() {
trace(my_arr[i].name);
var tween_2:Object = new Tween(my_arr[i].name, "_y", Elastic.easeOut, my_arr[i].y+100, my_arr[i].y-100, 50, false);
trace("2");
}
}
Thank You
1966
OnMotionFinished Problem
Hi there I am having a problem
myTween2.onMotionFinished = function() { never gets called but
myTween.onMotionFinished = function() { does get called!!
Im trying to run each tween once the one before it has finished.
Code:
import mx.transitions.*;
import mx.transitions.easing.*;
var myTween = new mx.transitions.Tween(boxmc, "_xscale", mx.transitions.easing.Regular.easeInOut, 0, 7500, 1.5, true)
myTween.onMotionFinished = function() {
var myTween2 = new mx.transitions.Tween(boxmc, "_yscale", mx.transitions.easing.Regular.easeInOut, 100, 2000, 1, true)
}
myTween2.onMotionFinished = function() {
trace('i been called');
boxmctwo._visible = true;
var myTween3 = new mx.transitions.Tween(boxmctwo, "_xscale", mx.transitions.easing.Regular.easeInOut, 0, 7500, 1.5, true)
}
OnMotionFinished Problem
Heylo,
I'm using the mx.transition.Tween class to tween a movieclip. After the tween i want it to execute some code. However when using the 'onMotionFinished' function it doesnt seem to work in FireFox, only IE. Does anyone have an idea?
Heres the code i used:
Code:
toMiddleTween = new mx.transitions.Tween(_root.mc,"_y",mx.transitions.easing.Regular.easeOut,_root.mc._y,targy,1,true);
toMiddleTween.onMotionFinished = function () {
_root.loadTemplates(null);
};
Thanks!
Help, Using Lacoz And Onmotionfinished
I've switch the using the lacoz script (lmc_tween.as) and now my onMotionFinished function doesn't work. What is equivalent to the onmotionfinished in order to get this to work?
Tweens And OnMotionFinished...
Heya folks,
Been awhile since I have a flash problem (yay me!) but I've got a rather odd one and am hoping someone here can tell me where I'm going wrong.
Basically I have a loop, where I loop through a series of MC's, and if required a tween is applied to them. However, I would like to kick off some further actionscript ONCE THE TWEEN IS DONE.
Here's what I have, but it doesn't work (the onMotionFinished code never executes):
ActionScript Code:
var shiftTween:Tween = new Tween();
for (a in _root.queuePanel.queueItems.navigation) {
if (typeof(_root.queuePanel.queueItems.navigation[a]) == "movieclip") {
if (_root.queuePanel.queueItems.navigation[a]._x <= (dropIndex * 72) + 6 ) {
shiftTween = new Tween(_root.queuePanel.queueItems.navigation[a], "_x", mx.transitions.easing.Strong.easeOut, _root.queuePanel.queueItems.navigation[a]._x, _root.queuePanel.queueItems.navigation[a]._x - 72, 0.5, true);
//_root.queuePanel.queueItems.navigation[a]._x -= 72;
}
}
}
shiftTween.onMotionFinished = function() {
this._parent._alpha = 100;
this._parent._x = (dropIndex * 72) + 6;
}
If I move the onMotionFinished function inside the for...loop, it gets called too many times (but it does work). Am thinking this is some kind of scoping issue but I thought my declaration prior to the for...loop would have solved that...
Any ideas?
This was my original working code, FYI:
ActionScript Code:
for (a in _root.queuePanel.queueItems.navigation) {
if (typeof(_root.queuePanel.queueItems.navigation[a]) == "movieclip") {
if (_root.queuePanel.queueItems.navigation[a]._x <= (dropIndex * 72) + 6 ) {
_root.queuePanel.queueItems.navigation[a]._x -= 72;
}
}
}
this._parent._alpha = 100;
this._parent._x = (dropIndex * 72) + 6;
OnMotionFinished Question
I'm new to using AS to tween my movieclips...
The tweens work great!!!
I'm trying to have the movieclip the actions are placed in go to the next frame when the tweens are done.
My first "onMotionFinished" works fine, but my second one does not trace anything or send the timeline anywhere. Any help on this would be greatly appreciated!
-John
Here is the code I have:
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var morphXscaleT:Tween = new Tween(morphBG_mc, "_rotation", Elastic.easeOut, 60, 0, 1, true);
var morphXposT:Tween = new Tween(morphBG_mc, "_x", Elastic.easeOut, 0, -196, 1, true);
var morphYposT:Tween = new Tween(morphBG_mc, "_y", Elastic.easeOut, -200, 0, 1, true);
morphYposT.onMotionFinished = function(content_mc:MovieClip) {
trace("first one worked");
var menuXscaleT:Tween = new Tween(menuBG_mc, "_rotation", Elastic.easeOut, 60, 0, 1, true);
var menuXposT:Tween = new Tween(menuBG_mc, "_x", Elastic.easeOut, 300, 160, 1, true);
var menuYposT:Tween = new Tween(menuBG_mc, "_y", Elastic.easeOut, 190, 81, 1, true);
};
menuYposT.onMotionFinished = function() {
trace("second one worked");
this.nextFrame();
};
OnMotionFinished Helpfile Example
can anyone get this example to work?
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001502.html
i tried also the comment example..none of them worked for me.
OnMotionFinished Issue
Hey guys,
I have this problem - I have declared a function which consists of few tweens.
I also declared another function which is calling the "onMotionFinished" state from the previous function but for some reason this doesn't work .... are there some restrictions on this onMotionFinished function or whatsoever please?
I tried to look for something online, no success.
here's a code example:
var newFUNCTION = function(){
var MAINMENUTween:Tween = new Tween(mainMOVIE, "_x", Regular.easeIn, getProperty(mainMOVIE, _x), 0, 1, true);
}
var newFUnctionXX = function(){
MAINMENUTween.onMotionFinished = function() {
trace("working!");
}
}
this is exactly what's not working....which is weird since when you put it there with no "extra" functions (holderLoad etc.) it works (!)
Many thanks for your help, I am really stuck.
L.
Tween + OnMotionFinished
I've got the following code in my actionscript class. When the onMotionFinished is run, it is not referencing my class to execute the slide() method. How would I properly do this?
Code:
var tween = new mx.transitions.Tween(target, "_y", easeType, beginPos, endPos, slideSpeed);
tween.onMotionFinished = function() {
this.slide();
}
Of course I can always go through the instance of my class like the following example, but that is not good practice.
Code:
_root.myInstance.slide();
OnMotionFinished Trouble
Okay, Ive got a slideshow and for the slideshow counter I've decided to use a bar and tween classes to make it look nicer. I want it to grow slowly, then when it finishes switch the image, then shoot back and start again... Currently I have
ActionScript Code:
var slideCounter:Tween = new Tween(slideBar, "_width", Regular.easeIn, 0, 640, 5, true);slideCounter.onMotionFinished = function() { if (slideBar<=0) { this.continueTo(640, 5); } else { this.continueTo(0, 1.5); }};
Now I'm begining to understand that onMotionFinished will only work only from the tweens position... It goes back but doesn't restart itself again?
Anyone with any suggestions?
Dave
Targeting From OnMotionFinished
ActionScript Code:
var tY:Tween = new Tween(this, "_y", Strong.easeOut, this._y, centerY, 1, 1);tY.onMotionFinished = function() { trace("finished"); this.play();};
Anyone know how I can target the MC which was being moved by the tween from inside the onMotionFinished function? I've tried
ActionScript Code:
tY.play();
as well.
I think I'm making a stupid mistake somewhere because I have done this before...
Thank you in advance!
OnMotionFinished Error
I get an error when I try to call 'onMotionFinished'
Its telling me there is no property with that name.
Here's my code
What am I doing wrong?
ActionScript Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
//new mx.transitions.Tween(ball_mc, "_x", mx.transitions.easing.Elastic.easeOut, 0, 300, 3, true);
var _xMove:Tween = new Tween(ball_mc, "_x", Elastic.easeOut, 0, 300, 30, false);
var _xMove:Tween = new Tween(ball_mc1, "_x", Elastic.easeOut, 0, 300, 1, true);
//
_xMove.onMotionFinished = function() {
//place your action here
trace("onMotionFinished triggered");
}
//
OnMotionFinished Questions...
Hello.
So, I've got a tween that I want to basically activate a button after it's done. I'm using onMotionFinished to accomplish this, but i was wondering if there is a way to reset it so that the next time someone rolls over, the button isn't already activated from before. Any thoughts?
Thanks
Using OnMotionFinished With Tween Class
I am using the Macromedia Tween classes which accompany Flash MX 2004. I am having difficulties using the onMotionFinished callback though. I am getting this error:
There is no property with the name 'onMotionFinished'.
I have used this many times before without difficulty, but this time I am trying to define it within an AS2 class. If I put the code on the timeline, there is no problem. Also the tween itself works fine, it is just the onMotionFinished event which does not fire.
This is the code:
xscaleTween = new mx.transitions.Tween(clip, "_xscale", easeType, clip._xscale, scale, randomTime, true);
xscaleTween.onMotionFinished = function () {
trace ("hello");
}
Ideas anyone?
OnMotionFinished Function ActionScript 3.0?
Hi, I've just finished taking a 5 week Flash course and am having major Action Script issues with my final project!
I need to use a loader to load my homepage content onto an element that has slid into place using a transition. Below is the code for this transition. I was told that using
the onMotionFinished function is the best way to go, but it doesn't seem to exist in 3.0?? Either that or I'm writing my code incorrectly - Entirely possible!
So, my question is: How can I add a child to the stage in a specific position after a transition has taken place?
I shouldn't need an event listener for this, right?
If I then want the loaded element to slide to another position (upon loading - not from a mouse click or anything), how do I do this? Do I use the same 'onMotionFinished' function t trigger the transition?
Please help!
Many thanks,
Scott
import fl.transitions.*;
import fl.transitions.easing.*;
function homeClick(myevent:MouseEvent):void{
this.home_btn.mouseEnabled = false;
var home_up:Object = new Tween(homelp_mc, "y", Strong.easeOut, 310, 15, 1.5, true);
this.homelp_mc.play();
}
this.home_btn.addEventListener(MouseEvent.MOUSE_UP , homeClick);
OnMotionFinished, Capture The Movieclip
Heylo,
I'm experimenting with the mx.transitions class, and i've run into a problem.
Here's the code i used
Code:
_global["vogeltjeVliegt"+_global.nr] = new mx.transitions.Tween(_root.vogeltje["vogel"+_global.nr],"_x",mx.transitions.easing.None.easeNone,800,-30,4,true);
_global["vogeltjeVliegt"+_global.nr].onMotionFinished = function () {
_global["vogeltjeVliegt"+_global.nr].removeMovieClip();
}
_global.nr++;
This script will be called multiple times per second.The movieclip _root.vogeltje["vogel"+_global.nr] will fly from right to left.
Now when its done flying I want to remove the movieclip. Is there some way to catch the name of the variable which called the onMotionFinished function, so i can substract the nr in it, and with that remove the actual movieclip?
Code:
_global["vogeltjeVliegt"+_global.nr].removeMovieClip();
wont work since _global.nr has increased when the first movieclip reaches his end point.. Any thoughts?
OnMotionFinished ContinueTo BUGGIN OUT Plz Hlp
check this out plz
www.mattvoran.net
okay so all i want is when a link is clicked, the upper box slides out and then back. Its weird it seems to work the very first time but then bugs out after that. here is my code. I am not a pro at this so any hints would be great!
//just one button here, others deleted for space
links_mc.about_btn.onRelease = function() {
contentTween(_root.content_mc, 350, -500, 1);
};
//Function definition
function contentTween(which, start, end, time) {
var content = new mx.transitions.Tween(which, "_x", mx.transitions.easing.Strong.easeOut, start, end, time, true);
content.onMotionFinished = function() {
this.continueTo(350);
};
}
Thanks.
Tween Class Help OnMotionFinished
I have this code:
Code:
import mx.transitions.Tween;
//
import mx.transitions.easing.*;
//
this.trace ();
//
var depth = this.getNextHighestDepth ();
//
var io = {_x:200, _y:1, _alpha:0, _visible:true};
//
this.attachMovie ("eclipse", "oneeclipse", depth, io);
this.attachMovie ("eclipse2", "twoeclipse", depth, io);
//
var alpha1:Tween = new Tween (oneeclipse, "_alpha", Strong.easeIn, 0, 100, 5, true);
alpha1.onMotionFinished = function () {
var alpha2:Tween = new Tween (oneeclipse, "_alpha", Strong.easeIn, 100, 0, 5, true);
var alpha3:Tween = new Tween (twoeclipse, "_alpha", Strong.easeIn, 0, 100, 10, true);
}
//
The thing is it is only executing the alpha3 variable. Been playing with it for hours and I have read up on onMotionFinished from a number of tutorials but still no luck. I am trying to fade the first image in then as i fade it back out i want to fade the second image in and so on.
Tweening Prototypes And OnMotionFinished?
i recently started scripting using the tweening prototypes.
http://laco.wz.cz/tween/?page=docs/getTweens
it's so much easier than the old mx.transitions that i was using... but i haven't found one crucial element in the prototypes:
onMotionFinished
is there any way to trigger another function after a tween is finished?
for example:
circle.slideTo(200, 150, 1, "EaseOutExpo");
slideTo.onMotionFinished.gotoAndPlay(30);
-alex-
OnMotionFinished / Scope Problem
I'm currently figuring my way through mtasc and swfmill. And things are going pretty well. However, I've stumbled on a problem which I hope someone might be able to help me with. Again, I'm no expert (learning to be, tho), I basically manage to get things working by figuring out examples on the net.
Here's the class that's giving me problems
Code:
class Pane
{
var nr:Number;
var showPic:Boolean;
var mult:Number = 0.5;
var timemult:Number = 5;
var radius:Number = 80;
var paneWidth:Number = 340;
var paneHeight:Number = 190;
var posX:Number;
var posY:Number;
var sec:Number;
var xTween:Tween;
var yTween:Tween;
function Pane (nr:Number, showPic:Boolean)
{
this.nr = nr;
this.showPic = showPic;
this.paneWidth = Math.floor(this.paneWidth*this.mult);
this.paneHeight = Math.floor(this.paneHeight*this.mult);
this.getNewPosition();
this.colorPane();
}
function getNewPosition ():Void
{
var direction:Number = Math.random()*360; // Set random direction (degrees)
var radius:Number = Math.random()*this.radius; // Set random distance (radius)
this.posX = Math.cos(direction)*radius; // Resolve x position
this.posY = Math.sin(direction)*radius; // Resolve y position
this.sec = (Math.random()*5+6)/this.timemult;
}
function colorPane ()
{
var panename:String = "colorPane_"+this.nr;
var pane:MovieClip = eval("_root.masterPane_"+this.nr).createEmptyMovieClip(panename, _root.getNextHighestDepth()); // Create colored pane
pane._x = this.posX;
pane._y = this.posY;
with (pane) {
beginFill(0x000000, 100);
moveTo(0-this.paneWidth/2, 0-this.paneHeight/2);
lineTo(this.paneWidth/2, 0-this.paneHeight/2);
lineTo(this.paneWidth/2, this.paneHeight/2);
lineTo(0-this.paneWidth/2, this.paneHeight/2);
lineTo(0-this.paneWidth/2, 0-this.paneHeight/2);
endFill();
}
this.getNewPosition();
// Set initial movement
var xTween:Tween = new Tween(pane, "_x", Regular.easeInOut, pane._x, this.posX, this.sec, true);
var yTween:Tween = new Tween(pane, "_y", Regular.easeInOut, pane._y, this.posY, this.sec, true);
// Now, keep moving
xTween.onMotionFinished = function ()
{
this.getNewPosition();
// Continue movement
xTween.continueTo(this.posX, this.sec);
yTween.continueTo(this.posY, this.sec);
};
}
}
This doesn't work, and I can't get it to work. I've been looking for a solution over half a day now.
The problem is that I want to create new coordinates for continueTo by calling this.getNewPosition() in the anonymous function for onMotionFinished. However, in the anonymous function I can't seem to get access to this.posX.
I've tried to create a new function to use as a callback for onMotionFinished, but I haven't managed to find a way to make that work at all. (This solution would have my preference!)
Anyone?
Successive Tweens Using OnMotionFinished
Hi everybody,
I'd like to build a sequence of successive tweens which would look like this : first a movie clip is scaled using some easing function. When the first tween is completed, a second movie clip is faded using another easing function, etc... I guess I should use the onMotionFinished event handler but I can't figure out how. If somenone can help me... Thank you very much, best regards
Here is my code :
import mx.transitions.Tween;
import com.robertpenner.easing.*;
/////////////////////////////////////////////////////////////////////////////////////
var tw:Object;
/////////////////////////////////////////////////////////////////////////////////////
function doTw(t:MovieClip, p:Object, e:Object, b:Number, f:Number, d:Number) {
delete tw;
tw = new Tween(t, p, e, b, f, d);
}
function lNav() {
doTw(m_mc, "_xscale", Cubic.easeOut, 100, 0, 25);
}
/////////////////////////////////////////////////////////////////////////////////////
lNav();
A Fuse Equivalent To OnMotionFinished ?
Hi all,
I'm quite new to this amazing tool that is Fuse, and I was wondering how do you script the callBack method equivalent to "onMotionFinished" of the mx package ?
Thanks to you guys
David
OnMotionFinished = Function Confusion?
I have a simple tween,
But when I use the onMotionFinished = function() {
This function has no access to by member variables unless they are static, this is driving me nuts, I've tried every combination of things but can't work it out.
I believe it's because the tween is a new object thus only has access to it's own properties.
I have my MovieClip as a member variable and need to be able to tween it somewhere then back again.
Buttons With OnMotionFinished Problem
Hello folks.
I would really need your help! =O
I've got a movie with 6 buttons. Each button will tween(motion)/play when pushed/activated("activated mode") and then tweened back to "inactivated mode" when unclicked/inactivated. and so far so good. Easy =P. but I want for example; If i push/activates button A and then pushes button B, I want the A button to tween back to "inactivated mode" and then(when done) the B button should animate to activated mode. And thats where I can't solve it =S Ive tried with Tween.onMotionFinished = function() but can't get that to work!
Anyone got any idea how to solve this in any easy way? How would you do it?
I really need this.
Sorry for the grammar ^_^
plenty Thanks!! =)
EDIT:
Tell me if you didn't understood what I meant =)
Preloader And OnMotionFinished Problem
Hello, i stumbled across a kinda big problem when i was setting up my preloader, I asked this at dynamicdrive to but im getting kinda frustrated now as I only have two days left on this project.
first of all:
I just found out that my tween doesnt work if I use "export frame to classes <the frame after the loading>" which I have to select if I want the loading to work properly. But I have a tween on my preloader frame, is there a way to solve this?
second question:
When the preloader is done it will jump to the other frame (frame 2) and it wont complete the tween unless you have to load longer then the tween is so I though I would also use an onMotionFinished but it doesnt work, this is how it looks like:
Code:
var slide:Tween = new Tween(holder, "_x",Regular.easeOut, 800, Stage.width / 2, 0.5, true);
this.onEnterFrame = function() {
var amount:Number = this.getBytesLoaded() / this.getBytesTotal() * 100;
holder.loader._xscale = amount;
var loader_text = Math.floor(amount);
holder.load_text.text = loader_text + "%";
if(amount == 100) {
slide.onMotionFinished = function() {
this.gotoAndStop(2);
delete this.onEnterFrame;
}
}
}
I cant really figure out how to fix this so would really appreciate if someone could point me to the right direction.
OnMotionFinished For A Tween In A Class
I have a class, in the class there is a tween. i want to trigger a couple of events when the the tween starts, and also when it finishes. but both events don't seem to trigger, can anyone tell me why?
Version 1:
ActionScript Code:
/**
Load Sub Stage class
author: Ahmed I. Masri
version: 1.1
modified: 08/11/2008
copyright: Ahmed I. Masri
This code defines a custom class that loads the correct sub movie.
*/
// Import Built-In Classes
import mx.utils.Delegate;
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Class to Load SubStages
class LoadSubStage {
// Variable Definitions
var Container:MovieClip;
var StageLoader:MovieClipLoader;
var Listener:Object;
var Preloader:MovieClip;
// Constructor Function to Select SubStage and prepare Stage
public function LoadSubStage(linkToFile:String) {
if (linkToFile != "intro_stage.swf") return;
LIntroStage(linkToFile);
}
// Constructor Function to PreLoad and present Intro SubStage
private function LIntroStage(linkToFile):Void {
// Variable definitions
StageLoader = new MovieClipLoader();
Listener = new Object();
StageLoader.addListener(Listener);
// Empty Movie Clip to place Intro SubStage
Container = _root.createEmptyMovieClip("MC_emptyHolder", _root.getNextHighestDepth());
Container._x = 0;
Container._y = 55;
// Function to handle (pre)loading
Listener.onLoadStart = Delegate.create(this, onLoadStart);
Listener.onLoadProgress = Delegate.create(this, onLoadProgress);
Listener.onLoadInit = Delegate.create(this, onLoadInit);
Preloader = _root.attachMovie("MC_stageLoader", "MC_stageLoader" , _root.getNextHighestDepth(), {_x:400, _y:261.5});
Preloader.MC_loadingProgressBar._width = 0;
Preloader.txt_PercentLoaded.text = "00";
// Loading of SubStage
StageLoader.loadClip(linkToFile, Container);
}
// Function to handle start of (pre)loading
private function onLoadStart() {
Container._visible = false;
}
// Function to handle progress of (pre)loading
private function onLoadProgress(mc:MovieClip, l:Number, t:Number):Void {
Preloader.MC_loadingProgressBar._width = (l / t) * (Stage.width * 1.2);
Preloader.txt_PercentLoaded.text = Math.round((l / t) * 100);
}
// Function to handle completion of (pre)loading
private function onLoadInit():Void {
// Variable definition
_root.tweenListener = new Object();
var tween_handler:Tween = new Tween();
tween_handler.addListener(_root.tweenListener);
// Function to handle (pre)loading
_root.tweenListener.onMotionStarted = Delegate.create(this, onMotionStarted);
_root.tweenListener.onMotionFinished = Delegate.create(this, onMotionFinished);
// Fade out Preloader;
tween_handler = new Tween(Preloader, "_alpha", Strong.easeOut, 100, 0, 3, true);
}
// Move Orange bars
private function onMotionStarted():Void {
// Variable Definitions
var middleOrangeBarY:Number = _root.MC_headerBackground.MC_middleOrangeBar._y;
var bottomOrangeBarY:Number = _root.MC_headerBackground.MC_bottomOrangeBar._y;
var tween2:Tween = new Tween(_root.MC_headerBackground.MC_bottomOrangeBar, "_y", Strong.easeOut, bottomOrangeBarY, 619, 3, true);
var tween3:Tween = new Tween(_root.MC_headerBackground.MC_middleOrangeBar, "_y", Strong.easeIn, middleOrangeBarY, -3.5, 3, true);
}
// Remove invisible Preloader and show SubStage
private function onMotionFinished():Void {
Preloader.removeMovieClip();
// Show SubStage (turn to fade-in)
Container._visible = true;
};
}
Version 2:
ActionScript Code:
/**
Load Sub Stage class
author: Ahmed I. Masri
version: 1.1
modified: 08/11/2008
copyright: Ahmed I. Masri
This code defines a custom class that loads the correct sub movie.
*/
// Import Built-In Classes
import mx.utils.Delegate;
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Class to Load SubStages
class LoadSubStage {
// Variable Definitions
var Container:MovieClip;
var StageLoader:MovieClipLoader;
var Listener:Object;
var Preloader:MovieClip;
// Constructor Function to Select SubStage and prepare Stage
public function LoadSubStage(linkToFile:String) {
if (linkToFile != "intro_stage.swf") return;
LIntroStage(linkToFile);
}
// Constructor Function to PreLoad and present Intro SubStage
private function LIntroStage(linkToFile):Void {
// Variable definitions
StageLoader = new MovieClipLoader();
Listener = new Object();
StageLoader.addListener(Listener);
// Empty Movie Clip to place Intro SubStage
Container = _root.createEmptyMovieClip("MC_emptyHolder", _root.getNextHighestDepth());
Container._x = 0;
Container._y = 55;
// Function to handle (pre)loading
Listener.onLoadStart = Delegate.create(this, onLoadStart);
Listener.onLoadProgress = Delegate.create(this, onLoadProgress);
Listener.onLoadInit = Delegate.create(this, onLoadInit);
Preloader = _root.attachMovie("MC_stageLoader", "MC_stageLoader" , _root.getNextHighestDepth(), {_x:400, _y:261.5});
Preloader.MC_loadingProgressBar._width = 0;
Preloader.txt_PercentLoaded.text = "00";
// Loading of SubStage
StageLoader.loadClip(linkToFile, Container);
}
// Function to handle start of (pre)loading
private function onLoadStart() {
Container._visible = false;
}
// Function to handle progress of (pre)loading
private function onLoadProgress(mc:MovieClip, l:Number, t:Number):Void {
Preloader.MC_loadingProgressBar._width = (l / t) * (Stage.width * 1.2);
Preloader.txt_PercentLoaded.text = Math.round((l / t) * 100);
}
// Function to handle completion of (pre)loading
private function onLoadInit():Void {
// Load complete animation
var middleOrangeBarY:Number = _root.MC_headerBackground.MC_middleOrangeBar._y;
var bottomOrangeBarY:Number = _root.MC_headerBackground.MC_bottomOrangeBar._y;
var tween_handler:Tween = new Tween(_root.MC_headerBackground.MC_middleOrangeBar, "_y", Strong.easeIn, middleOrangeBarY, -3.5, 3, true);
// Move Orange bars to position
tween_handler.onMotionStarted = function() {
var tween2:Tween = new Tween(_root.MC_headerBackground.MC_bottomOrangeBar, "_y", Strong.easeOut, bottomOrangeBarY, 619, 3, true);
var tween3:Tween = new Tween(Preloader, "_alpha", Strong.easeOut, 100, 0, 3, true);
}
// Remove invisible Preloader and show SubStage
tween_handler.onMotionFinished = function() {
Preloader.removeMovieClip();
// Show SubStage (turn to fade-in)
Container._visible = true;
};
}
}
Retreiving Variables In OnMotionFinished
I'm having trouble getting this.counter to even trace inside my onMotionFinished function, let alone do everything i want it to. Anyone know a way to send my variable this.counter so it can be used in my onMotionFinished.
ActionScript Code:
this.mc.onRelease = function() {
_root.mySound2.start(0, 1);
var xScaleThumb:Tween = new Tween(_root.profMC.bg, "_width", Regular.easeOut, _root.profMC.bg._width, xSize[this.counter], 1, true);
var yScaleThumb:Tween = new Tween(_root.profMC.bg, "_height", Regular.easeOut, _root.profMC.bg._height, ySize[this.counter], 1, true);
yScaleThumb.onMotionFinished = function() {
_root.profMC._visible = true;
_root.profMC.titleTxt = titleTxt[this.counter];
_root.profMC.clientTxt = clientTxt[this.counter];
_root.profMC.companyTxt = companyTxt[this.counter];
_root.profMC.bodyTxt = bodyTxt[this.counter];
_root.profMC.picture.loadMovie(largeImage[this.counter], 1);
};
};
Tweens And OnMotionFinished In MX2004
I created some code in Flash 8 for a client using MX2004.
I used Tween and made a onMotionFinished function. I saved it as a MX2004 file, but when he tries to compile it he gets
**Error** Scene=movie scene, layer=Actionscript, frame=1:Line 26: There is no property with the name 'onMotionFinished'.
gallery.onMotionFinished = function() {
Tweens And OnMotionFinished In MX2004
I created some code in Flash 8 for a client using MX2004.
I used Tween and made a onMotionFinished function. I saved it as a MX2004 file, but when he tries to compile it he gets
**Error** Scene=movie scene, layer=Actionscript, frame=1:Line 26: There is no property with the name 'onMotionFinished'.
gallery.onMotionFinished = function() {
Tween.onMotionFinished.. Repeatedly.
I'm trying to animate entirely in AS for the first time. (Woo!) I'm using the Tween class, with the very convenient Tween.onMotionFinished to invoke my next animation. But once I get pretty far into it, it starts to look like this:
ActionScript Code:
var centerType:Number = (Stage.width / 4) * 3;var transTween:Tween = new Tween(grayGrad, "_alpha", Strong.easeOut, grayGrad._alpha, 0, 1, true);transTween.onMotionFinished = function() { var iamPos:Tween = new Tween(iam_txt, "_x", Strong.easeOut, iam_txt._x, iam_txt._x + 100, .7, true); iamPos.onMotionFinished = function() { var prepPos:Tween = new Tween(prepared_txt, "_x", Strong.easeOut, prepared_txt._x, centerType, .5, true); var prepAlpha:Tween = new Tween(prepared_txt, "_alpha", Strong.easeOut, 0, 100, .5, true); prepAlpha.onMotionFinished = function() { setTimeout(function ():Void { var engaPos:Tween = new Tween(engaged_txt, "_x", Strong.easeOut, engaged_txt._x, centerType, .5, true); var engaAlpha:Tween = new Tween(engaged_txt, "_alpha", Strong.easeOut, 0, 100, .5, true); var prepPos2:Tween = new Tween(prepared_txt, "_x", Strong.easeOut, prepared_txt._x, Stage.width + 100, .5, true); var prepAlpha2:Tween = new Tween(prepared_txt, "_alpha", Strong.easeOut, 100, 0, .5, true); }, 100); } }; var photoAlpha:Tween = new Tween(photo1, "_alpha", Strong.easeOut, photo1._alpha, 100, .5, true);};
I've found that, when applying a tween to a function, I am unable to refer to that tween (specifically, onMotionFinished) from outside of it. This works okay but leaves me with some rather ugly ActionScript!
Any suggestions?
Tweening Prototypes And OnMotionFinished?
i recently started scripting using the tweening prototypes.
http://laco.wz.cz/tween/?page=docs/getTweens
it's so much easier than the old mx.transitions that i was using... but i haven't found one crucial element in the prototypes:
onMotionFinished
is there any way to trigger another function after a tween is finished?
for example:
circle.slideTo(200, 150, 1, "EaseOutExpo");
slideTo.onMotionFinished.gotoAndPlay(30);
-alex-
OnMotionFinished And Calling Other Functions
I have this function that builds menus, and I'm using a tweening class function to move the menu items around. The thing is that when calling the tween function I need the submenu building function to wait until the tween is finished otherwise things start freaking out.
It's organized like this (pseudo code):
ActionScript Code:
function tweenItem(movieclip) {
[tweens the item];
movieclip.onMotionFinished = function() {
buildSubmenu;
}
};
function buildMenu() {
tweenItem(movieclip);
function buildSubmenu() {
buildMenu();
}
tweenItem(movieclip);
};
The problem is that I need the first tweening to finish before I can build the submenu. I've tried using the onMotionFinished, but it doesn't seem to want to call a function nestled into another function (in this case buildMenu()).
Does anyone have any ideas about how to do this?
|