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




Tween.onMotionFinished = Function() Problem.



Hi folks!

(I've searched for this problem and found similiar, but couldn't find any real answer.)
I've got a problem with a onMotion function. I'll show you. =)


Quote:




function ape() {
myTween.onMotionFinished = function() { // Problem here! This never runs!
<..some code..>
anotherFunction();
}
}
function donkey() {
var myTween:Tween = new Tween(....);
}




Anyone know how to solve this? I've tried with _root.myTween but it doesn't help.

All help appreciated! =)



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-07-2007, 04:30 PM


View Complete Forum Thread with Replies

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

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();

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();

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?

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.

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;
          };
       }
    }

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?

Class, Tween, OnMotionFinished, Inheritance
hi all

i have a query for you gurus out there.

if i have a class similar to the following;

import mx.transitions.Tween;
import mx.transitions.easing.*;
class myClass extends MovieClip {
public function myClass() {
myClassInit();
}
public function myClassInit():Void {
myFunctionA();
}
public function myFunctionA():Void {
var myTween:Object = new Tween(object, property, function, begin, end, duration, useSeconds);
myTween.onMotionFinished = function() {
};
}
public function myFunctionB():Void {
}
}

how do i get myTween.onMotionFinished to call myFunctionB()?

thank you in advanced to ne1 who answers this for me, merry xmas all who read this.

schwarzA

Tween Class And OnMotionFinished Script
hey guys.

here's my script:

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

preview.onRollOver = function() {
var xscTweenOver:Tween = new Tween(this, "_xscale", Elastic.easeOut, this._xscale, 1000, 1, true);
var yscTweenOver:Tween = new Tween(this, "_yscale", Elastic.easeOut, this._yscale, 1000, 1, true);
}};

preview.onRollOut = function() {
var xscTweenOver:Tween = new Tween(this, "_xscale", Elastic.easeOut, this._xscale, 100, 1, true);
var yscTweenOver:Tween = new Tween(this, "_yscale", Elastic.easeOut, this._yscale, 100, 1, true);
};

fairly simple. but here's what i'd really like to do. i want the first tween to execute (_xscale) and then after that is finished execute the (_yscale) tween. i've thought about using onMotionFinished...but am not exactly sure how to go about getting it to work correctly. any AS junkies care to help?

Tween Class / OnMotionFinished Problem
Hey all, hopefully someone can help me out with this problem that I have been having today...

I am currently creating a menu system for a site, that when hovered over expands from a short strip into the larger menu containing buttons/graphics etc.

To reduce the number of frames used within the site, i am trying to achieve this method using the tween class / onMotionFinished action as opposed to having a movieclip which plays through when hovered over.

However if you move the mouse off before the "loading in" animation is complete, it begins the "reverse" animation and seperate titles both appear on top of eachother.

Basically i need to stop the tweens from playing, should the user hover away before they are complete, like a movieclip would "rewind" if you were using that well documented method.

Below is the script, and I have attached the .fla for you to have a look at.

Any help would be greatly appreciated - thank you in advance if you are able to help!


Code:

// import classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
stop()
this.onRollOver = function(){

var menu_expand:Tween = new Tween(_root.main_menu.menu_background,"_height",Elastic.easeOut,23,69,1,true);

var text_rollOut:Tween = new Tween(_root.main_menu.menu_text,"_y",Strong.easeIn,0,-11,0.5,true);
var text_fadeOut:Tween = new Tween(_root.main_menu.menu_text,"_alpha",Strong.easeIn,100,0,0.5,true)

text_rollOut.onMotionFinished = function(){

var name_rollIn:Tween = new Tween(_root.main_menu.laimonas_text,"_y",Strong.easeOut,11,0,0.5,true);
var name_fadeIn:Tween = new Tween(_root.main_menu.laimonas_text,"_alpha",Strong.easeOut,0,100,0.5,true);

}

}
this.onRollOut = function(){

var menu_shrink:Tween = new Tween(_root.main_menu.menu_background,"_height",Strong.easeOut,69,23,1,true);

var name_rollOut:Tween = new Tween(_root.main_menu.laimonas_text,"_y",Strong.easeIn,0,11,0.5,true);
var name_fadeOut:Tween = new Tween(_root.main_menu.laimonas_text,"_alpha",Strong.easeIn,100,0,0.5,true);

name_rollOut.onMotionFinished = function(){

var text_rollIn:Tween = new Tween(_root.main_menu.menu_text,"_y",Strong.easeOut,-11,0,0.5,true);
var text_fadeIn:Tween = new Tween(_root.main_menu.menu_text,"_alpha",Strong.easeOut,0,100,0.5,true);

}

}

WHY Does OnMotionFinished Register Even After The Tween Is Stopped? (reposted)
i'm looking for a solution. i need to trigger a scripted tween (fade in) after one the first one has completed.

the tween event handlers, like onMotionFinished, register the end of the event even if the animation hasn't finished, like in the event that you restart the tween. below is a description of my issue.

this is a slideshow application which loads jpegs and text files externally.

using the tweens class, i have scripted fades in and out for the images (loaded into a movie clip), and the text (loaded into a dynamic text field, nested in a movie clip).

using onMotionFinished, the text waits until the image has faded in completely before the text fades in.

this works just as described, unless you start clicking buttons too quickly, before the text has completely faded in.

for example, if you click the "next" button three times in quick succession (before the text has faded in completely) you advance to the fourth slide and it fades in. but what happens next is that the text attempts to fade in another three times, even though only one jpeg has loaded.

what i find strange is that the movieClip loader (and tweening script) aborts the loading of the previous three jpegs, yet the script for the text keeps trying to fade in, for each of the three times. i suspect this has to do with my placement of the variable within the function, but maybe not.

it seems to work properly on simon hoegsberg's site:

http://www.simonhoegsberg.com/

can someone offer some help? i have zipped and included the appropriate fla. it loads a series of files starting with "small0.jpeg" and "small0.txt" which are not included here.

thank you.

import mx.transitions.*;
import mx.transitions.easing.*;

var mclLoader:MovieClipLoader = new MovieClipLoader();
var oListener:Object = new Object();

mclLoader.addListener(oListener);

var lvSlideInfo:LoadVars = new LoadVars();
lvSlideInfo.onLoad = function (success) {
if (success){
slideCounter();
} else {
mText.loadedInfo.text = "error";
}
}

//loads a file with the total number of slides
lvSlideInfo.load("smallWork/slideInfo.txt");

var nCurrentFrame:Number = 0;

function slideCounter() {
lvSlideInfo.load("smallWork/small" + nCurrentFrame + ".txt");
var sSlideInfo:String = (lvSlideInfo.work);
mText.loadedInfo.text = (sSlideInfo);
}
mText._alpha = 0;
function loadFrame() {
mclLoader.loadClip("smallWork/small" + nCurrentFrame + ".jpg", mcHolder);
}

loadFrame();

//fades the text after the image has completley faded in
this.mclLoader.onLoadInit = function() {
var twFadeIn:Tween = new Tween(mcHolder, "_alpha", Regular.easeOut, 0, 100, 5, true);
twFadeIn.onMotionFinished = function() {
var twBox:Tween = new Tween(mText, "_alpha", Regular.easeOut, 0, 100, 3, true);
}
};
//textFade();
//slideCounter();
function activateButtons() {
btNext.enabled = true;
btNext._visible = true;
btPrev.enabled = true;
btPrev._visible = true;
}


