[CS3] Easing To A Stop When Using StopDrag Function
Hi,
I have a movie clip which is draggable, using the startDrag/stopDrag command; when the user clicks it drags the movieclip, when they release it stops dragging. I am trying to put some easing on the movement when they release, so that it eases to a stop.
At the moment I am using this: (My movieclip is called "textdrag")
Code: on (press) { startDrag(_root.textdrag, false, 0, 0, -2550, 0); } on (release, releaseOutside, rollOut) { stopDrag(); new mx.transitions.Tween(textdrag, "_x", mx.transitions.easing.Regular.easeOut, 0, 300, 3, true);
}
But it performs the tweening at the same place everytime, due to the '0,300' parameters. If I take them off though the easing doesn't happen at all.
Can anyone help? I'd really appreciate it. I've gone through the help files but it's not helping me much.
John
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-24-2008, 08:30 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
StopDrag Doesn't Stop
I'm making a "makeover" game of one of my teachers to show to the entire school (with his permission) on Tuesday. I am using the following code to drag the articles of clothing.
Code:
on(press) {
this.startDrag();
this.gotoAndStop(2);
}
on(release) {
this.stopDrag();
}{
My problem is that stopDrag doesn't stop the Dragging everytime. About 10% of the time, the piece sticks to my mouse and i drag it all over, no matter how much i click. How can i fix this?
[F8] StopDrag() Won't Stop Dragging - Please Help
Hi all,
I've built a media player which pulls in a FLV. Everything works fine but sometimes the volume slider and timeline slider don't stop dragging after the release of the mouse button. Here's the stopDrag code below for you to look at. The volume slider works in the same way.
PHP Code:
movieScrubber.scrubDot.onRelease = function():Void{
this.stopDrag();
videoDisplay.play(t);
scrubbing = false;
}
I'll add the rest of the code just in case it helps:
PHP Code:
stop();
var scrubbing:Boolean;
var t:Number; // current playhead time (in seconds)
var scrubberLength:Number = movieScrubber.clipTimeline._width;
var scrubRange:Number = scrubberLength - movieScrubber.scrubDot._width;
var volumeRange:Number = volumeSlider.volumeWedge._width - volumeSlider.volumeDot._width/2;
var soundLevel:Number;
var owner:MovieClip = this;
var configURL:String; // change path to config.xml using flashvars
// Preferences loaded via XML config file
var autoPlay:Boolean;
var flvURL:String;
var loop:Boolean;
var volume:Number;
// Listeners for MediaDisplay component
var flvListener:Object = new Object();
// called when Flash video playback is completed
flvListener.complete = function(evt:Object):Void{
videoCompleted();
}
// called repeatedly while FLV download is in progress
flvListener.progress = function(evt:Object):Void{
var bl:Number = evt.target.bytesLoaded;
var bt:Number = evt.target.bytesTotal;
movieScrubber.loadProgress._width = Math.round(bl/bt * movieScrubber.clipTimeline._width);
if(bl > 4 && bt > 4 && bl >= bt){
trace("FLV loaded");
}
}
videoDisplay.addEventListener("complete", flvListener);
videoDisplay.addEventListener("progress", flvListener);
// Play/Pause button handlers
playpauseClip.pause_btn.onRelease = function():Void{
videoDisplay.pause();
}
playpauseClip.play_btn.onRelease = function():Void{
videoDisplay.play();
}
// Video scrubber
movieScrubber.scrubDot.onPress = function():Void{
this.startDrag(false, 0, 0, scrubberLength-10, 0);
scrubbing = true;
}
movieScrubber.scrubDot.onRelease = function():Void{
this.stopDrag();
videoDisplay.play(t);
scrubbing = false;
}
movieScrubber.onEnterFrame = function():Void{
togglePlay();
if(scrubbing){
t = (this.scrubDot._x/scrubberLength) * videoDisplay.totalTime;
videoDisplay.play(t);
// this pauses video until scrubber is released
videoDisplay.pause();
}
else{
var scrubFactor:Number = videoDisplay.playheadTime/videoDisplay.totalTime;
this.scrubDot._x = scrubRange * scrubFactor;
}
}
// Volume controls
volumeSlider.volumeDot.onPress = function():Void{
this.startDrag(false, 0, -4, volumeRange, -4);
volumeSlider.onEnterFrame = function():Void{
var v:Number = Math.round((this.volumeDot._x/volumeRange)*100);
soundLevel = v;
setVolume(v);
}
}
volumeSlider.volumeDot.onRelease = function():Void{
this.stopDrag();
delete volumeSlider.onEnterFrame;
}
volumeSlider.speakerIcon.onRelease = function():Void{
var muted:Boolean = videoDisplay.volume == 0;
setVolume(muted ? soundLevel : 0);
}
// Functions
function init():Void{
// mute volume initially
setVolume(0);
// hide pause button initially
playpauseClip.pause_btn._visible = false;
// load XML preferences
loadPreferences();
}
function loadPreferences():Void{
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success:Boolean){
if(success){
trace("XML loaded.");
var prefNode:XMLNode = this.firstChild.firstChild;
while(prefNode != null){
trace(prefNode.nodeName + ": " + prefNode.firstChild.nodeValue);
// convert nodes to Timeline variables
owner[prefNode.nodeName] = prefNode.firstChild.nodeValue;
// move to next preference
prefNode = prefNode.nextSibling;
}
// set MediaDisplay properties
setupVideo();
}
else{
trace("Error loading XML preferences.");
}
}
myXML.load(configURL == null ? "ikypVideo.xml" : configURL);
}
function setupVideo():Void{
// set MediaDisplay properties
videoDisplay.autoPlay = autoPlay;
videoDisplay.contentPath = flvURL;
soundLevel = volume;
setVolume(soundLevel);
}
function setVolume(v:Number):Void{
volumeSlider.volumeDot._x = Math.round((volumeRange*v)/100);
videoDisplay.volume = v;
var speakerLevel:Number = Math.round(((volumeSlider.volumeDot._x/volumeRange)*100)/33)+1;
volumeSlider.speakerIcon.speaker_mc.gotoAndStop(speakerLevel);
}
function videoCompleted():Void{
// this moves playhead to 0
videoDisplay.stop();
}
function togglePlay():Void{
var isPlaying:Boolean = videoDisplay.playing && !scrubbing;
playpauseClip.pause_btn._visible = isPlaying;
playpauseClip.play_btn._visible = !isPlaying;
}
// Initialize movie
init();
It seems to release ok until you slide the slider to the end of it's range, then it continues dragging after release.
Can anyone shed some light on the situation?!
Many thanks in advance
Joanna
Help With StopDrag OnEnterFrame Function When Rolling Out Screen
Hi, any help here much appreciated.
I have a script (from a post on here) for the drag and zoom of a movieclip. This all works fine except when i scroll outwith a mask i set, or the flash movie screen while dragging the clip. What happens is that i drag the clip outwith dimensions and do mouserelease it doesnt register. If i do a mouse release there it stays big and will not release itself without a button click.
How do i get it to go back to startng position. Here is the code.
---
Code:
image.onMouseDown = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
movieClip.onEnterFrame = function()
{
this.startDrag();
zoomIn(this);
}
}
}
/*****************************************************************
* Releasing the mouse button involkes the stopDrag method and
* excutes the onEnterFrame function. The onEnterFrame function
* calls the zoomOut function which is effectively looped due to
* the onEnterFrame method. The function also returns the movieClip
* home to the original location in a smooth motion
*****************************************************************/
movieClip.onRelease = function() {
this.stopDrag();
movieClip.onEnterFrame = function() {
zoomOut(this);
// Send the image back to the home on release
image._x = image._x - (image._x - homeX) / 5;
image._y = image._y - (image._y - homeY) / 5;
} //end on EnterFrame function
} //end onRelease function
messy code but it is working - "image" and "movieclip" are the same thing.
What is need is something like:
Code:
maskingbox_mc.onRollOut = function(){
delete image.onEnterFrame
trace("the image should go back");
trace("but it doesn't?");
_root.image._alpha = 50();
}
I realise i need to kill the onenterframe function, or need to set a variable which is tested for. But what is best way, or most clean? How do i set another onEnterFrame to them zoom back slowly and then stop that? I'm confused.. if i set an onenterframe does it just keep going on going for length of movie? So if i cant get a mouse release then i need to test for it elsewhere...i don't know how to do that. So i then set a mask, if i roll outwith the mask then i'll reverse the zoom and sop the drag, but i'm stuck...
Anyway i can get this done i'll be happy. Takes me so long to look up one bit of code, then test that, lalalala Especially when ive only known what a function is for about 8 hours. (and i just forgot as soon as i typed that) help!
Thanks
Help Needed: StartDrag/stopDrag Function Prevents Closing Popup Window
Hey all,
Summary:
I created a popup window inside my flash movie and it worked fine.
Then I decided that the user should have the ability to drag the window around if needed.
So, I added a startDrag/stopDrag function to it.
Problem:
Because I added the startDrag function, I can't close the popup window.
If I comment the drag function out, then I can close the window.
I can do one or the other, but not both.
I have a vague idea of what's happening.
Theory:
The close window command ( t.removeMovieClip() ) is not able to execute because
the "close button movie clip" is inside the popup window movie clip. Therefore, when I add the startDrag function, it gets dragged along with everything else. I believe that to
sovle this problem the startDrag function has to be cleared some sort of way
so that the "close button movie clip" can perform its function.
Well that's just my theory.
Here is my code:
Code:
//-----------------------This creates an empty movie clip----------------------\
this.createEmptyMovieClip("container_mc",1);
//-----------------------end of movie clip creation----------------------------\
//-------------This attaches movie clip to stage on button release-------------\
button.onRelease = function () {
var t:MovieClip = container_mc.attachMovie("popup","pop_mc",container_mc._level1());
t._x =100;
t._y =100;
t.closer.onRelease = function () {
t.removeMovieClip();
}
//---------------------end attach movie--------------------------------------\
//--------------------drag events--------------------------------------------\
t.onPress = function () {
t.startDrag();
}
t.onRelease = function () {
t.stopDrag();
}
//----------------------------end drag events------------------------------\
}
I have attached the fla file.
--------------------
Thanks in advance.
Hungry Samurai
Stop Easing Me Now
Hi group
I'm making a MC called me move with the following AS to give it some ease action. The AS is embedded into a frame.
Math.easing = function(current, destination, speed) {
return (destination-current)/speed;
};
this.me.onEnterFrame = function() {
if (_root.me._x == 34) {
_root.gotoAndStop("S");
}
this._x += Math.easing(this._x, 33, 10);
};
What I want is when the movieclip's x position is 34, for flash to jump to another section in the timeline labeled "S", hence the if statement.
Now the MC moves and eases fine, but the AS never ever makes Flash jump to "S"
Ok, I understand theoretically I can never reach the target of x=33, since the loop is always cutting the distance in half but surely I can reach x==34?
Whats wrong with this code? I've tried, x==35, x==36, x= 50--nothing!?!
Any help, greatly appreciated
Vic
Easing To A Stop On Rollout
Hello,
I have a MC that responds to the _x position of the mouse when it is on an invisible button on Rollover state in the MC. When the mouse Rolls out the _x movement of the MC stops (fine), but I'd like to have the MC ease out to a slow stop not a harsh abrupt stop. I've tried several pieces of code to accomplish this but with no luck, I've tried :
I set avariable for the ease like so:
onClipEvent (load) {
ease = 5;
xmove = _x;
Then this on the stop animation frame when the mouse rolls out of the MC:
_x += (_root.airplanescroller.photo.xmove-_x)/ease;
No matter where I put this it just makes my MC dissappear on Rollout (I'm guessing it moves the MC off the board somewhere. I'd just like the MC to come to a slow stop instead of stopping abruptly on Rollout, any thoughts ???
Stop Looping Mc With Easing
Hi, I have a movieclip that loops. I need to tell it to stop. but instead of just stopping, i'd like it to ease out when I click a button. Can anyone please help?
Also, If I have multiple instances of the mc, how do i write the as so that my onRelease statement applies to all instances?
THANKS!
How To Stop MC With Easing On Mouse Out?
Dear Mods & Friends...
I am moving 1 mc by onClipevnet (enterframe) while mouse is there on certain portion of the stage and i stop that moving of mc while mouse is not over tht certain portion of the stage or moves out of tht certain area. Bt i want to stop moving with ease not suddanly. I dont know how to do this...
Can ne plz look in to this...I am attaching my fla here
Thx in advance for your precious time.
Bhavik
How To Stop Mx.transitions.easing?
hi Guys,
I've read the tutorial on actionscript.org and used the tween classes to constantly "float" a movieclip. this is what I have:
ActionScript Code:
Tween1(mx.transitions.easing.Regular.easeInOut);
function Tween1(easeType) {
var begin = 189;
var end = 193;
var time = 30;
var mc = leo;
ballTween = new mx.transitions.Tween(mc, "_y", easeType, begin, end, time);
ballTween.onMotionFinished = function() {
this.yoyo();
};
}
Now when the visitor of the site wants to go back to the main menu, it all get's messed up. I blieve this is because it loads twice or something.
How do I stop it? I've tried evrything, but can't get it to stop.
Fuse Kit - How Do I Stop Easing All Together
Hi
I'm pretty new to using Fuse kit and have been reading up and gone through a few tutorials (gotoandlearn video tutorials) and have now got an animation that moves from one side of the screen to the other. The only problem is I don't want an easing function included in it (I want the object to move at a linear speed). I haven't specified an easing function in my code but it seems to be happening by default anyway. Here is the code I've got:
import com.mosesSupposes.fuse.*;
import com.robertpenner.easing.*;
ZigoEngine.register(Fuse,PennerEasing,FuseFMP,Linear);
FuseFMP.writeFilter(buy,"Blur",{blurY:100, blurX:100, quality:1});
var f:Fuse=new Fuse();
f.push({target:box, x:-250, time: 10.75, ease:"easeNone", func:afterFuse, scope:box});
f.push({target:buy, Blur_blurX:0, Blur_blurY:0, alpha:100, seconds:1, ease:"easeOutCubic", func:afterFuse, scope:ball});
f.start();
function afterFuse():Void
{
trace("Fuse complete");
}
Can anyone see where I'm going wrong with the first push statement?
I've uploaded the fla of what's happening with this code.
http://www.drawn2pixels.co.uk/banner.fla
Hope someone can help.
Thanks
Infinity Menu With Easing Stop
Ok so I have a menu that I made from a couple of sources but I cant get it to stop moving on rollout. Basicaly its a infinite horizontal menu with a tsunami effect. On roll out I would like it to ease to a stop but i cant figuer that out.
a good example of what I would like it to do can be found here
http://www.ascentium.com/ like how there buttons follow eachother on the x axis. (how do they do that?)
But my horible mess can be found here (attached below)
Any responce is welcome My thanks in advance.
Infinity Menu With Easing Stop (cs3,AS2)
Ok so I have a menu that I made from a couple of sources but I cant get it to stop moving on rollout. Basicaly its a infinite horizontal menu with a tsunami effect. On roll out I would like it to ease to a stop but i cant figuer that out.
a good example of what I would like it to do can be found here
http://www.ascentium.com/ like how there buttons follow eachother on the x axis. (how do they do that?)
But my horible mess can be found here (attached below)
Any responce is welcome My thanks in advance.
Easing Rotation To Stop At Zero MX2004
I have an MC which is rotating constantly controlled by an onEnterFrame action. Every frame, the MC rotates by the value of outerspinerate.
onClipEvent(enterFrame) {
curr_outer_rot = this._rotation;
this._rotation = curr_outer_rot + _root.dynamo.outerspinrate;
trace(curr_outer_rot);
}
I noticed in the trace that the rotation values in flash are translated into the range of -180 to +180.
I want the MC rotation to slow to a stop at zero _rotation value when certain events become true (it's for a preloader).
I want this to happen gradually over at least half a rotation, so i'm using something like
if (allbytesloaded && theMC._rotation == -174) {
decrease the variable 'outerspinrate' so that 'theMC' slows down gradually to stop at or very near zero _rotation;
I'm rather scatterbrained at devising logic so can someone help me with this? I'm going to be doing this with 3 clips at once, and one of them will be spinning the opposite way, but explaining it once should enable me to finish the rest. thank you!
-andy
Easing Rotation To Stop At Zero MX2004
I have an MC which is rotating constantly controlled by an onEnterFrame action. Every frame, the MC rotates by the value of outerspinerate.
onClipEvent(enterFrame) {
curr_outer_rot = this._rotation;
this._rotation = curr_outer_rot + _root.dynamo.outerspinrate;
trace(curr_outer_rot);
}
I noticed in the trace that the rotation values in flash are translated into the range of -180 to +180.
I want the MC rotation to slow to a stop at zero _rotation value when certain events become true (it's for a preloader).
I want this to happen gradually over at least half a rotation, so i'm using something like
if (allbytesloaded && theMC._rotation == -174) {
decrease the variable 'outerspinrate' so that 'theMC' slows down gradually to stop at or very near zero _rotation;
I'm rather scatterbrained at devising logic so can someone help me with this? I'm going to be doing this with 3 clips at once, and one of them will be spinning the opposite way, but explaining it once should enable me to finish the rest. thank you!
-andy
Random Start/stop Of Easing Eq.'s?
Hi all, am curious how to go about randomly starting dynamic scripted tweens. I have a fla with a bunch of bees in it and they need to move randomly at different times.
I have the following on each bee instance::
Code:
onClipEvent (load) {
start = this._x;
change = 615;//this is variable
duration =150;//this is variable
t = 0;
}
onClipEvent (enterFrame) {
t++;
if (t <= duration) this._x = Math.easeInOutQuad(t, start, change, duration);
}
And all the bees are on the main timeline.... So how can I randomly start them AND have them play again after a random period of time?
Any help is greatly appreciated!
Tnx US!.....
Stop Actionscript Function At A Specific Frame (stop Looping)
I want to stop an effect at a specific frame but I dunno how.
Do I have to put something in the code?
I'm confused.
Or just tell me how to stop it from looping.
Edit:
Is it possible to attach this to a movie clip? Then i can stop it or use onEnterFrame and then escape();
I actually have no idea what I am talking about. /Edit
Here is one of the code I borrowed:
MovieClip.prototype.placeInSpace = function(id) {
var ratio = this.focaldistance / Math.sqrt(this[id].z * this[id].z);
this[id]._x = this[id].x * ratio;
this[id]._y = this[id].y * ratio;
this[id]._xscale = this[id]._yscale = 1000 / this[id].z;
}
MovieClip.prototype.randomPlace = function(id) {
var radius = this.rmin + (this.rmax - this.rmin) * Math.random();
var polar = 2 * Math.PI * Math.random();
this[id].x = radius * Math.cos(polar);
this[id].y = radius * Math.sin(polar);
this[id].z = this.zmin + (this.zmax - this.zmin) * Math.random();
}
Here's the other code cause I can use two in my movie:
function mover() {
// Move the particle over time
this._y += this.speed;
this._yscale += 10;
this.speed++;
if (this._y>500) {
this._y = 0;
this.speed = Math.random()*10;
this._yscale = 100;
}
}
function starField(x, y, n) {
// Generate a starfield of specified dimensions with n stars
for (var i = 0; i<n; i++) {
var star = this.createEmptyMovieClip("star"+i, i);
var dot = star.createEmptyMovieClip("dot", 0);
star._rotation = Math.random()*360;
star._x = x;
star._y = y;
dot.lineStyle(0, 0xFFFFFF, 100);
dot.moveTo(0, 10);
dot.lineTo(0, 15);
dot.onEnterFrame = mover;
dot.speed = Math.random()*10;
}
}
starField(275, 200, 100);
Easing Function?
Hi i want to add some easing to my pan view for a better effect
Some ideas?
tks very much!
PHP Code:
onClipEvent (load)
{
ycenter = 300;
xcenter = 300;
speed = 1/30;
}
onClipEvent (enterFrame)
{
var distanceY = _root._ymouse-ycenter;
var distanceX = _root._xmouse-xcenter;
_x -= (distanceX*speed);
_y -= (distanceY*speed);
if (this.hitTest(this._parent.Right_Collision_Block))
{
_x += (distanceX*speed);
}
if (this.hitTest(this._parent.Left_Collision_Block))
{
_x += (distanceX*speed);
}
if (this.hitTest(this._parent.Top_Collision_Block))
{
_y += (distanceY*speed);
}
if (this.hitTest(this._parent.Bot_Collision_Block))
{
_y += (distanceY*speed);
}
}
Easing Function
Hi! I'm trying to scale and move a movieclip dynamically... Is there any easingFunction to do that?
thanks
Easing Function
Hello, i have a question regarding an easing forumla that i wanted to create a generic function for. Many thanks in advance for advice or help.
What i would like to achieve is to fade / scale / alter any mc with one generic formula.
So far i have this:
PHP Code:
function easingIt (mcName, speed, targProperty)
{
mcName.onLoad = function ()
{
mcName.targProperty = 100;
}//end onLoad
mcName.onEnterFrame = function ()
{
cProperty = mcName._xscale;
difProperty = cProperty - mcName.targProperty;
mcName._xscale = cProperty - (difProperty/speed);
}//end onEnterFrame
mcName.onMouseDown = function ()
{
mcName.targProperty = targProperty;
}//end onMouseDown
}
And then just to call the function:
PHP Code:
easingIt (_root.ball, 5, 100);
easingIt (_root.square, 5, 800);
However, i have a few problems with this.
1) The mc's scale down to 0 (whether that be alpha or _x and _y scale) when the movie initially loads.
2) How would i pass a parameter to change the property that i am calling, so i would like this:
PHP Code:
easingIt (_root.ball, _xscale, 8, 100);
easingIt (_root.square, _alpha, 5, 800);
Something along those lines. If anyone could point me in the right direction or point out how to go about correcting the function, that would be great.
Many thanks for any help! This is not urgent, just a little query that i have. If i achieve the basics of this function then i will create a class and objects to make it more simple to call the funciton.
Best regards, Snapple
[F8] AS Easing Function
Hello!
Quick question for you guys. I'm working on this "game" and I currently have a ball that increases in speed as you hold down the arrow key. What I am now trying to accomplish is I want the ball to ease to a stop when the user let's go of the keyboard key (onKeyUp). Here's the File. <---Link
Here is my code so far:
Code:
var speed = 10;
ball_mc.onEnterFrame = function (){
if(Key.isDown(Key.RIGHT)){
this._x += speed += 1;
}
if(Key.isDown(Key.UP)){
this._y -= speed += 1;
}
if(Key.isDown(Key.LEFT)){
this._x -= speed += 1;
}
if(Key.isDown(Key.DOWN)){
this._y += speed += 1;
}
if(speed >= 45){
speed = 45;
}
}
So once you let go of the Keyboard Key I want the ball to slow down to a stop. Thanks for your help!
-Loren
Alpha Easing Function
Hello, im looking for a quick function i can bang into all my movies that flashes a movieclip and then eases the alpha up until the movieclip is at its normal alpha level, the kinda way that netdgoz (http://www.netdogz.com/homeflash.html) loads in each of the components of its site. Does any1 know where there are ready made easing functions that work well, or can any1 write this function for me? thanks alot
Easing Function Never Stops
My easing function isn't stopping.
It never reaches where I want.
I can't remove Math.Round cuz I'm using a pixel font.
here is the code:
PHP Code:
bt_texto.useHandCursor = false;
bt_texto.onRollOver = function(){
texto_up();
}
bt_texto.onRollOut = function(){
texto_down();
}
function texto_up(){
_root.onEnterFrame = function() {
trace(texto._y);
texto._y = Math.round(texto._y+(300-texto._y)/4);
if (texto._y == 300) {
delete (this.onEnterFrame);
}
};
}
function texto_down(){
_root.onEnterFrame = function() {
trace(texto._y);
texto._y = Math.round(texto._y+(460-texto._y)/4);
if (texto._y == 460) {
delete (this.onEnterFrame);
}
};
}
Mx.transitions Easing Out Function
when i click one button, it calls a function that sets all my mcs (b1-b4) alphas to 0 -- *this function works properly.
when i click a different button, i call another function (below) that checks to see if my mcs (b1-b4), have alphas of 0. if they do, then ease them all back to 100.
the problem is, this doesn't work. any suggestions?
code:
function unfade(){
easeType = mx.transitions.easing.Strong.easeOut;
if (_root.b1._alpha < 100){
moveTween = new mx.transitions.Tween(_root.b1, "_alpha", easeType, 0, 100, atime, scale, true);
}
if (_root.b2._alpha < 100){
moveTween = new mx.transitions.Tween(_root.b2, "_alpha", easeType, 0, 100, atime, scale, true);
}
if (_root.b3._alpha < 100){
moveTween = new mx.transitions.Tween(_root.b3, "_alpha", easeType, 0, 100, atime, scale, true);
}
if (_root.b4._alpha < 100){
moveTween = new mx.transitions.Tween(_root.b4, "_alpha", easeType, 0, 100, atime, scale, true);
}
}
[MX] Easing Function Using _rotation
I am building a site where each time a user clicks on a button, the content slides in from the left or right. A background graphic spins a certain amount and stops when the content stops. So each rotation is a little shorter of longer than the other, depending on what button is pressed.
I have made the following code that works fine for me, but I want to add an easing function so the spining background graphic stops smoothly instead of all at once. Because of the different variables I cannot use tweens, it must be actionscript.
Can anyone help?
slide.red3.onRelease = function() {
wheel._rotation = 0;
wheel.onEnterFrame = function () {
wheel._rotation ++;
if (wheel._rotation >= 45) {
this.onEnterFrame = null;
this._rotation = 45;
}
}
}
Adding Easing To Function
how could i include easing in this?
Code:
MovieClip.prototype.setTarg = function(targ) {
//specify the width and height of the movie
width = 780;
height = 570;
//-------------------
var dist, norm;
this.x = this._x;
this.speed = 25;
this.targx = targ;
dist = _root.DistanceBetweenPoints(this.x, this.targx);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
};
Easing Function Never Stops
Hey,
I need some help here please.
My easing function never reaches the coordinates I want it to reach.
I attached the .fla I'm working on and the code.
Thank in advance.
PHP Code:
bt_texto.useHandCursor = false;
bt_texto.onRollOver = function(){
texto_up();
}
bt_texto.onRollOut = function(){
texto_down();
}
function texto_up(){
_root.onEnterFrame = function() {
trace(texto._y);
texto._y = Math.round(texto._y+(300-texto._y)/4);
if (texto._y == 300) {
delete (this.onEnterFrame);
}
};
}
function texto_down(){
_root.onEnterFrame = function() {
trace(texto._y);
texto._y = Math.round(texto._y+(460-texto._y)/4);
if (texto._y == 460) {
delete (this.onEnterFrame);
}
};
}
Easing In OnRollOut Function
How would I work Easing into this?
//
mcFloat.onRollOut = function(){
this.play();
}
Where mcFloat is floating across the screen on a guide, onRollOver it stops, onRollOut mcFloat would continue on its way, but I'd like to use easing to give the effect that it's being slung back into its floating pattern.
Thanks for any help.
Help Incorporating Easing Into My Function
i have this function that moves my mc under a mask, when it gets to the higher than the mask its text changes then moves to a position lower then the mask and scrolls back up to its origional position with the updated text. the problem is i need help making it ease instead of just moving with "this._y -=6"
my code:
Code:
function newProject(g, d, l, c, t) {
dtext.onEnterFrame = function() {
this._y -= 6;
//moving up
if (this._y < -388) {
this.description.htmlText = "<font color="#CC0000">+ "+t+"</font><br>"+d+"<br><font color="#0099cc"><a href=""+l+"">> Launch It</a></font><br><br><font color="#cc0000">Client:</font> "+c;
//go below the mask
this._y = -56;
}
if (this._y == -188) {
delete this["onEnterFrame"];
}
};
}
Reversing An Easing Function
How do you do that? So, for instance, if the ease is Bounce.easeIn - how do you get it to play backwards - so that it bounces in reverse?
Custom Easing Function Woes
here is my code:
tween = function (object, origin, destination, speed) {
object.onEnterFrame = function() {
object._x += (destination-origin)/speed;
if (object._x>=destination) {
delete object.onEnterFrame;
}
};
};
//
testbutton.onRelease = function() {
tween(ball, 100, 500, 10);
};
my problem is that i get a motion, but i don't get a tween. i don't know if it's something as simple as moving a line of code to a different spot or if it might be something more complicated. i also tried it this way:
getTweenValue = function (origin, destination, speed) {
difference = destination-origin;
return difference/speed;
};
//
tween = function (object, origin, destination, speed) {
object.onEnterFrame = function() {
object._x += getTweenValue(origin, destination, speed);
if (object._x>=destination) {
delete this.onEnterFrame;
}
};
};
//
testbutton.onRelease = function() {
tween(ball, 100, 500, 10);
};
and still no luck. Any help would be appreciated. i would also like to know how i can adapt it to tween any property, if i can ever actually get it to tween .
Adding Easing To A Rotation Function?
I have the following code:
Code:
function rotate(mc, dest){
mc.onEnterFrame = function() {
this._rotation = dest;
if (Math.round(this._rotation) == [dest]) {
trace("rotating done");
this.onEnterFrame = undefined;
}
}
}
That moves the MC all at once, but how would I modify this so that it rotated and eased out?
Thanks in advance.
Easing Function Passed As Variable
is it possible to pass an easing function stored as a variable to the Tween constructor, like so:
ActionScript Code:
[b]var tween_effect:String = curr_.transition_effect + ".easeInOut";[/b]
trace(tween_effect);
var trans_x_1:Tween = new Tween(prev_article, "x", [b]tween_effect[/b], 0, banner_mask.width, transition_speed, true);
var trans_x_2:Tween = new Tween(curr_article, "x", [b]tween_effect[/b], -banner_mask.width, 0, transition_speed, true);
you will note i am trying to dynamically create the tween construct params. all else seem to work fine but i am getting: 1067: Implicit coercion of a value of type String to an unrelated type Function - for the tween_effect.
by the way, i have also tried defining the 'tween_effect' var as a Function and still no luck.
Hittest Calls Easing Function
on frame 1 I am using easing functions to make a menu slide out.
on the menu I have the following code
ActionScript Code:
onClipEvent (enterFrame) { if (this.hitTest(_root._xmouse, _root._ymouse, true)) { trace("icons hit"); _root.buttonsOUT(); _root.labelsOUT(); }}
for some reason the hittest calls the function. but the slide menu stutters out rather than sliding smoothly.
if I remove the hittest and replace it with a simple on release then it work fine.
I think that the hittest keeps triggering the function over and over as the trace is tracing loads of times in the output window.
[Flash8] Easing Function Is Too Fast
I'm using the prototype functions from the easing tutotial on this site, and i'm having difficulty finding a way to slow the transitions down. In particular, I am needing to use the "easeAlpha" function and the minimum speed is 1. I need the transition to be about half that speed, but nothing seems to work right when adjusting the speed below 1.
Any input would be greatly appreciated. Thanks so much in advance....
Quote:
MovieClip.prototype.easeAlpha = function( to:Number , speed:Number , endF:Function , endO , endP:Array ){
var _this:MovieClip = this;
var aux:MovieClip = _this.createEmptyMovieClip( "easeAlpha_aux" , 1227 );
var previousAlpha:Number = this._alpha;
if( isNaN(speed) || speed == undefined || speed == '' || speed <= 1 ) speed = 1.2;
if( _this._alpha != to ){
aux.onEnterFrame = function(){
_this._alpha = to - ( to - _this._alpha ) / speed;
if( _this._alpha == previousAlpha ){
_this._alpha = to;
this.removeMovieClip();
if( endF ) endF.apply( endO , endP );
}
previousAlpha = _this._alpha;
}
} else {
if( endF ) endF.apply( endO , endP );
}
}
Getting This Penner Motion/easing Function To Work
Hello,
I am attempting to get a MC to move/ease from down to up with the help of AS without resorting to tweens...
Mind you, I am still working with Flash5.
Right, I found this Robbert Penner function:
ActionScript:
onClipEvent(load)
{
Math.easeInElastic = function (t, b, c, d, a, p) {
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs ) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
};
}
I placed it on a MC (a different one from the ones mentioned below) on frame 1 on _root
With it I want to make a MC (lets call this MC Bob) move from down to up (out of sight) after the timeline in another MC (hostMC) has reached a certain Frame (lets say frame 23).
Since I have to tell Flash to execute this function (which I am forced by Flash5 to put functions within a ActionScript:
onClipEvent(load){
}
I put ActionScript:
onClipEvent(load){
_root.bob.Math.easeInElastic;
}
attached to another MC which I placed inside hostMC on frame 23.
Needless to say, it doesnt work.
But what am I doing wrong?
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
Easing Function (Math Property Error)
Hello,
i have included an as file with several easing equations. all seems to work in a couple projects i've used them in but the majority wont run due to this error x34 [each for it's respective equation]:: i have used the "ease out elastic " equation as an example.
//My "ease out elastic "equation
Math.easeOutElastic = function (t, b, c, d, a, p) {
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
};
//this is the error that runs for each equation:
**Error** Symbol=main, layer=Layer 23, frame=1:Line 204: There is no property with the name 'easeOutElastic'.
//I add the following code to an actions layer on frame one of my main MC::
#include "easing_equations.as" // includes my 34 equations
MovieClip.prototype.easeProperty = function(p,f,d,e,oc){
if (e==undefined)e="easeOutQuad";//set a default easing equation
this["f" + p] = f;
this["t" + p] = 0;
this["b" + p] = Math.floor(Number(this[p].toString(10)));
this["c" + p] = f - this["b" + p];
this["d" + p] = d;
this["propInt" + p] = setInterval(easeIt,32,this,p,this["f" + p],d,e,oc);
}
function easeIt(mc,p,f,d,e,oc){
mc[p] = Math[e](mc["t" + p]++,mc["b" + p],mc["c" + p],mc["d" + p]);
if (mc["t" + p] >= mc["d" + p]){
mc[p] = this["f" + p];
if (oc != undefined)_root[oc]();
delete mc["f" + p];
delete mc["t" + p];
delete mc["b" + p];
delete mc["c" + p];
delete mc["d" + p];
clearInterval(mc["propInt" + p]);
delete mc["propInt" + p];
}
}
// the following are the symbols on my stage that put the equations to work::
mybutton.onRelease = function(){
mysymbol.easeProperty("_x",425,60,"easeOutBounce");
}
please any input will be much appreciated.
thanks
pete rodin
www.gro2.com
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 :)
PLEASE HELP Easing Scrollbar Code Needed To Add Mouse Wheel Function Not Working?
Hi,
I really appreciate some help here is the code below for my scrollbar which works fine but I can't get the mouse wheel code to work (I've taken it out since) How to add a mouselistener and get it to work with my scrollbar? Apparently some simple code but when I put it in nothing works please help if you could add the code in my code that might work.
I think I need to add some code that listens to the mouse wheel? PLEASE HELP! I only know VERY basic action script.
HERE is the code:
//Scrollbar Control//
fscommand("allowscale", "false");
bar.useHandCursor = dragger.useHandCursor=false;
space = 0;
friction = 0.3;
speed = 4;
y = dragger._y;
top = main._y;
bottom = main._y+mask_mc._height-main._height-space;
dragger.onPress = function() {
drag = true;
this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
dragger.scrollEase();
};
dragger.onMouseUp = function() {
this.stopDrag();
drag = false;
};
bar.onPress = function() {
drag = true;
if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
this._parent.dragger._y = this._parent._ymouse;
this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
} else {
this._parent.dragger._y = this._parent._ymouse;
}
dragger.scrollEase();
};
bar.onMouseUp = function() {
drag = false;
};
moveDragger = function (d) {
if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
clearInterval(myInterval);
} else {
dragger._y += d;
dragger.scrollEase();
updateAfterEvent();
}
};
up_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, -1);
};
down_btn.onPress = function() {
myInterval = setInterval(moveDragger, 18, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
this.onEnterFrame = function() {
if (Math.abs(dy) == 0 && drag == false) {
delete this.onEnterFrame;
}
r = (this._y-y)/(bar._height-this._height);
dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
main._y += dy;
};
};
How Do I Stop A Function?
Hi,
I'm using the following function to pause my timeline:
function pause(){
play();
clearInterval(timer);
};
my_var = 18000;
stop();
timer = setInterval(pause, my_var);
---
at the end of the movie clip, I want the function to stop functioning. How do I do this?
cheers!
jen
How Do You Stop A Function?
Hi...
I am working through a book i purchased from sitepoint..."The Flash Anthology" and am extending and manipulating the code for my own fun. I was just wandering though how you stop events from happening. ( not using the stop(); function)
Here is the code I am working with :
function jiggleLetters() {
//this is the function i am trying to stop
function randomBetween(a, b) {
return Math.min(a, b)+random(Math.abs(a-b)+1);
}
MovieClip.prototype.Jiggle = function(minRot, maxRot, minScale, maxScale) {
var mc = this.createEmptyMovieClip("Jiggle", 0);
mc.minRot = minRot;
mc.maxRot = maxRot;
mc.minScale = minScale;
mc.maxScale = maxScale;
mc.onEnterFrame = function() {
var JiggleScale = randomBetween(this.minScale, this.maxScale);
this._parent._xscale = JiggleScale;
var JiggleRot = randomBetween(this.minRot, this.maxRot);
this._parent._rotation = JiggleRot;
};
};
e.Jiggle(-20, 20, 100, 120);
n.Jiggle(-20, 20, 100, 120);
d.Jiggle(-20, 20, 100, 120);
e1.Jiggle(-20, 20, 100, 120);
s.Jiggle(-20, 20, 100, 120);
i.Jiggle(-20, 20, 100, 120);
g.Jiggle(-20, 20, 100, 120);
n1.Jiggle(-20, 20, 100, 120);
}
jig_stop._visible = false;
jig_start.onPress = function() {
jig_stop._visible = true;
jiggleLetters();
jig_start._visible = false;
};
//Trying to stop the function with this button
jig_stop.onPress = function() {
jig_start._visible = true;
jig_stop._visible = false;
//have tried different ways to stop it here....
};
Your help would be greatly appreciated.
Schpitz
End Or Stop Function If
im trying to figur out how i can have it so that if the dragable mc is hitting the mc dude which is on top of mc floor it wont be able to perform the drop target. this is the last thing i need to have my game fully operational so anyone could help it would be VERY MUCH appreciated
on (release) {
this.stopDrag();
setProperty(this, _x, 450);
setProperty(this, _y, 265);
if(this._droptarget=="/floor1"){
if(this.hitTest(dude1){
**stop the fuction**
}
trace("hit!");
_root.money = _root.money-10;
_root.time = _root.time-7;
trace (_root.money);
_root.floor1.gotoAndPlay(2);
}
}
How To Stop A Function?
Hi everyone,
I have this timer which plays a movie clip when it reaches a specific time.
There is a button that you can click on that plays the movie clip aswel. If I press the button before the timer is triggered the movie clip will start from the beginning again.
Is there a way to stop the function when the user hits the button?
This is the timer AS:
function countdown():Void{
trace("moving on");
_root.hmp.gotoAndPlay(2);
clearInterval(myDelay);
}
var myDelay:Number = setInterval(countdown, 10000);
stop();
This is the button AS:
on(release){
_root.hmp.gotoAndPlay("hmp");
}
I dont know the right syntax (hense the thread) but in simple terms I want this to happen:
on(release){
_root.hmp.gotoAndPlay("hmp");
STOP COUNTDOWN
}
Please can someone help?
How Do I Use The Stop Function ?
I have an intro on the first frame. Once i hit my skip button i go to the second frame but the audio from first frame keeps still going.
i started with a bit of code which makes my skip button work and takes me to the second frame:
stop();
skip.addEventListener(MouseEvent.CLICK, gonextframe);
function gonextframe(event:MouseEvent):void {
nextFrame();
}
So now im on the second frame but i can still hear the intro music playin from the first frame.
Do i have to add another eventlistener to the skip button and use the stop(); function ?
How To Stop A Function?
Hi.
I have this function:
function proceed()
{
if (this._currentframe == 4)
{
this.gotoAndPlay(1);
}
else
{
clearInterval(delayTime);
nextFrame();
}
}
How can I stop it trough a button?
Stop A Function
I'm being brainless, once again, but how do I stop a function? It happens every frame but I want it to not do it every frame when I push a certain button, and then be able to start running again it later (if I desire). How do I do that?
How Do You Stop A Function (k)
I have this code placed in the second frame of my timeline. It is there
to pause the playhead for 4 seconds before moving onto the next frame.
Problem with the code is that once the statement is true it keeps
jumping ahead doing a perpetual nextFrame.
I want to reset the variables and stop the function. I have no idea what
I am doing.
//
startTime = getTimer();
trace("startTime "+startTime);
this.onEnterFrame = function() {
currentTime = getTimer();
//4000 below = 4 seconds
if (currentTime-startTime>4000) {
nextFrame();
trace("currentTime "+currentTime);
}
};
|