Repeat A Function X Times? - Crazy Animation...
Hey Everyone!
I am trying to repeat a function x number of times. How do I go about doing that?
Here is the function:
Code:
function dance(){
var animspeed = .4;
var back = 0;
var delay = (animspeed);
var delay1 = (animspeed*2);
var delay2 = (animspeed*3);
body.slideTo(124,304, animspeed, "easeOutSine");
//lowerbody down
body.lowerbody.rleg.rthigh.rotateTo(-30,animspeed,"easeInOutSine");
body.lowerbody.rleg.rthigh.rfoot.rotateTo(40,animspeed,"easeInOutSine");
body.lowerbody.lleg.lthigh.rotateTo(30,animspeed,"easeInOutSine");
body.lowerbody.lleg.lthigh.lfoot.rotateTo(-40,animspeed,"easeInOutSine");
//upperbody flail
body.upperbody.rarm.rotateTo(-70,animspeed,"easeInOutSine");
body.upperbody.rarm.rhand.rotateTo(-30,animspeed,"easeInOutSine");
body.upperbody.larm.rotateTo(70,animspeed,"easeInOutSine");
body.upperbody.larm.lhand.rotateTo(30,animspeed,"easeInOutSine");
//AND BACK!
body.slideTo(124,300, animspeed, "easeOutSine", delay);
body.lowerbody.rleg.rthigh.rotateTo(back,animspeed,"easeInOutSine", delay);
body.lowerbody.rleg.rthigh.rfoot.rotateTo(back,animspeed,"easeInOutSine", delay);
body.lowerbody.lleg.lthigh.rotateTo(back,animspeed,"easeInOutSine", delay);
body.lowerbody.lleg.lthigh.lfoot.rotateTo(back,animspeed,"easeInOutSine", delay);
body.upperbody.rarm.rotateTo(back,animspeed,"easeInOutSine", delay);
body.upperbody.rarm.rhand.rotateTo(0,animspeed,"easeInOutSine", delay);
body.upperbody.larm.rotateTo(back,animspeed,"easeInOutSine", delay);
body.upperbody.larm.lhand.rotateTo(back,animspeed,"easeInOutSine", delay);
}
How could I repeat that function x number of times if I use an on(mousePress) as my event?
Thanks!
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-23-2006, 05:14 PM
View Complete Forum Thread with Replies
Sponsored Links:
Repeat Movie 'x' Times?
Q: I have a movie 4 scenes long. I want to repeat the whole movie (all 4 scenes) a full 3 times and then stop on the last frame of the last scene untill the page is refreshed. It is not something I have come across before (not much of a scripter!) I realise I could just duplicate the scenes and end up with 12 scenes that play 1-12 and stop, but is there another way?
View Replies !
View Related
MC Repeat Section "x" Times, Then Move On.
How can I make an MC repeat a portion a specific number of times, then jump to the next section after the desired number of repeats has been achieved?
I have the MC sitting on my main time line. Frame 1 is labled "start". Frame 12 is labled "repeat" and frame 13 is labled "nextsection".
Frame 12 currently has gotoAndPlay("start"); How can I modify this so that it repeats "x" number of times, then goes to "nextsection"?
Thanks
View Replies !
View Related
How Repeat A Part Of An Animation?
i have an animation which contains 30 frames. it has two layers. the first layer has animation till the last frame but the second layer has animation only till the 3rd frame.. now i want the second layer to repeat itself its animation(3 frames) for 10 times till the movie reaches the end(30th frame).. how to do this? do i need any technique using action script?.. please help out..
View Replies !
View Related
Button Animation Repeat Problem
hello there
i searched for this as i thought there would be hundreds of threads on this but i couldnt seem to find an answer
i have a movieclip inside a button for my rollover animation.
when you click on the button it plays a sound but it also replays the rollover animation.
how can i set my button up so that it will only play the animation once until the mouse has left rollover area and re-entered it again?
thanks in advance
View Replies !
View Related
How To Make Background Animation Repeat?
Please help me with this. Thanks.
I am trying to make the background loop again and again.
e.g. The background text "Happy Happy Happy Happy" will move from left to right again and again endlessly looking slowly and smooth.
I tried doing use tweening but as the frame start from frame 1 again, it will blink then loop again.. this is not smooth.
Is there any coding that anyone can help me with.
Thanks.
View Replies !
View Related
Random Function With No Repeat
Guys, I have a big problem
It is to do with randomising which one of 4 frames the movie goes to.
I have a script which randomly selects 1 of four frames.
frames = 4;
frameno = Math.ceil(Math.random()*frames);
gotoAndStop (frameno+1);
But i want it so that it only selects each frame once
If anyone has any idea on how to do this i would be so graftul.
Matt
View Replies !
View Related
[cs3] Function Doesn't Repeat...
I'm making an up button that scrolls the'content' on the page up, the code does what it should do but it doesn't repeat, you have to keep rolling over the button to get the content to the target position. Can anyone help?
ytarget = 0;
up.onRollOver = goUp;
function goUp() {
yMC = getProperty(_root.content, _y);
moveMC = _root.ytarget - yMC;
setProperty(_root.content, _y, yMC + (moveMC/10));
}
View Replies !
View Related
Repeat Same Function For Add. Movieclips
Hi !
The enclosed fla-file have a script that does some things to movieclip "mc_1", but how do I repeat the script to do the same thing on other mc's, with an interval of .2 or .4 seconds?
The script:
Code:
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
// Tween(obj, prop, func, begin, finish, duration, useSeconds)
// BlurFilter(blurX, blurY, quality);
//
var clip_y:Number = 50;
//
// the mc starts at position "clip_y" and stays on for x seconds
//
function one_1() {
new Tween(mc_1, "_y", Elastic.easeOut, clip_y, clip_y, 2000, true);
interval_1 = setInterval(two_2, 2100);
clearInterval(interval_4);
}
//
// the mc is blured and moved to a new position
//
function two_2() {
var blur_movieclip = new Tween(mc_1, "blur", Strong.easeOut, 0, 24, .8, true);
var blur_movieclip = new Tween(mc_1, "_y", Strong.easeOut, clip_y, clip_y-80, .8, true);
blur_movieclip.onMotionChanged = function(the_movieclip:Object) {
the_movieclip.obj.filters = [new BlurFilter(0, the_movieclip.obj.blur, 3)];
}
interval_2 = setInterval(three_3, 800);
clearInterval(interval_1);
}
//
// the mc is blured and moved to a new position
//
function three_3() {
var blur_movieclip = new Tween(mc_1, "blur", Strong.easeOut, 43, 46, 1, true);
var blur_movieclip = new Tween(mc_1, "_y", Strong.easeOut, clip_y+115, clip_y-100, 1, true);
blur_movieclip.onMotionChanged = function(the_movieclip:Object) {
the_movieclip.obj.filters = [new BlurFilter(0, the_movieclip.obj.blur, 3)];
}
interval_3 = setInterval(four_4, 1000);
clearInterval(interval_2);
}
//
// the mc is un-blured and moved to a start position
//
function four_4() {
var blur_movieclip = new Tween(mc_1, "blur", Strong.easeOut, 26, 0, 1, true);
var blur_movieclip = new Tween(mc_1, "_y", Strong.easeOut, clip_y+95, clip_y, 2, true);
blur_movieclip.onMotionChanged = function(the_movieclip:Object) {
the_movieclip.obj.filters = [new BlurFilter(0, the_movieclip.obj.blur, 3)];
}
interval_4 = setInterval(one_1, 3100);
clearInterval(interval_3);
}
//
one_1();
Thank you
Ferran
View Replies !
View Related
Button To Repeat A Function
I could really use some help, please. How would I add a Close button to a loaded swf/menu to imitate the same action that the click on the image does. I'm referring to the Carousel 3 example, Where the image slides back into position and the rotating starts up again.
I have a popup menu with a close button on it. I would like to close the menu and then the single image on the carousel would move back into position and then the rotating begins again.
View Replies !
View Related
Animation Loop For 7 Times
Hi, noob here,
I have been searching the forum about looping animations, and need to know how I can make my movie loop, say only 7 times.
The user can stop the movie anytime.
Then, the user must hit the play button again to start the movie after it stops after the 7th loop.
jbonham
View Replies !
View Related
Looping Animation 4 Times
For whatever reason I can't get this to work. I have a banner ad that I built with everything on the main timeline and the client would like it to loop 4 times. What is the best or easiest way to do this. Through the property Inspector? ActionScript? The only way I was able to get it to work was by putting my main movie within a graphic symbol on the root timeline and by extending that symbol out to the amount of frames the movie would take to play 4 times (Main movie is 383 and at four times that would expand to 1532 frames). I also tried it with a while statement but can't get it to work.
ex.
i = 4;
while (i > 0) {
myMC.duplicateMovieClip("newMC" + i, i );
i--;
}
Thanks in advance.
View Replies !
View Related
Call A Function To Repeat Over A Few Different Frames
I would like to be able to call a function from a movie clip so that the function repeats itself over a few different frames without having to be called again. I could have the function call itself according to an "if" statement but I believe that the movie will not go the next frame until it finishes all the cycles. So for example: The function makes the movieclip move over a few pixels but I want it to move over a bunch of pixels so as to give the illusion that it is moving slowly, I To do that the function needs to repeat until the movieclip moves the entire distance, but if that happens all within the function, at least as far as I have been able to figure out, the movie clip simply jumps to the last position without the viewer seeing each step of its movement.
Does anyone know how to fix this?
View Replies !
View Related
Loop Animation X Number Of Times
Hi all,
I want to stop my animation from continously looping and instead only loop twice and then stop on a frame mid-way through the animation during the second loop.
Ive done it by duplicating the frames and adding a stop function at the end but i thought there much be a quicker way using actionscript to do this.
thanks
View Replies !
View Related
Play Animation Multiple Times
Hello to everyone,
I have a flash banner animation and I need to know if there is any sort of script that plays the animation multiple times all over from the beginning and then stop at the end (let's say after playing three times it then stops.
I have already found a solution about my above request, but just need if anyone has the script for it.
I am good at flash and can help someone in return if needed anything, but this type of requirement that I am asking above is something I have never done.
Thanks for all your kindness and help.
Respectfully yours,
Beko
View Replies !
View Related
Loop Animation X Number Of Times
Hi all,
I want to stop my animation from continously looping and instead only loop twice and then stop on a frame mid-way through the animation during the second loop.
Ive done it by duplicating the frames and adding a stop function at the end but i thought there much be a quicker way using actionscript to do this.
thanks
View Replies !
View Related
Run Animation/form 200 Times Then Change
You lucky people!
I need some thought on a project i may be doing soon and would love your help or pointers if a t all possible.
I want to create an animation which promots a free gift, when they click they get a form to apply.
I need the swf to count how many successfull form completed on an external file (txt file etc) once the counter reaches 200 on the file it will then change the banner to promote omehting differnet eg, show a different animation.
Basically read and write to a file check to see if this exceeds and change the movie based on this figure!
Thanks so much in advance guys.
Many thanks!
Anthony :shock:
View Replies !
View Related
[MX04] Getting A Function To Repeat/setInterval Problem
Hey gang... this should be the last question for a while.
After some help from the boards, I have created a function that duplicates some MCs, runs the animation, and then removes the clips when they reach a certain point on the _y axis. I need for that function to repeat every so often (let's say 5 secs for this example)... I thought it was a simple setInterval, but it's acting all wonky.
Can someone help me sort it out?
code: condensation = function () {
var condensationNum = Math.round(Math.random()*4)+1;
for (i=0; i<condensationNum; i++) {
attachMovie("drops", "dupMC"+i, i);
this["dupMC"+i]._x = Math.round(Math.random()*200)+500;
this["dupMC"+i]._y = Math.round(Math.random()*155)+195;
var scale = Math.round(Math.random()*50)+50;
this["dupMC"+i]._xscale = scale;
this["dupMC"+i]._yscale = scale;
}
this.onEnterFrame = function() {
with (this) {
for (i=0; i<condensationNum; i++) {
if (this["dupMC"+i].dropMC._y+this["dupMC"+i]._y>525) {
this["dupMC"+i].stop();
if (this["dupMC"+i]._alpha>1) {
this["dupMC"+i]._alpha -= 10;
} else {
this["dupMC"+i].removeMovieClip();
}
}
}
}
};
};
this.onEnterFrame = function() {
myInterval = setInterval(condensation(this), 5000);
};
The problem is that I have 2 onEnterFrames called from the _root, but I don't know where to put the other one. The only things I've got on the stage with instance names are the MCs created within the function, and since I suck at loops I have no idea what how change the pathing of the onEnterFrame found within the function so that I can use the _root for the other one. I hope that makes sense...
Any help is most appreciated!
-Sandy
View Replies !
View Related
Crazy Text Animation
Click on Folio, then watch the description text.
http://www.mw2designs.com/
it seems like each word is its own movie clip, and I assume its reading text from XML. Does anyone know how this effect is accomplished or can point me to a tutorial? thanks!
View Replies !
View Related
Crazy Embellishment Animation
http://www.toothandnail.com/index2.html
I've seen people paste the object into flash and then erase a little of the object at a time, making keyframes after each pass, and then reversing the keyframes, but this is incredibly smooth. I've seen examples of this everywhere but I'd like to know if there's a secret to getting this effect to work smoothly.
View Replies !
View Related
Scripted Animation Go Crazy When Replaying...
Hey guys,
I got some strange problems when doing a replay animation. The way I set up my movie is like this: A main movie(Movie A) load in the sub movie(Movie B) for animation using loadMovie. The Movie B uses the Flash Tween class to create the animation. Back in the Movie A, there is a button when it's rollovered the Movie B should replay from beginning. For doing the replay, I tried putting "movieB.gotoAndPLay(1);" or "movieB.ini();" (ini() is for initialing the animation) to replay the animation. It works ok if the replay was called after the Movie B animation is finished, however, if the replay was called during the animation, then the animation would go crazy.....
I tried several way to solve this issue. I tried to reset the object position at the beginning of the animaiton or to removie the Movie B and load again before replaying, but none of them worked. I was guessing that maybe the tween animation wasn't really cleared even the movie itself was unloaded. Or maybe the object's position was cached so it can't be animated correctly. Is there any way to remove the Tween completely? or should I just gave up and back to use time-line based animation instead of using the Tween class?
Hope my explaination is understandable. Thanks a lot in advance. Any suggestions will be very very helpful. Thank you.
View Replies !
View Related
Calling A Function 50 Times, How To Do?
How can I simplify this?
Movieclip.prototype.randomcolor=function(rank){
if (rank>25) {
var r=255
var g=rank/50*255
var b=rank/50*255
var c=new Color(this)
c.setRGB(r<<16|g<<8|b)
}
else {
var r=rank*255/50
var g=0
var b=0
var c=new Color(this)
c.setRGB(r<<16|g<<8|b)
}
}
_root.map.s1.randomcolor(23);
_root.map.s2.randomcolor(48);
_root.map.s3.randomcolor(20);
_root.map.s4.randomcolor(33);
_root.map.s5.randomcolor(1);
_root.map.s6.randomcolor(24);
_root.map.s7.randomcolor(29);
_root.map.s8.randomcolor(45);
_root.map.s9.randomcolor(4);
_root.map.s10.randomcolor(10);
_root.map.s11.randomcolor(42);
_root.map.s12.randomcolor(39);
_root.map.s13.randomcolor(5);
_root.map.s14.randomcolor(14);
_root.map.s15.randomcolor(30);
_root.map.s16.randomcolor(32);
_root.map.s17.randomcolor(25);
_root.map.s18.randomcolor(22);
_root.map.s19.randomcolor(40);
_root.map.s20.randomcolor(19);
_root.map.s21.randomcolor(13);
_root.map.s22.randomcolor(8);
_root.map.s23.randomcolor(21);
_root.map.s24.randomcolor(31);
_root.map.s25.randomcolor(17);
_root.map.s26.randomcolor(44);
_root.map.s27.randomcolor(38);
_root.map.s28.randomcolor(35);
_root.map.s29.randomcolor(41);
_root.map.s30.randomcolor(9);
_root.map.s31.randomcolor(36);
_root.map.s32.randomcolor(3);
_root.map.s33.randomcolor(11);
_root.map.s34.randomcolor(47);
_root.map.s35.randomcolor(7);
_root.map.s36.randomcolor(27);
_root.map.s37.randomcolor(28);
_root.map.s38.randomcolor(26);
_root.map.s39.randomcolor(46);
_root.map.s40.randomcolor(14);
_root.map.s41.randomcolor(2);
_root.map.s42.randomcolor(34);
_root.map.s43.randomcolor(49);
_root.map.s44.randomcolor(12);
_root.map.s45.randomcolor(15);
_root.map.s46.randomcolor(37);
_root.map.s47.randomcolor(18);
_root.map.s48.randomcolor(50);
_root.map.s49.randomcolor();
_root.map.s50.randomcolor();
View Replies !
View Related
Recall A Function X Times
Hi,
I made a simple rollover function. I need to call that function x times. Is that possible with a for loop?
I tried this, but the "for" part didn't work
//Rollover function
function rollin(nr){
if(_global.a != nr){
tellTarget(_root.topnav add ".nav" add nr){
gotoAndPlay("rollin");
}
}
}
//Recall function x times
for(i=0;i<40;i++){
topnav.nav1.onRollOut = function() {
rollin(1
i);
}
As you can see, I need the function quiete often, so a rather use a function..
Thanks for reading and replying
Frans-Jan
View Replies !
View Related
Why Can't I Run My Function Several Times Simmultaneously ?
To practice actionscript I've been taking free code from the web and trying to improve it. I got this code to make a movieclip follow the cursor...
Code:
onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/10;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
//y movement
my=_root._ymouse;
if (my<_y) {
dy=_y-my;
}
else {
dy=my-_y;
}
moveSpeedy=dy/10;
if (my<_y) {
_y=_y-moveSpeedy;
}
else {
_y=_y+moveSpeedy;
}
}
I'm not sure or really bothered if that is good code as much as I wanted to see if I could wrap it up in a function that I could use on any movieclips I chose, each with a unique follow speed as well as remove the onEnterFrame when it wasn't needed so it wasn't running severally and continiously... just to see if I could.
SoI did this...
Code:
/// these are my movieclips, they're little fly animations
var mcFly_1:MovieClip;
var mcFly_2:MovieClip;
var mcFly_3:MovieClip;
// create a function and pass it a movieClip name and value of the 'lag' on the cursor follow
function followCursor(follower:MovieClip, lag:Number):Void {
var motionX:Number;
var motionY:Number;
var dx:Number;
var dy:Number;
onMouseMove = function () {
follower.onEnterFrame = function():Void {
//x movement
motionX = _root._xmouse;
if (motionX<follower._x) {
dx = follower._x-motionX;
} else {
dx = motionX-follower._x;
}
movspeedx = dx/lag;
if (motionX<follower._x) {
follower._x = follower._x-movspeedx;
} else {
follower._x = follower._x+movspeedx;
}
//y movement
motionY = _root._ymouse;
if (motionY<follower._y) {
dy = follower._y-motionY;
} else {
dy = motionY-follower._y;
}
movspeedy = dy/lag;
if (motionY<follower._y) {
follower._y = follower._y-movspeedy;
} else {
follower._y = follower._y+movspeedy;
}
// delete onEnterFrame on mouse hit
if (follower.hitTest(_xmouse, _ymouse, true)) {
trace(follower);
delete follower.onEnterFrame;
}
};
};
}
It works fine when I run
Code:
followCursor(mcFly_1, 10);
or
Code:
followCursor(mcFly_2, 20);
or
Code:
followCursor(mcFly_3, 30);
... but when I run
Code:
followCursor(mcFly_1, 10);
followCursor(mcFly_2, 20);
followCursor(mcFly_3, 30);
the function only runs on the last instance - presumably each subsequent invocation of the function is removing the previous, but why? How can I make this work for all clips?
Should I re-write it as a for-loop? I think I should but I want to know why this isn't working as it is
thanks in advance
Scott
View Replies !
View Related
Listener Run My Function 2 Times
Hello, I hope I could get some help with this issue, since I give up. It is too much for just me.
This script is originally from MX. I have a hard time trying to translate to AS3.
Anyway. There were a moment when I have to mix the original code with the slide show tutorial from kirupa site. Right now is almost functional. But it behave very weird when is online.
My problem is this. After all the work my final touch is to place a preloader to each loaded image(I already made it). But the secuence should be IF LOADED...then execute the FX and summ 1 number to the secuence...
At the end everything works OK, locally, but online the process show the previous images before it get to the preloader secuence of the new comming image. Becouse of this I step a few test behind the actual and noted this:
When the user see the first set of images, everything is OK, but if he move to other, then the listener seem to execute the click function 2 times, becouse the trace window show 2 outputs. At the end we have the right number, but I don't know if this is the problem.
I'm placing the file here, since it seem to be a little big to post here, and the code is very long.
http://bengalamedialab/forums/album_trace_error.zip
One more thing, I hope someone could help me becouse this is a very diferent kind of gallery file, and I think it could be usefull to others. It has some interesting funtionalities, but I have to solve this small problem before I could place it for the public use. And there aren't many in AS3.
View Replies !
View Related
Function Going Crazy
There is a thread: "declaring a function", which must have a infinite loop in it. What's going on there? A discussion about function is fine but I don't quite see the 1) MX relevance and 2) the specific problem in creating a file.
View Replies !
View Related
Going Crazy..please Help Me With This Function.
This is getting me so frustrated I'm about to hurl this damn computer out the window !!!
I have finished most of the tutorials (they are awesome), and I have learned so much about flash than I ever thought I would.
But this last thing is driving me crazy. It seems so simple but I can't pull it off for some reason.
I have one list window (instance: nameList) and one dynamic text window (instance: nameInfo) fed by an xml file. The list works just fine and reads the xml when I click on each item in the list.
My goal is to use "itemRollOver" to launch the text info automatically without having to click on the darn name in the list.
This is somewhat the same effect as the "Select A Tutorial" list in main gotoAndLearn window, except instead of a text bubble, I just want the text to display in the dynamic text window.
I have tried so many versions of the function, but "undefined" is the best I can do :(
Anyway, here is the code. Help before my computer meets an untimely death.
Code:
var listArray:XML = new XML();
listArray.ignoreWhite = true;
var picArray:Array = new Array();
var infoArray:Array = new Array();
listArray.onLoad = function()
{
var loop:Array = this.firstChild.childNodes;
for(i=0;i<loop.length;i++)
{
nameList.addItem(loop[i].attributes.listName);
infoArray.push(loop[i].attributes.desc);
}
}
var textList:Object = new Object();
textList.change = function()
{
nameInfo.text = infoArray[nameList.selectedIndex];
}
textList.itemRollOver = function()
{
}
nameList.addEventListener("change",textList);
nameList.addEventListener("itemRollOver", textlist);
listArray.load("text.xml");
EDIT:
Here is the XML file as well:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<list>
<item listName="List Name 1" desc="Name 1 Text Here" />
<item listName="List Name 2" desc="Name 2 Text Here" />
</list>
View Replies !
View Related
Calling A Function Multiple Times
Any ideas on the best way to fade a number of different movie clips simultaneously.
I'm using a for...loop to address each mc, that calls a fade function ( using onEnterFrame to reduce the alpha by 10 each pass )- but the function is only working on the last mc to be called.
For example i=1 to 10 addresses each mc and then calls the function for each one. The function is only working on mc number 10, as it seems to restart with each new mc. Can I pause the for...loop until the function has finished ????
View Replies !
View Related
Referencing A Function Multiple Times
I have this code to make mc's move and scale
Code:
function startMove(x, y, w, h) {
this.destX = x;
this.destY = y;
this.destW = w;
this.destH = h;
this.onEnterFrame = move;
}
function move() {
this._x += (this.destX-this._x)/4;
this._y += (this.destY-this._y)/4;
this._width += (this.destW-this._width)/4;
this._height += (this.destH-this._height)/4;
if (Math.round(this._x) == this.destX && Math.round(this._y) == this.destY) {
if (Math.round(this._width) == this.destW && Math.round(this._height) == this.destH) {
this._x = this.destX;
this._y = this.destY;
this._width = this.destW;
this._height = this.destH;
delete this.onEnterFrame;
}
}
}
What is the proper way to set up multiple calls of this code?
Currently I am doing this
Code:
btn.onRelease = function(){
startMove.call(mcBox, 176, 16, 208, 108)
startMove.call(mcText, 180, 150, 193.9, 32.7)
startMove.call(compFader, 180, 20, 200, 100)
startMove.call(mcMask, 190, 30, 190, 90)
}
Is there anyway to reference the startMove.call and then add all of my parameters under it somehow?
Thanks
View Replies !
View Related
Calling Same Function Multiple Times
I am trying to make a simple text effect I can easily modify and use across a flash project. I have a function that does the effect just the way I want it, until I try to call the function somewhere else in the movie. I was hoping someone could lend a hand.
Code:
function superText(theText,space,initX,initY){
i=1;
speed = 50;
function newText() {
if(i<theText.length+1) {
thisLetter = theText.substring(i-1,i);
textMovies = attachMovie("textBox","textBox"+i,i);
textMovies._x = textMovies._x + initX
textMovies._x = textMovies._x + initX +(space * i);
textMovies._y = initY;
textMovies.theText = thisLetter;
++i;
} else {
clearInterval(intevalID);
}
}
intevalID = setInterval(newText,speed);
}
superText("Am I Qualified?",12,4,50);
So far I can get the last function call to run normally. I have tried making all variables dynamic and had some even stranger results.
View Replies !
View Related
Running A Function Multiple Times
I have posted this question in several different ways and looked all over, but I still don"t know...
I have a function that creates an object(I've run into this problem while creating movieclips and sounds) I only want one of this object to exist. So when the function is called again I want it to remove the previous object. Does that make sense, I don;t know if this is a coding question or if I need to understand something about how the compiler works or what, but any advise or links would be appreciated.
View Replies !
View Related
Function Going Crazy Second Time Round
Okay, I've got an interactive flash app which creates survey questions and stores them in a database through ASP.
On one frame of the app there is a way of changing the order of the questions by use of a pseudo drag-and-drop function. The function essentially gets the original position of the question line (oldPos), then works out the new position based on the mouse Y position at release (y_pos) and changes the order accordingly. See code below.
code:
function getFormattedPosition(y_pos,oldPos){
newPosition = Math.round((y_pos - startHeight)/30)+1 + adjuster;
trace("newPos=" + newPosition);
if (newPosition >= _root.totalQs)
{
newPosition = _root.totalQs - 1;
}
if (newPosition < 1)
{
newPosition = 1;
}
trace(newPosition);
if (newPosition > oldPos)
{
temp= _root["survLine"+oldPos].ans;
tempDate= _root["survLine"+oldPos].date;
tempTitle= _root["survLine"+oldPos].title;
tempId = _root["survLine"+oldPos].id;
n = oldPos;
for (n==oldPos;n<=newPosition;n++){
changer=n+1;
_root["survLine"+n].title = _root["survLine"+changer].title;
_root["survLine"+n].ans = _root["survLine"+changer].ans;
_root["survLine"+n].date = _root["survLine"+changer].date;
_root["survLine"+n].id = _root["survLine"+changer].id;
//trace("changed= " + _root["survLine"+n].ans);
}
_root["survLine"+newPosition].ans = temp;
_root["survLine"+newPosition].date = tempDate;
_root["survLine"+newPosition].title = tempTitle;
_root["survLine"+newPosition].id = tempId;
}
else(newPosition < oldPos)
{
difference = oldPos-newPosition;
if (difference >0){
trace("difference="+difference);
temp= _root["survLine"+oldPos].ans;
tempDate= _root["survLine"+oldPos].date;
tempTitle= _root["survLine"+oldPos].title;
tempId = _root["survLine"+oldPos].id;
n = oldPos;
for(n==_root.oldPos;n>=newPosition;n--){
changer=n-1
_root["survLine"+n].ans = _root["survLine"+changer].ans;
_root["survLine"+n].date = _root["survLine"+changer].date;
_root["survLine"+n].title = _root["survLine"+changer].title;
_root["survLine"+n].id = _root["survLine"+changer].id;
trace(_root["survLine"+n].ans);
}
_root["survLine"+newPosition].ans = temp;
_root["survLine"+newPosition].date = tempDate;
_root["survLine"+newPosition].title = tempTitle;
_root["survLine"+newPosition].id = tempId;
}
}
}
Additionally, the cursor changes to a "gripping hand" MC while 'dragging' the line.
Anyway, problem comes after submitting the changes to the database. If you then return to the frame to re-edit the order the code starts acting strangely. The newPosition is recorded inaccurately and the gripping hand MC refuses to vanish on release.
Anyone know why it should work first time fine, but screwy after that? Sorry if I haven't explained it very well, thanks for any help.
E
EDIT: Ah, is fixed now.
View Replies !
View Related
Spacebar Key Listener Calls Function Multiple Times
My problem:
I have a file, index.swf, which contains a movieClip name loader_mc. As you might expect, I have four separate .swf files that load into loader_mc from a menu on index.swf.
On two of my .swf files, movie1.swf & movie 3.swf, I have placed code that allows the user to advance the page by clicking the spacebar as well as by clicking the next_btn.
The code works fine the first time that you open movie1.swf or movie3.swf from index.swf. However, after returning to the menu and loading a new .swf into loader_mc, the spacebar now advances two pages instead of one. The third time I've loaded a .swf into loader_mc, the spacebar will now advance 3 pages (and so on). It doesn't matter whether I load the same .swf into loader_mc or a new one (i.e. I can open movie1.swf from the main menu on index.swf 5 times and the spacebar will now advance the page 5x when moving through movie1.swf).
My Code:
Here is the code which controls page navigation. It is placed on frame 1 of movie1.swf (similar code is placed on frame 1 of movie3.swf).
// Page Navigation________________________________________ _____//
function nextScreen() {
// I don't think that the code here is the issue, it advances the page or screen 1x
}
function previousScreen() {
// I don't think that the code here is the issue, it moves the page or screen backward 1x
}
// Button Code
next_btn.onRelease = nextScreen;
previous_btn.onRelease = previousScreen;
// SpaceBar (Hitting the spacebar rather than clicking the next button)
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == Key.SPACE) {
nextScreen();
}
};
Key.addListener(keyListener);
The next_btn correctly calls the nextScreen() function and appropriately advances the page 1x (no matter how many times I load movie1.swf into loader_mc). Since the spacebar listener is tied to the same function, I can only assume that somehow the spacebar code is being called multiple times simultaneously.
Any idea why the spacebar code duplicates itself when movie1.swf is reloaded into loader_mc?
View Replies !
View Related
[MX04] SetInterval Function Running Finite Number Of Times...
Hi,
I was wondering if someone could look over this(see code below). It basically stops responding and offers to stop running the script.
What I'm trying to do is run a function a finite number of times with an interval between each time it runs.
There may be a better way of doing it otherwise but any suggestions would be brill, Ta.
Neily
PHP Code:
onClipEvent (mouseUp) {
var Counter=0;
do {
setInterval(TraceTest,1000);
} while (Counter<=10);
setInterval(TraceTest,1000);
function TraceTest(){
trace("Function Called" + Counter);
Counter++;
}
}
View Replies !
View Related
Testing For A Repeat In A "Ranom" Function
Hello,
I have a .fla that has 40 placeholders(empty movieClips) into which I am loading random photos from a bank of 99. This is working except for when I use the random function, some of the photos are being repeated. Is there a way for me to avoid this?
Here is the AS I am using.
for (i=1; i<=40; i++) {
loadMovie("photoIcons/"+random(92)+".swf", "mc"+i);
}
Thanks,
Damien
View Replies !
View Related
Openning A Site 3 Times And 3 Times The First Image Is Different
hi))
iŽll try to put this simple..i have 3 pictures and i want to access my website in a way that every time i type the adress one pic of a time appears..
example: type adress - enter = pic 01 appears ...close
type adress again - enter = pic 02 appears ...close
type adress again - enter = pic 03 appears ...
and then of course loop to pic 1
appreciated if anyone could help(/and send example)
View Replies !
View Related
Crazy Easy If/else Script Drive Me Crazy
Hello new Kirupa friend! I am jakartaguy from jakarta indonesia with crazy simple question...
code below is okay IF people put in only number... but if they put in LETTER... result is NaN (non number)....
the code i use (from tutorial here) is:
if (ques1 > 100 || ques1 < 0 || ques1 == undefined) {
ValidationMessage = "For statement 1 please insert a number between 0 and 100%";
}
But question - how do I add if/else for Letter??? The script below NOT WORK... can someone please help??
if (ques1 > 100 || ques1 < 0 || ques = NaN || ques1 == undefined) {
ValidationMessage = "For statement 1 please insert a number between 0 and 100%";
}
thankyou(terima kasih)
jakartaguy
View Replies !
View Related
Start Non-repeat And Then Repeat?
Hey, i would like to make an image fade into appearance and then after that do a repeat of some kind of animation...
In other words have a character appear on screen, and then have his eyes change from red to black in a repeat.
How would i accomplish this? .
View Replies !
View Related
SetInterval Inside A Loop Inside A Function - Am I Crazy?
I've got a menu loading from XML data - however I'd like the mc's to appear sequentially, maybe 1/10th second apart. I know setInterval should do this, but I'm still new to flash and despite trawling Google for 24 hrs solid, nothing seems to show me the right way.
Here's the script:
Code:
function CreatePortMenu(port_xml)
{
var portClients = port_xml.firstChild.childNodes;
var xPos = 0;
var yPos = 0;
var xSpacing:Number = 90;
var ySpacing:Number = 35;
var i = 0;
for ( i = 0; i < portClients.length; i++ )
{
switch (i) //splits the menu items into columns of 4 (max 12 items)
{
case 0:
case 1:
case 2:
case 3:
yPos = ySpacing * i;
break;
case 4:
case 5:
case 6:
case 7:
xPos = xSpacing * 2;
yPos = ySpacing * (i - 4);
break;
case 8:
case 9:
case 10:
case 11:
xPos = xSpacing * 3;
yPos = ySpacing * (i - 8);
}
var currentClient = portClients[i];
var portHold = portHolder_mc.attachMovie( "jobOption", "pb"+i, i, {_x:xPos, _y:yPos});
portHold.jobTitle.jobText.text = currentClient.attributes.title;
}
}
So I *think* I should be inserting two lines, one creating a setInterval, and one clearing it, but where? Some guides say inside the function, some say outside, some say only the clearInterval should be inside, some have the function inside the loop... I also *think* I've tried every possible combination, but no soap. Please help!?
View Replies !
View Related
Crazy Client Came With Crazy Idea.
I met my client two weeks ago.
Thay want to do some multimedia like Karaokae
but that Karaokae thay want not like the other
like hmm... I want to type some words and then it will speak(TTS)
AND SPEAK OUT LIKE SINGING..
If my job is english or other language I will think about it...
but my language is harding to do this.
Question is can we do this?
base on Text to speech?
View Replies !
View Related
Animation On _x In Function
Hello,
Is it possible to animate a group of dynamically created movieclips by activating a function that should move them on their x axis incrimetally. instead they just seem to appear in the last position? once I've created the movie clips on the stage i start a the function below and pass it the value n = 1;
thanks for any help...
Craig
function moveblocs() {
oldPos = _root["homestrip"+n]._x;
dist = (300-oldPos)/48;
_root["homestrip"+n]._x = _root["homestrip"+n]._x+dist;
n++;
if (n>numofblocs) {
n = 1;
}
if (dist>0.1) {
moveblocs();
}
}
View Replies !
View Related
Function For The Whole Animation?
Hey! I am making an animation, and I want to call a function, but then I want this function to be recognized by all the buttons and frames in the movie? What do I need to do to make it a (Is Global the term?) Function?
Thanks!
I am using Flash MX 2004
View Replies !
View Related
|