//--------------<nextSlideButton>--------------\
this.btNext.onRelease = function() {
if (nCurrentFrame < Number(lvSlideInfo.totalSlides) - 1) {
nCurrentFrame++;//} else {
}
trace (nCurrentFrame);
//disables next button on last slide
if (nCurrentFrame == Number(lvSlideInfo.totalSlides) - 1) {
this.enabled = false;
this._visible = false;
} else {
activateButtons();
}

var twFade:Tween = new Tween(mcHolder, "_alpha", Strong.easeIn, 100, 0, 5);
//twBox.stop();
var twFadeText:Tween = new Tween(mText, "_alpha", null, 100, 0, 1);
twFade.onMotionFinished = function() {
loadFrame();
slideCounter();
}
};

//--------------</nextSlideButton>--------------\
this.btPrev._visible = false;

//--------------<previousSlideButton>--------------\
this.btPrev.onRelease = function() {
nCurrentFrame --;
activateButtons();
//trace(nCurrentFrame);
//disables previous button on first frame
if (nCurrentFrame == 0) {
this._visible = false;
this.enabled = false;
}
var twFade:Tween = new Tween(mcHolder, "_alpha", Strong.easeIn, 100, 0, 5);
var twFadeText:Tween = new Tween(mText, "_alpha", null, 100, 0, 1);
twFade.onMotionFinished = function() {
loadFrame();
slideCounter();
};
}

//-------------</previousSlideButton>--------------\

Tween Class - Code Not Executed Within OnMotionFinished
How come the code within the onMotionFinished function never executes?


ActionScript Code:
import mx.transitions.Tween;import mx.transitions.easing.*;var topboxsectionXScale:Tween = new Tween(topboxsection_mc, "_xscale", Elastic.easeOut, 0, 100, .7, true);var middleboxsectionXScale:Tween = new Tween(middleboxsection_mc, "_xscale", Elastic.easeOut, 0, 100, .7, true);var bottomboxsectionXScale:Tween = new Tween(bottomboxsection_mc, "_xscale", Elastic.easeOut, 0, 100, .7, true);bottomboxsectionXScale.onMotionFinished = function() {    var middleboxsectionYscale:Tween = new Tween(middleboxsectiontop_mc, "_height", none, 14, 493, .7, true);    bottomboxsection_mc._y += 479;}



Edit:// Nevermind.

Tween Class Multipule OnMotionfinished Need Expert.
Hi,
I have a ActionScript that copies the same Movie clip onto the screen 30 times.
I then get a random point on the screen and tween each of the movie clips to that point. THIS PART WORKS FINE.
When I try to use the onMotionFinished it only works for the last tween. How do I make it so each onMotionFinished is unqiue? So that when one clip stops the onMotionFinished fires seperatly for each. Right now it only fires once for everone. Below is the code I used ***** to show where the problem is.


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

// array of objects set to stop
var xyArray=[];
for (var i=0;i<30;i++){
var antsobj = new Object();
antsobj.xp="stop";
antsobj.yp="stop";
xyArray.push(antsobj);
}

function moveAnts():Void{
var speed=10;
for (var i=0;i< 30;i++){

var thisOne=xyArray[i];
if (thisOne.xp=="stop" && thisOne.yp=="stop") {
thisOne.xp="go";
thisOne.yp="go";

endx=Math.round(Math.random()*1250);
endy=Math.round(Math.random()*950);

var antTweenx:Tween = new Tween(this["ant_mc"+i],"_x",none.Easenone,this["ant_mc"+i]._x,endx,speed,false);
var antTweeny:Tween = new Tween(this["ant_mc"+i],"_y",none.Easenone,this["ant_mc"+i]._y,endy,speed,false);

antTweenx.onMotionFinished = function () {

*******what I want do here is set the array back to "stop" when each motion *******finishes
thisOne=xyArray[i];
thisOne.xp="stop";
thisOne.xy="stop";



}


}//if
}//for
}
//copies 30 movie clips random on screen
function antSetup():Void {
for (var i=0; i < 30; i++) {
attachMovie("ant_mc","ant_mc"+i,this.getNextHighes tDepth());
antx=Math.round(Math.random()*1250);
anty=Math.round(Math.random()*950);
this["ant_mc"+i]._x=antx;
this["ant_mc"+i]._y=anty;
}
}
antSetup();

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 = 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.

OnMotionFinished And Function Calls
Hi there.

Can I make function calls from within the onMotionFinished scope? See example belowe. Also tried by using the Delegate class...

var a_handler:Object = new Tween(params);
a_handler.onMotionFinished = function(){
test();
}

var test:Function = function():Void {
trace("hello");
}

OnMotionFinished Function Keeps Calling - The Gift That Keeps On Giving
i'm looking for a solution. i need to trigger a scripted tween (fade in) after one the first one has completed.

the tween event handlers, like onMotionFinished, register the end of the event even if the animation hasn't finished, like in the event that you restart the tween. below is a description of my issue.

this is a slideshow application which loads jpegs and text files externally.

using the tweens class, i have scripted fades in and out for the images (loaded into a movie clip), and the text (loaded into a dynamic text field, nested in a movie clip).

using onMotionFinished, the text waits until the image has faded in completely before the text fades in.

this works just as described, unless you start clicking buttons too quickly, before the text has completely faded in.

for example, if you click the "next" button three times in quick succession (before the text has faded in completely) you advance to the fourth slide and it fades in. but what happens next is that the text attempts to fade in another three times, even though only one jpeg has loaded.

what i find strange is that the movieClip loader (and tweening script) aborts the loading of the previous three jpegs, yet the script for the text keeps trying to fade in, for each of the three times. i suspect this has to do with my placement of the variable within the function, but maybe not.

it seems to work properly on simon hoegsberg's site:

http://www.simonhoegsberg.com/

can someone offer some help? i have zipped and included the appropriate fla. it loads a series of files starting with "small0.jpeg" and "small0.txt" which are not included here.

thank you.

import mx.transitions.*;
import mx.transitions.easing.*;

var mclLoader:MovieClipLoader = new MovieClipLoader();
var oListener:Object = new Object();

mclLoader.addListener(oListener);

var lvSlideInfo:LoadVars = new LoadVars();
lvSlideInfo.onLoad = function (success) {
if (success){
slideCounter();
} else {
mText.loadedInfo.text = "error";
}
}

//loads a file with the total number of slides
lvSlideInfo.load("smallWork/slideInfo.txt");

var nCurrentFrame:Number = 0;

function slideCounter() {
lvSlideInfo.load("smallWork/small" + nCurrentFrame + ".txt");
var sSlideInfo:String = (lvSlideInfo.work);
mText.loadedInfo.text = (sSlideInfo);
}
mText._alpha = 0;
function loadFrame() {
mclLoader.loadClip("smallWork/small" + nCurrentFrame + ".jpg", mcHolder);
}

loadFrame();

//fades the text after the image has completley faded in
this.mclLoader.onLoadInit = function() {
var twFadeIn:Tween = new Tween(mcHolder, "_alpha", Regular.easeOut, 0, 100, 5, true);
twFadeIn.onMotionFinished = function() {
var twBox:Tween = new Tween(mText, "_alpha", Regular.easeOut, 0, 100, 3, true);
}
};
//textFade();
//slideCounter();
function activateButtons() {
btNext.enabled = true;
btNext._visible = true;
btPrev.enabled = true;
btPrev._visible = true;
}


//--------------<nextSlideButton>--------------\
this.btNext.onRelease = function() {
if (nCurrentFrame < Number(lvSlideInfo.totalSlides) - 1) {
nCurrentFrame++;//} else {
}
trace (nCurrentFrame);
//disables next button on last slide
if (nCurrentFrame == Number(lvSlideInfo.totalSlides) - 1) {
this.enabled = false;
this._visible = false;
} else {
activateButtons();
}

var twFade:Tween = new Tween(mcHolder, "_alpha", Strong.easeIn, 100, 0, 5);
//twBox.stop();
var twFadeText:Tween = new Tween(mText, "_alpha", null, 100, 0, 1);
twFade.onMotionFinished = function() {
loadFrame();
slideCounter();
}
};

//--------------</nextSlideButton>--------------\
this.btPrev._visible = false;

//--------------<previousSlideButton>--------------\
this.btPrev.onRelease = function() {
nCurrentFrame --;
activateButtons();
//trace(nCurrentFrame);
//disables previous button on first frame
if (nCurrentFrame == 0) {
this._visible = false;
this.enabled = false;
}
var twFade:Tween = new Tween(mcHolder, "_alpha", Strong.easeIn, 100, 0, 5);
var twFadeText:Tween = new Tween(mText, "_alpha", null, 100, 0, 1);
twFade.onMotionFinished = function() {
loadFrame();
slideCounter();
};
}

//-------------</previousSlideButton>--------------\

Help With Tween Function(s)
Im having trouble with some script that I have written to tween elements in a MC with 3 frames, frame one contains information for tweening in arrays, frame 2 has a tween out function that I have written and frame 3 has a tween in function that I have written.

The tween functions tell the elements in the MC to go to points on the root level (ExpandBox) and to reset to its original state (ContractBox).

The problems I am getting are:
1. If I move the MC on the root level I get differing results
2. If I have more than 1 instance of the MC only one instance works properly.

I have attached the fla file I am working on, If someone could have a look and tell me the problems with my script or offer an alternative using AS I would be very grateful!

Adding _x And _y To A Tween Function
I have the function below that moves portTxtHolder to a position, it is called using:

_root.PTpos1();



function PTpos1()
{
extendTween = new TweenExtended(portTxtHolder,["_x","_y"],
easingType,[portTxtHolder._x,portTxtHolder._y],[600,505],2,true);
}

what i want to do is add or subtract from this start position to save me writing extra functions for each new postion,

to add extra _x value like:
_root.PTpos1()_x+100;

to add 100 to the portTxtHolder, the above eg does not work but i 'm not sure what to do?

[F8] Modify A Tween Function
i'm using the following code functions to control alpha values of my MC's


PHP Code:



function fade90(MC)
{
    extendTween = new TweenExtended(MC,["_alpha"],
    easingType3,[MC._alpha],[90],0.75,true);
}

function fade0(MC)
{
    extendTween = new TweenExtended(MC,["_alpha"],
    easingType3,[MC._alpha],[0],0.75,true);
}

function fade40(MC)
{
    extendTween = new TweenExtended(MC,["_alpha"],
    easingType3,[MC._alpha],[40],0.75,true);
}




i would like to clean my code to combine the function into one, where i can name the alpha value and MC in one single function.

eg

mc1 alpha 10
then
mc2 alpha 40!!!

my scripting skills are poor in that i can not work out how to do this?

cheers
rat

Curious Tween Function
Hi all you beloved AS gurus,


I just came across an unknown form of tweening, it looks like this :


ActionScript Code:
b1.tween("_yscale", 100, 2, "easeInOutBack", 2)

but if you just code it like that it doesn't work, so I suppose it's linked to someone's personal class.

My question is :

Then why does flash put the "tween" word in blue, as if it recognised it ?
Furthermore, when you open a parenthesis, flash gives you the usual tip on how to fill in...

Flash only put's it in blue if it's preceeded by an instance name, if you start the line with tween, flash doesn't recognise it, and when I right click on "tween" to get the help, the help turns up with the typical html error page saying that it can't show the requested page...

Anyone has an idea ?

Cheers,

David

Alpha Value In Tween Function
I think I need some guides in letting me know how the parameters work in the function.

I have the code as below and the result is so strange.

Code:
c.alpha = 0.6;
c.addEventListener(MouseEvent.ROLL_OVER, rO);

function rO(evt:Event):void
{
var alpha1Tween:Tween = new Tween(c, "alpha", None.easeInOut, 0.3, 1, 1.5, true);
trace( "1: " + c.alpha);
var alpha2Tween:Tween = new Tween(c, "alpha", None.easeInOut, 0.5, 0.3, 1.5, true);
trace( "2: " + c.alpha);
}

Code:
1: 0.296875
2: 0.5
Why the values of alpha are so strange?

public function Tween(obj:Object, prop:String, func:Function, begin:Number, finish:Number, duration:Number, useSeconds:Boolean = false)

Shouldn't the value be the same as the value of "finish:Number" ?

Thank you.

How To Kill A Tween Function ?
Hello people !

An easy one :

I was wondering if it if possible to kill a tween class function while flash is achieving it?

my_tween = new mx.transitions.Tween(target1, "_alpha", easing, 0, 100, 8);


let's take this tween for example. It runs over 8 frames' time and let's say I'd like the function to stop on the fourth because I've got another function running in that's sort of contradictory to this one, do you brilliant people know if it is possible ?

Thanks

Problem With Tween And Function
Hi,

I wanted to know if anyone could help me solve my problem. I have a function that adds in a child and tweens in the object to a certain opacity. That works fine. When I click my close_btn I have a tween that is supposed to tween out that same object to 0 opacity and then remove. The problem I am having is that when I click the close_btn, the object just gets removed with no tween taking place. How can this be resolved.

Thanks.
code is attached.







Attach Code

import fl.motion.easing.*
import fl.transitions.Tween;
import fl.transitions.easing.*;


var myXML:XML = new XML();
var thisImage:String = new String();
var imageLoader:Loader = new Loader();
var xmlLoader:URLLoader = new URLLoader();
var current:String = "off";
var Grey:greyOut = new greyOut();
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.distance =5;
dropShadow.blurX=4;
dropShadow.blurY=4;
dropShadow.alpha=.6
dropShadow.angle=90;

xmlLoader.addEventListener(Event.COMPLETE, handleComplete);
xmlLoader.load(new URLRequest("sherwoodText.xml"));
var popUp:WindowPopUp = new WindowPopUp();
var Sherwood:sherwoodMap = new sherwoodMap();
addChild(Sherwood);

var pin1:Pin1 = new Pin1();
pin1.x=250;
pin1.y=600;
addChild(pin1);

var pin2:Pin1 = new Pin1();
pin2.x=250;
pin2.y=550;
addChild(pin2);


function loadImage(thisImage:String):void {
imageLoader.load(new URLRequest(thisImage));
imageLoader.x=289;
imageLoader.y=3;
popUp.addChild(imageLoader);
trace(thisImage);

}


function RemoveGrey(Grey):void {
removeChild(Grey);
}



popUp.close_btn.addEventListener(MouseEvent.CLICK, exitWindow);
function exitWindow(event:MouseEvent):void {
tweenOut(Grey);
RemoveGrey(Grey);
removeChild(popUp);


}


function tweenGrey(Grey):void {
var GreyTween:Tween = new Tween(Grey, "alpha", Elastic.easeOut, .1, .5, 3, true);
Grey.x=305;
Grey.y=395;
addChild(Grey);
}


function tweenOut(Grey):void {
var GreyTweenOut:Tween = new Tween(Grey, "alpha", Elastic.easeOut, .5, 0, 3, true);


}


function handleComplete(event:Event):void {

//Load in XML
myXML = new XML(event.target.data);

//ignore spaces
myXML.ignoreWhitespace;
trace("loaded");

popUp.filters = [dropShadow];
//Set the text boxes to proper data
popUp.display1.text =myXML.loc2.bld;
popUp.display2.text =myXML.loc2.desc;
thisImage =myXML.loc2.image;
loadImage(thisImage);

popUp.x=290;
popUp.y=240;
addChild(popUp);
current="off"










trace("displayed");


}


pin1.addEventListener(MouseEvent.CLICK, showRec);
function showRec(event:MouseEvent): void {


tweenGrey(Grey);
popUp.display1.text =myXML.loc1.bld;
popUp.display2.text =myXML.loc1.desc;
thisImage =myXML.loc1.image;
loadImage(thisImage);
popUp.x=290;
popUp.y=240;

addChild(popUp);



}


pin2.addEventListener(MouseEvent.CLICK, showAud);
function showAud(event:MouseEvent):void {
tweenGrey(Grey);
popUp.display1.text =myXML.loc3.bld;
popUp.display2.text =myXML.loc3.desc;
thisImage =myXML.loc3.image;
loadImage(thisImage);
popUp.x=290;
popUp.y=240;
addChild(popUp);

}

Call Function After Tween Is Done?
ok so i'm using mcTween2 for a project, i have movie clips animating in to start with then at a certain point i use a onTweenComplete to call a preload function. it all works to a certain point, once the function gets called the preloader starts fine but then after a few seconds the function gets called again so the preloader starts over and never actually loads anything, just keeps looping around. the only thing calling the preload function is that tween.

anyone ever have this problem before / know how to fix it?

Tween Problem With Function
I have posted a simplified version of a problem I have been having at http://www.milestoneadvertising.com/functionTest.fla.
The problem is that I have a tweening symbol that once a function is executed that specifies the x position for the symbol and stops the tween. I cannot get the tween to start again even though the MC that contains it is playing.

If you download the source file the tween automatically starts and calls a function (telling it a new x position and stops the animation) once it hits a certain frame in the animation. Then once you hit the button to restart the animation the tween will not start again, but through a trace command you can tell the MC symbol is running.


The following script is more elaborate with the same problem, that once rollover "button1" a function tells the "mask" symbol a new x position, I can't get the symbol "mask" to start tweening again. The onRollOut function plays the "symbolMC" that contains the "mask" symbol and the play head is moving but the tween is not animating.

button1.onRollOver = function() {
timedFunction = setInterval(rollOverFunction, 1);
};
button1.onRollOut = function() {
symbolMC.gotoAndPlay(20);
};
function rollOverFunction() {
if (symbolMC.mask._x<300) {
symbolMC.mask._x = symbolMC.mask._x+5;
}
if (symbolMC.mask._x>=300) {
clearInterval(timedFunction);
}
}

Any Ideas Thanks

Tween Class Function -help
Hi there,

I am fading some text for a banner in & out and some nice people on ultrashock suggested Tween Class. However im still pretty new to actionscript and have got myself confused!

I need to cut file size down so I am trying to create a function for my fade in/out instead of applying it to each frame. However each time it needs to target a different movieclip (text1, text2 etc).

here is my code so far:

frame=1
tex=1


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

function fadeIn() {
var tween_handler:Object = new Tween("tex+1", "_alpha", Strong.easeIn, 100, 0, 1, true);

tween_handler.onMotionFinished = function() {
gotoAndPlay ("Frame+1");

}

function fadeOut() {
var tween_handler:Object = new Tween("tex+1", "_alpha", Strong.easeIn, 100, 0, 1, true);

tween_handler.onMotionFinished = function() {
gotoAndPlay ("Frame+1");

}
}

Am I on the right path? I can't seem to get it to work- i'm assuming i have muddled it up,

Any help would be much appreciated

Laco Tween Function
Hi There,

I am using Laco tween to fade an object, then once it has finished gotoAndStop a frame in another Movie Clip.

Problem is I am having to call another function, which is a bit long winded, but the only way I can get it to work.

Does anyone have a better solution?

The code I am using is as follows:

function pageToStop(){
contentPages.gotoAndStop(_root.contentToStop);
trace("contentToStop = " + _root.contentToStop);

}

delayTarget.alphaTo(100, 0.4, 'linear', 0.4, pageToStop);
trace("At Content");
transitionCurtain.play();

Thanks

Dabush

Tween Function For Multiple Mc's...help
Hello,

I'd like to get several MC's to tween from point a to b and repeat. I wrote the function below which works fine with on e MC.

However if I use the function with more than one, all of the MC's tweens become the same, which is the last function I call -linkrun(square5, 400, 400).

How can I fix this?

Thanks for any help.

-E



ActionScript Code:
xloc=250
yloc=250
 
function linkrun(mc, xstart, ystart){
 
 
var xt:Tween = new Tween(mc, "_x", Regular.easeOut, xstart, xloc, framerate, false);
var yt:Tween = new Tween(mc, "_y", Regular.easeOut, ystart, yloc, framerate, false);
 
 
xt.onMotionFinished = function() {
xt.start()
};}
 
yt.onMotionFinished = function() {
yt.start()
}
 
linkrun(square, 10,10)
linkrun(square2, 400,10)
linkrun(square3, 250, 10)
linkrun(square4, 10, 250)
linkrun(square5, 400, 400)

My Function, Tween To 3 Diff Positions?
function moveXthenY(mc, xpos, ypos, ypos2) {
mc.onEnterFrame = function () {
mc._x += (xpos - mc._x) / 2;
if (Math.abs(mc._x - xpos) < 1) {
mc._x = xpos;
mc._y += (ypos - mc._y) / 2;
if (Math.abs(mc._y - ypos) < 1) {
mc._y = ypos;
mc._y += (ypos2 - mc._y) / 2;
if (Math.abs(mc._y - ypos2) < 1) {
mc._y = ypos2;
if (mc._y == ypos2 and mc._x == xpos) {
delete mc.onEnterFrame;
}
}
}
};
}

**** dont work...

[CS3] Make Tween Reverse Within Function?
Hi everyone,

I'm building a fullscreen website for my client and i'm using tweenclasses for some simple animations.

When clicking a button, a menu moves from (menu._y-155) to his original position (menu._y). This part works.

I want to reverse this tween when clicking the button for the second time, but I can't use absolute coordinates, because of the fullscreen positioning of the menu.
So I want to use the onMotionFinished reverse function for the second click.
How exactly can I achieve this?
I know I can make a new tween with the opposite parameters, but that doesn't work when scaling the browser.

This is my AS so far:


PHP Code:




stop();

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

var incr = 0;
personal_but.onRelease = function() {
    incr++;
    if (incr>1) {
        incr = 0;
        reversing();
    }
    if (incr == 1) {
        forwd();
    }
};
function forwd() {
    _root.gotoAndStop("personal");
    var Personal:Tween = new Tween(_root.personal_mc, "_y", Elastic.easeInOut, (_root.personal_mc._y)-155, _root.personal_mc._y, 32, false);
};
function reversing() {
    Personal.reverse();
};







The forwd works great, but the reversing part doesn't...
Any ideas?

Many thanks!

[CS3] Multiple Function For Tween Reversing
Hi everyone,

Something is driving me nuts, I have a menu with 4 buttons,
when pressing one of the buttons for the first time, a mc slides out using a tween.
When you click THE SAME button for the second time, the mc slides back again using the excisting tween by .yoyo

Same function for the other buttons, so far so good!
BUT at the moment when you click one of the buttons, it should check first if one of the other mc's are still slided out,
and if so, have to slide back first before sliding out the mc of the pressed button....

So I made a variable called n_status for each button, which tells if the mc is slided out (zichtbaar) or not slided out (onzichtbaar).
The other buttonfunctions should check these variables if they are "zichtbaar" and then slide the mc back first.

This part kinda works, but when clicking randomly on the buttons a few times,
something goes wrong... but I can't figure out what!!!

This is my actionscipt so far (I only made 2 of the 4 buttons yet to test):


PHP Code:




stop();

personal_selected._visible = false;
network_selected._visible = false;

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

// PERSONAL //
var incrP = 0;
var p_status = "onzichtbaar";

personal_but.onRelease = function() {
    incrP++;
    if (incrP>1) {
        incrP = 0;
        reversingP();
        p_status = "onzichtbaar";
    }
    if (incrP == 1) {
        forwdP();
        p_status = "zichtbaar";
    }
};

var personal;

function forwdP() {
    //Reversing other mc's
    if (n_status == "zichtbaar") {
        reversingN();
    }
    //Forwarding network mc
    _root.personal_mc._visible = true;
    personal_selected._visible = true;
    personal = new Tween(_root.personal_mc, "_y", Strong.easeInOut, 80, 300, 32, false);
};
function reversingP() {
    personal_selected._visible = false;
    personal.yoyo();
};


// NETWORK //

var incrN = 0;
var n_status = "onzichtbaar";

network_but.onRelease = function() {
    incrN++;
    if (incrN>1) {
        incrN = 0;
        reversingN();
        n_status = "onzichtbaar";
    }
    if (incrN == 1) {
        forwdN();
        n_status = "zichtbaar";
    }
};

var network;
    
function forwdN() {
    //Reversing other mc's
    if (p_status == "zichtbaar") {
        reversingP();
    }
    //Forwarding network mc
    _root.network_mc._visible = true;
    network_selected._visible = true;
    network = new Tween(_root.network_mc, "_y", Strong.easeInOut, 80, 300, 32, false);
};
function reversingN() {
    network_selected._visible = false;
    network.yoyo();
};








Please, give me the golden tip! Any help is very much appreciated
Thanx

Tween Function Is Messing Up My Width
Hello All,

I posted this over at the Adobe Flash Forum, but I didn't get any kind of reply. Though I would try here as well.

I am using Flash 8 Professional for a real-world pop-up application. I have isolated a tweening problem that I can not seem to fix and I need to call in the experts. I have created a very small sample app which demonstrates my problem.

My stage is 500 x 500.

I've got a movie clip called my_mc which contains a 50 x 50 square. On the stage, it is located in the lower left-hand corner (the box is registered in the lower left corner as well).

I've got two other movie clips called FindEdge_x and FindEdge_y. They consist of a vertical line and a horizontal line respetively. They will be dynamically positioned to the top edge (FindEdge_y) and right edge (FindEdge_x) of the box after a tween has been applied to it.

When I roll over the my_mc movieclip, I am tweening it to a random height and width and then repositioning the findedgex and findedgey lines accordingly.

Am am making the following assumptions ::
The line corresponding to the top edge of the box (FindEdge_y) = my_mc._y - my_mc._height
The line corresponding to the right edge of the box (FindEdge_x) = my_mc._x + my_mc._width

The problem I am having is this -- the width and height properties of my_mc contain a level of error after the tween has been applied. The greater the distance of the tween, the greater the level of error. This makes positioning elements to the top-right corner of the box (ie, a close "X" button) nearly impossible.

The code for my sample application is as follows ::

========================================

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

my_mc.onRollOver = function():Void
{
tmpTween = new Tween( my_mc, "_width", None.easeNone, 50, 50+random(400), 6, false );
tmpTween.onMotionFinished = function()
{
findedgex._x = my_mc._x + my_mc._width;
}
tmpTween = new Tween( my_mc, "_height", None.easeNone, 50, 50+random(400), 6, false );
tmpTween.onMotionFinished = function()
{
findedgey._y = my_mc._y - my_mc._height;
}
}

my_mc.onRollOut = function():Void
{
tmpTween = new Tween( my_mc, "_width", Strong.easeOut, my_mc._width, 50, 6, false );
tmpTween.onMotionFinished = function()
{
findedgex._x = my_mc._x + my_mc._width;
}
tmpTween = new Tween( my_mc, "_height", Strong.easeOut, my_mc._height, 50, 6, false );
tmpTween.onMotionFinished = function()
{
findedgey._y = my_mc._y - my_mc._height;
}

}

findedgex._x = my_mc._x + my_mc._width;
findedgey._y = my_mc._y - my_mc._height;

=============================================

1) Is this a problem with my code or with the Tween class? (I have tried various easings and they all yeild the same error-result)
2) Any ideas how I can counteract (ie hack) the problem away?

Thanks in advance for your help!
-Tim

A Good Tween Class Function
Hello All-
I've had problems with a custom class I've been using, so I am deciding to just use the built in classes flash ships with for tweening. Does anyone have or can show me how to have just one big Tween function so that when I call it to move something, it would only require something like this:

TweenThis(my_mc, property, newPos, SomeFunctionOnceTweenFinished);

Any help apprecitated...thanks...

Using A Tween Function According To Relative Position Of Mc
Hello, I'm using a tween function and I want to move an obect relative to it's current position. Like say, MC15.xSlideTo(MC15._x+10, .6, easeOutExpo);

Here's my code:

ActionScript Code:
function thumbRoll(tagID)
{
    _root["MC"+tagID].xSlideTo(_root.MC[tagID]._x - 10, .6,"easeInExpo");
    _root["MC"+tagID].ySlideTo(_root.MC[tagID]._y + 10, .6,"easeInExpo");

} // End of the function
I want to have one function for all the different clips as there will be 65 clips.
The problem is that the mc moves all the way across the screen.
Here's an example: http://www.metapps.com/testing/areas2.html
rollover the names in the drop down list

Tween Not Working In An .onLoadComplete Function?
Hello all - been a while since I've treaded these waters (like the new facelift, btw ). But now I've got something that's completely stumping me and I'm hoping one of you fine people can help me out.

I'm building a dynamic image gallery - got that part working. I read the contents of the database through php, push that data into flash with a LoadVars object, and then use the resultant data to pull the image off the server. I'm loading the images using a MovieClipLoader so I can have a preloader and - I was hoping - slightly more control. Here's the issue that I've come across -

This is code that loads the actual images -

ActionScript Code:
portImgsCat.onLoad = function():Void{
    var j:Number = 0;
    var k:Number = 1;
    var thumbWide:Number = 130;
    var thumbHigh:Number = 130;
    var crY:Number = 0;
    var crX:Number = 0;
    for(i=0; i<portImgsCat.totRows; i++){
        var crThumb:String = "thumb"+i;
        var crLoc:String = "loc"+i;
        var crID:String = "id"+i;
//create the scroller base for the portfolio thumbnails, if necessary...
        rPane.createEmptyMovieClip("scroller", rPane.getNextHighestDepth());
//attach the thumbnails and set the id variable for each
        rPane.scroller.attachMovie("thumbnail", [crThumb], rPane.getNextHighestDepth());
        rPane.scroller[crThumb].imgID = portImgsCat[crID];
//take care of the onClick event for each thumbnail...
        rPane.scroller[crThumb].onRelease = function():Void{
            getImage(this.imgID);
        }
        tImg.addListener(thumbListener);
//load the thumbnail images...
        tImg.loadClip("makeImage.php?img="+portImgsCat[crLoc], rPane.scroller[crThumb].imgHolder);
        tImg.loadClip("makeImage.php?img="+portImgsCat[crLoc], rPane.scroller[crThumb].imgRef);
//position the thumbnails...
        rPane.scroller[crThumb]._y = crY;
        rPane.scroller[crThumb]._x = thumbWide * j;
//    rPane.scroller[crThumb]._x = 675;
        if(j < 4){
            j++;
        }else{
//reset positioning info on the next line down...
            j = 0;
            crY = (thumbHigh * k);
            k++;
        }
        crX = thumbWide*j;
//duplicate the images for the "reflection"...
        rPane.scroller[crThumb].imgRef._rotation = 180;
        rPane.scroller[crThumb].imgRef._xscale = -100;
        rPane.scroller[crThumb].imgRef._alpha = 40;
    }
//create the masking for the scroller movie clip...
    rPane.createEmptyMovieClip("masking", rPane.getNextHighestDepth());
    rPane.masking.beginFill(0x000000, 0);
    rPane.masking.lineTo(640, 0);
    rPane.masking.lineTo(640, 640);
    rPane.masking.lineTo(0, 640);
    rPane.masking.lineTo(0, 0);
    rPane.masking.endFill();
//set the scroller mask...
    rPane.scroller.setMask(rPane.masking);
//add the scrollbars if the scroller movieclip is taller than the masking..
    if(rPane.scroller._height >= 640){
        rPane.attachMovie("scrollBar", "scrollBar", rPane.getNextHighestDepth());
        rPane.scrollBar._x = 640;
        rPane.scrollBar._y = 50;
//handle the click events for the scrollbar...
    //up ->
        rPane.scrollBar.dn.onPress = function():Void{
            sclIt = setInterval(scrollDn, 10);
        }
        rPane.scrollBar.dn.onRelease = function():Void{
            clearInterval(sclIt);
        }
    //down ->
        rPane.scrollBar.up.onPress = function():Void{
            sclIt = setInterval(scrollUp, 10);
        }
        rPane.scrollBar.up.onRelease = function():Void{
            clearInterval(sclIt);
        }
    }
    var portImgsCat:LoadVars = new LoadVars();
}
This is loading in all my images in perfect rows with the proper spacing between and the proper amount of images across. Yay. However, what I'd like to have is for the images (once they're done loading) slide in using a tween from the right of the screen. So, to test, I uncomment the line "rPane.scroller[crThumb]._x = 675;" and comment out the line "rPane.scroller[crThumb]._x = thumbWide * j;". So, now I've got all my thumbnails overlapping nicely off the edge of my stage.

Now the rest of the code -

ActionScript Code:
thumbListener.onLoadComplete = function(tgt:MovieClip){
    eval(tgt)._parent.preloader.removeMovieClip();
    new Tween([eval(tgt)._parent], "_x", mx.transitions.easing.Strong.easeOut, eval(tgt)._parent.x, 10, 2, true);
}
This does nothing. At all. The tween should work, right? Or has my cold finally eaten the last of my brain? I'm still on Flash MX Professional 2004, btw.

A Question About Tween() Function By Zeh Fernando. Help Please.
Hi,
If you are familiar with Fernando's function tween(), can I call the callback function in the middle of the tweening?
In this address: http://hosted.zeh.com.br/mctween/index.html
I mean for example:
MC1 fades in from 0 to 100. I start fading MC2 when the MC1._alpha=50;

Thanks.

Stop A Tween Class In Another Function
hi all, i jjust want to know a way how to (on the rollout) stop the tweens that are happening on the rollover


Code:
for (i=0; i<=sections.length; i++) {
this[sections[i]+""].onRollOver = function() {
var heightGo:Tween = new Tween(this, "_height", Strong.easeOut, this._height, 2*this._height, 0.3, true);
var widthGo:Tween = new Tween(this, "_width", Strong.easeOut, this._width, 2*this._width, 0.3, true);
};
this[sections[i]+""].onRollOut = function() {
var heightGoBack:Tween = new Tween(this, "_height", Strong.easeOut, this._height, 0.5*this._height, 0.3, true);
var widthGoBack:Tween = new Tween(this, "_width", Strong.easeOut, this._width, 0.5*this._width, 0.3, true);
};
}
I don't know how to reference a tween within that function :S

Tint Tween/fade Function
Hello Kirupa (first post here).

Im kinda stuck with a little project i hope you guys can help me with.

Im in need of a function which on mouseOver fade/tints to one colour (script definded) and on mouseOut fades back to original colour. (for multiple movieclips)

Iwe been through the forums.. tryed a bit of coding but couldnt get it to work ..

Anyone have an example that does the above?

Thanks in advance!

Kasper

A Question About Tween() Function By Zeh Fernando. Help Please.
Hi,
If you are familiar with Fernando's function tween(), can I call the callback function in the middle of the tweening?
In this address: http://hosted.zeh.com.br/mctween/index.html
I mean for example:
MC1 fades in from 0 to 100. I start fading MC2 when the MC1._alpha=50;

Thanks.

Tween Function Mini-tutorial
This def. isn't where this should be posted, but i couldn't really find an appropriate forum..

Anyways, this is a small tutorial i put together on the tween functions that were written by Zeh Fernando (w/ Robert Penner's easing equations).

These simple functions are very handy and if you aren't already using them, i would strongly suggest taking a look at this tutorial.

word.


http://www.gigsoft.com/tween


btw- i'm going to add a few more things (like volume and pan tweens) in the next few days, so if you have any suggestions on what else i should include, let me know.

-evan

Cannot Reference A Tween Inside A Function.
Hi

Im sure im being a bit stupid but i cannot seem to reference a tween inside a function. Just want to use tweenName.stop(); and tweenName.resume(); but no dice. Can anyone shed any light?

Thanks


Tween Code
Code:

//////////load stuff
import mx.transitions.Tween;
import mx.transitions.easing.*;

//////////variables
var restart:Boolean = true;
var targX:Number = 0;

//////////functions
function fadeClip(who, targX){

   var tw1:Tween = new Tween(who,"_x",Regular.easeInOut,who._x,targX,100,false);
   
   tw1.onMotionFinished = function() {
      tw1.yoyo();
   };
}

fadeClip(clip01,0);

Button Code

Code:

clip01.onRollOver = function(){
   //trace("fading uP");
   //if(rolled == false){
   tw1.stop();

}

clip01.onRollOut = function(){
   tw1.resume();
}

Variable Instead Of Movieclip In Tween() Function
I'm looping through an array of movieclips, and I'd like them all to move. Right now they would move at one time but eventually I'd like a pause in between each move.

I can't seem to get the Tween() function to understand a variable in place of the clip name, so it will find the next one in the array and move it.

Not sure how to do this, but here's my script...


Code:


stop();

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

var roomTween:Tween;

function moveClip(begin:Number, end:Number):Void {
var seconds:Number = 1;
var useSeconds:Boolean = true;
roomTween = new Tween(clipArray[i], "_x", Regular.easeInOut, begin, end, seconds, useSeconds);
}


var clipArray:Array = new Array();
clipArray[0] = "one_mc";
clipArray[1] = "two_mc";
clipArray[2] = "three_mc";
clipArray[3] = "four_mc";

function loopClips() {

for(i=0;i<clipArray.length;i++) {

var new_name:String = (i+1) + clipArray[i];
_root.attachMovie(clipArray[i], new_name, getNextHighestDepth(), {_x:i, _y:i});
trace(new_name);
moveClip(0, 550);
}
}

loopClips();



Anyone have any ideas?

Thanks!

-B

RemoveClip Not Working In Function With Tween Class
The function and loop create the button states for 8 buttons that have captions when rolled over and stick when clicked to indicate which section you are in.

The function for the onRollOut states is using the tween class to fade out the clip before it removes it. For some reason it will fade out any of the captions on the first rollOut, but subsequent rollOuts fail to remove the clip.

I'm pretty sure it's the removeClip that is where the problem lies, and perhaps the tween class is adding some complexity.

Are there any tutorials on function syntax? Everything I've found so far hasn't been this in-depth.


Code:

function createSubNav (j) {

var capOn = "cap" + j;
var newCapOn = "cap"+ j + "b";
var curMcButton = this["mc_button"+j];

// buttons with captions
_root["mc_button"+j].j = j;
_root["mc_button"+j].capOn = capOn;
_root["mc_button"+j].newCapOn = newCapOn;

// creates each button's onRollOver state, fades in the caption using tween class
_root["mc_button"+j].onRollOver = function () {
this.attachMovie(this.capOn, this.newCapOn, this.getNextHighestDepth());
new mx.transitions.Tween(this[newCapOn], "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 1.25, true);
}

// creates the onRollOut state that should fade out the caption using the tween class
_root["mc_button"+j].onRollOut = function () {
trace("newCapOn is " + this.newCapOn);
var ncoFade = new mx.transitions.Tween(this[newCapOn], "_alpha", mx.transitions.easing.Strong.easeOut, 100, 0, 1, true);

// using the onMotionFinished function to remove the clip after it is done fading out.
// this is perhaps where the problem lies, most likely in my syntax
ncoFade.onMotionFinished = function() {
trace("newCapOn is " + newCapOn);
this[newCapOn].removeMovieClip();
}

}


// to avoid issues/bugs this should have the same actions as the onRollOut (fade out and remove captions
_root["mc_button"+j].onDragOut = function () {
//trace("newCapOn is " + this.newCapOn);
this[newCapOn].removeMovieClip();
}


// creates the onPress functions for each, and because there are two main buttons they
// are associated with (mc animations), this breaks them up and removes the opposite
//captions and movieclip

if (this.j<=4) {
_root["mc_button"+j].onPress = function () {
removeCaps ( this.j, 1);
}
} else {
_root["mc_button"+j].onPress = function () {
removeCaps ( this.j, 2);
}
}

};

Making Tween Function Available To Entire Movie?
Hi,

I have the following function on my main timeline:

Code:
_global.importTrans = function() {
import mx.transitions.*;
import mx.transitions.easing.*;
};
Further down the timeline I am attaching mcs to a container on the main stage and trying to call importTrans(), but to no avail. The only way that I can get it to work is if I paste the code on the timeline of each attached mc and then call it. Considering that I have dozens of mcs to attach, is there any sort of workaround for this?

Thanks

Emptying Text Field In A Function Before A Tween
With a bit of help, I have a slideshow gallery that externally loads images. There's buttons at the bottom left and when you press one a new externally loaded image loads up (the old image fades out and the new one fades in). The title (a Textfield) of the image aligns to the bottom right of the image and I have a listener that automatically finds out what the width of the image being loaded is, that gets put in a variable and that variable is then used to change the x position of the title textfield and thus align it to the right of the image (as the images are of different widths).

It all works okay, but I want the textfield to be empty as soon you press the button, the tween to happen and then the new text/title to appear. At the moment the text shows the old title, then the tween happens and then the new title comes up.


Ermm.. does this make sense? I'm a newbie!

Any thoughts would be most welcome...


Here's some code

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

this.createEmptyMovieClip("container_mc",this.getN extHighestDepth());
this.createEmptyMovieClip("buttons_mc1",this.getNe xtHighestDepth());
this.createEmptyMovieClip("buttons_mc2",this.getNe xtHighestDepth());
this.createEmptyMovieClip("buttons_mc3",this.getNe xtHighestDepth());

var mywide:Number;
var clipList:Object = new Object();
var clipLoad:MovieClipLoader = new MovieClipLoader();
clipLoad.addListener(clipList);


clipList.onLoadInit = function(target:MovieClip) {
trace(" width = "+ target._width+" height = "+ target._height);
mywide = (target._width-mytext._width);
setX();
}


buttons_mc1.attachMovie("one","one_mc",buttons_mc1 .getNextHighestDepth());
buttons_mc1.one_mc._x = 1;
buttons_mc1.one_mc._y = Stage.height-buttons_mc1.one_mc._height-2;


buttons_mc2.attachMovie("two","two_mc",buttons_mc2 .getNextHighestDepth());
buttons_mc2.two_mc._x = 10;
buttons_mc2.two_mc._y = Stage.height-buttons_mc2.two_mc._height-2;

buttons_mc3.attachMovie("three","three_mc",buttons _mc3.getNextHighestDepth());
buttons_mc3.three_mc._x = 20;
buttons_mc3.three_mc._y = Stage.height-buttons_mc3.three_mc._height-2;



function setX(){
mytext._x = mywide;
mytext.text = newText;
mytext.setTextFormat(myTextFormat);
};




function setNewText(){
mytext.text = newText;
mytext.setTextFormat(myTextFormat);
};






_root.createTextField("mytext",105,125,428,300,100 );

var newText = "TITLE ONE"
mytext.text = newText;
trace(mytext);

mytext.embedFonts = true;

myTextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.size = 11;
myTextFormat.color = 0x000000;
myTextFormat.align = "right";

mytext.setTextFormat(myTextFormat);


textInstance.setTextFormat(myTextFormat);


clipLoad.loadClip('1.jpg',container_mc);

function fadeIn() {
var MyfadeIn = new Tween(container_mc, "_alpha", Strong.easeOut, 0, 100, 36, false);
}

function fadeOut() {
var MyfadeOut = new Tween(container_mc, "_alpha", Strong.easeOut, 100, 5, 20, false);
}



buttons_mc1.one_mc.onRelease = function() {
newText = "TITLE ONE"
setNewTex()
new Tween(container_mc, "_alpha", Strong.easeOut, 100, 0, 20, false).onMotionFinished = function() {
clipLoad.loadClip('1.jpg',container_mc);

newText = "TITLE ONE"
setNewTex()
fadeIn();


};

};








buttons_mc2.two_mc.onRelease = function() {

new Tween(container_mc, "_alpha", Strong.easeOut, 100, 0, 20, false).onMotionFinished = function() {
clipLoad.loadClip('2.jpg',container_mc);
fadeIn();

fadeIn();
newText = "TITLE TWO"
setNewTex()

};
};





buttons_mc3.three_mc.onRelease = function() {

new Tween(container_mc, "_alpha", Strong.easeOut, 100, 0, 20, false).onMotionFinished = function() {
clipLoad.loadClip('3.jpg',container_mc);
fadeIn();

fadeIn();
newText = "TITLE THREE"
setNewTex()

};
};

Adding Easing Tween -- To Exisiting Function
Adding Easing Tween -- to exisiting function

Ok so I found this nice code over at Prototype. Its a function for Aligning to stage on Resize. http://proto.layer51.com/d.aspx?f=1514

It works really nice on its own but I was hoping to add some tweened easing as an additional optional parameter. (I posted there twice asking for help to no avail =( So I am asking here at Kirupa, hoping someone can help me with my struggles. What I wish to add is - implementing and adding an "easing" function as part of the current function. Something generalized to be called only if desired and the ability to set the ease type, duration, maybe prop etc.. (or whatever needed to make it work )

I have tried all kinds of things and below is as close as I can come (at least the only thing I can do to get the thing to move, although as you will see it works backwards and I can only get it to work using stage.width, stage.height, however I have tried newX oldX and all kinds of other things and cant seem to get things to move.

I am missing something, perhaps everything


Code:
// Original Script found here --
// Functions: Align to stage on Resize -- http://proto.layer51.com/d.aspx?f=1514

// +++ Stage Align +++
// onR function is used with fullscreen & "T(op)L(eft)" Stage.align as a ref point!!!
//fscommand( "fullscreen", true ); // <<-- Optional if needed

import mx.transitions.Tween;
import mx.transitions.easing.*;
Stage.scaleMode = "noScale";
Stage.align = "TL";

// Optional Easing -- I am trying to add with no success =(

function mover(obj:MovieClip, startX:Number, startY:Number, endX:Number, endY:Number) {
var tweenX:Tween = new Tween(obj, "_x", Regular.easeInOut, startX, endX, 1, true);
var tweenY:Tween = new Tween(obj, "_y", Regular.easeInOut, startY, endY, 1, true);
}

// trigger alignment via Stage listener object!
// alignment options: "TL", "TR", "TC", "BL", "BR", "BC", "CL", "CR", "CC"
// optional offset by X or Y axis provided as an object property: obj.X, obj.Y

function onR(A, obj) {
var F = String(A).substring(0, 1);
var L = String(A).substring(1, 2);
(obj.X == undefined) ? obj.X=0 : obj.X=obj.X;
(obj.Y == undefined) ? obj.Y=0 : obj.Y=obj.Y;
if (F == "T") {
obj._y = Math.ceil(obj.Y);
} else if (F == "B") {
obj._y = Math.ceil(Stage.height-obj._height-obj.Y);
} else if (F == "C") {
obj._y = Math.ceil((Stage.height-obj._height)/2-obj.Y);
}
if (L == "L") {
obj._x = Math.ceil(obj.X);
} else if (L == "R") {
obj._x = Math.ceil(Stage.width-obj._width-obj.X);
} else if (L == "C") {
obj._x = Math.ceil((Stage.width-obj._width)/2-obj.X);
}
}
//Usage
// ... later
// -- OPTIONAL positioning - to add further positioning of items if needed

mc_1.X = 100;
// X offset for mc_1 used for Center Left alignment
mc_2.Y = -50;

// Y offset for mc_2 used for Center Right alignment

var resizeListener:Object = new Object();
resizeListener.onResize = function() {
onR("CL", mc_1);
onR("CR", mc_2);

// Optional Easing Call to mover function -- I am trying to add with no success =(
// I know its set to stage center now but with all my efforts, this is the only senerio
// I can get anything to move, I tried newX old X etc.. this. and on and on.. can
// someone be so kind to help me add an "optional" workable easing function to this
// script? Mucho Apreciato to anyone that does ;-)

mover(mc_1, mc_1._x, mc_1._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
mover(mc_2, mc_2._x, mc_2._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
};
Stage.addListener(resizeListener);

// also the 2 mcs have registration in upper left etc..


I am open to suggestions on implementation, I just thought this function from prototype was pretty slick really and wanted to add some easing to it. It should be possible, I just cant get my head wrapped around it.

Can anyone please provide some help? I really appreciate your input people Thanks for your help.
__________

Simplify What I am asking:

http://proto.layer51.com/d.aspx?f=1514

Add easing to the above function found at that link (also posted above) on browser resize, so any MCs using the align function ease to there new location instead of just snapping into place.

Thanks everyone

Call Function Scripted On Tween Complete
im trying to make an event listener for a when a tween completes, and im not having any luck, any advise

my script

function startmove(event:KeyboardEvent) {
switch (event.keyCode) {
case 17 :
if ((blasts>0) && (blown)) {
blasts -= 1;
updateblasts();
blown = false;
blastx = ship.x;
blasty = ship.y-(ship.height/2);
bomb = bhold.addChild(new blast());
bomb.name = bomb;
bomb.x = blastx;
//bomb.addEventListener(Event.ENTER_FRAME, dropbomb);
bombtween:Tween = new Tween(bomb, "y", null, blasty, blasty-200, .5, true);
}
break;
}
}

bombtween.addEventListener(Event.COMPLETE, removebomb);

how can i make it call the removebomb function after the tween is completed???

OnTweenComplete Function...any Way To Trigger Something Half-way Through A Tween?
Hi

I have two boxes. Box 1 moves down the page and Box 2 up the page. I can get it so, after box 1 has moved down and reached its destination, box 2 is then triggered and starts its tween up the page. I am using MC Tween and onTweenComplete();

easy enough

But I would like box 2 to start moving, half way through box 1's tween, so when the tween is only 50% complete...any ideas on doing this???

how can I constantly keep track of box1's position? So a value is being returned like every millisecond to see if it has passed, say ._y>100...any ideas??? thanks

Adding Easing Tween -- To Exisiting Function
Adding Easing Tween -- to exisiting function

Ok so I found this nice code over at Prototype. Its a function for Aligning to stage on Resize.
http://proto.layer51.com/d.aspx?f=1514

It works really nice on its own but I was hoping to add some tweened easing as an additional optional parameter. (I posted there twice asking for help to no avail =( So I am asking here at GTAL, hoping someone can help me with my struggles. What I wish to add is - implementing and adding an "easing" function as part of the current function. Something generalized to be called only if desired and the ability to set the ease type, duration, maybe prop etc.. (or whatever needed to make it work :( )

I have tried all kinds of things and below is as close as I can come (at least the only thing I can do to get the thing to move, although as you will see it works backwards and I can only get it to work using stage.width, stage.height, however I have tried newX oldX and all kinds of other things and cant seem to get things to move.

I am missing something, perhaps everything :D

Code:

// Original Script found here --
// Functions: Align to stage on Resize -- http://proto.layer51.com/d.aspx?f=1514

// +++ Stage Align +++
// onR function is used with fullscreen & "T(op)L(eft)" Stage.align as a ref point!!!
//fscommand( "fullscreen", true ); // <<-- Optional if needed

import mx.transitions.Tween;
import mx.transitions.easing.*;
Stage.scaleMode = "noScale";
Stage.align = "TL";

// Optional Easing -- I am trying to add with no success =(

function mover(obj:MovieClip, startX:Number, startY:Number, endX:Number, endY:Number) {
   var tweenX:Tween = new Tween(obj, "_x", Regular.easeInOut, startX, endX, 1, true);
   var tweenY:Tween = new Tween(obj, "_y", Regular.easeInOut, startY, endY, 1, true);
}

// trigger alignment via Stage listener object!
// alignment options: "TL", "TR", "TC", "BL", "BR", "BC", "CL", "CR", "CC"
// optional offset by X or Y axis provided as an object property: obj.X, obj.Y

function onR(A, obj) {
   var F = String(A).substring(0, 1);
   var L = String(A).substring(1, 2);
   (obj.X == undefined) ? obj.X=0 : obj.X=obj.X;
   (obj.Y == undefined) ? obj.Y=0 : obj.Y=obj.Y;
   if (F == "T") {
      obj._y = Math.ceil(obj.Y);
   } else if (F == "B") {
      obj._y = Math.ceil(Stage.height-obj._height-obj.Y);
   } else if (F == "C") {
      obj._y = Math.ceil((Stage.height-obj._height)/2-obj.Y);
   }
   if (L == "L") {
      obj._x = Math.ceil(obj.X);
   } else if (L == "R") {
      obj._x = Math.ceil(Stage.width-obj._width-obj.X);
   } else if (L == "C") {
      obj._x = Math.ceil((Stage.width-obj._width)/2-obj.X);
   }
}
//Usage
// ... later
// -- OPTIONAL positioning - to add further positioning of items if needed

mc_1.X = 100;
// X offset for mc_1 used for Center Left alignment
mc_2.Y = -50;

// Y offset for mc_2 used for Center Right alignment

var resizeListener:Object = new Object();
resizeListener.onResize = function() {
   onR("CL", mc_1);
   onR("CR", mc_2);

// Optional Easing Call to mover function -- I am trying to add with no success =(
// I know its set to stage center now but with all my efforts, this is the only senerio
// I can get anything to move, I tried newX old X etc.. this. and on and on.. can
// someone be so kind to help me add an "optional" workable easing function to this
// script? Mucho Apreciato to anyone that does ;-)

   mover(mc_1, mc_1._x, mc_1._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
   mover(mc_2, mc_2._x, mc_2._y, Math.round(Stage.width/2), Math.round(Stage.height/2));
};
Stage.addListener(resizeListener);

// also the mcs have reg in upper left etc...

I am open to suggestions on implementation, I just thought this function from prototype was pretty slick really and wanted to add some easing to it. It should be possible, I just cant get my head wrapped around it. :?

Can anyone please provide some help? I really appreciate your input people Thanks for your help :)

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