MX- Function Works OnMouseUp, Not With SetInterval
Hi,
seem to have something wrong with the following code.
a bug in my loop maybe
It draws curves between mc h12, using ctl mc as the control point to each of the mc's h0 to h9.
mc's are all dragable.
at the end I have two methods of calling the draw function. When testing I comment one or the other out. (only ever one active)
setInterval gives me a curve from h12 to 0,0
onMouseUp gives me all the curves to the h0 to 9 mc's
setInterval may be drawing 10 curves to 0,0, not sure.
code is in a mc on the root positioned at 0,0 that just contains the code
setInterval is the method I actually want to use
any idea whats going on
thanks mark
XStart = 100;
YStart = 0;
// attach the end point handles
for (i=0; i<10; i++) {
_root.attachMovie("squareHandle", "h" add i, i);
this["h" add i]._x = XStart;
this["h" add i]._y = YStart;
XStart = XStart - 10;
YStart = YStart + 10;
}
_root.attachMovie("squareHandle", "h12" , 12);
_root.attachMovie("roundHandle", "ctl", 11);
h12._x = 300;
h12._y = 100;
ctl._x = 188;
ctl._y = 225;
_root.createEmptyMovieClip("curve_mc", 13);
function draw() {
j = 0;
curve_mc.clear();
curve_mc.lineStyle(0, 0x000000);
for (j=0; j<10; j++) {
curve_mc.moveTo(h12._x, h12._y);
curve_mc.curveTo(ctl._x, ctl._y, this["h" add j]._x, this["h" add j]._y);
}
}
onMouseUp = draw;
//setInterval(draw, 25);
stop();
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-19-2003, 02:14 PM
View Complete Forum Thread with Replies
Sponsored Links:
Replacing This.onMouseUp = Function() {
Dear All,
I am very new to Flash and here is my problem. I am trying to create my own screensaver using some of Tarbel's code to create an array of pixels within a movie clip. Thats all fine.
However there is a function() that I would like to replace and this is the
this.onMouseUp:
this.onMouseUp = function() {
if (gridmade) {
// remove old grid
for (var n = 0; n<gridList.length; n++) {
gridList[n].doFadeOut();
}
gridmade = false;
makeGrid();
}
};
gridmade = false;
makeGrid();
stop();
I am trying to automate the regeneration of the grid but I have no idea how
Any help would be appreciated.
Peter
View Replies !
View Related
Automate This.onMouseup = Function()
Dear All,
I have posted the same question over on the newbies page but got no replies so hopefully some actionscript guru can help me with this.
I am using some of J. tarbell's opensource actionscript for a screensaver and the below function is called to reset the array so that flash rebuilds the pixel blocks.
Is there a way that I can call this automatically on (gridmade) ie the grid is automatically rebuilt after it is completed negating the user interaction (its a screensaver)
this.onMouseup = function() {
if (gridmade) {
for (var n = 0; n<gridList.length; n++) {
gridList[n].doFadeOut();
}
gridmade = false;
makeGrid();
}
};
gridmade = false;
makeGrid();
stop();
+++++++++Full Code++++++++++++++++++
var maxx = 16;
var maxy = 9;
var gridspace = 64;
function makeGrid() {
gridList = new Array();
gridSpot = new Array();
var depth = 0;
for (var x = 0; x<maxx; x++) {
for (var y = 0; y<maxy; y++) {
point = {x:x, y:y};
gridSpot.push(point);
}
}
this.onEnterFrame = function() {
buildGrid();
};
}
function buildGrid() {
var n = random(gridspot.length);
point = gridSpot[n];
gridSpot.splice(n, 1);
var nombre = "qr"+String(depth++);
var init = {_xoint.x*gridspace+gridspace/2, _yoint.y*gridspace+gridspace/2, _xscale:gridspace, _yscale:gridspace};
var neo = this.attachMovie("ColourSquare", nombre, depth, init);
var fr = 0;
var fr_mean = 0;
for (var k = 0; k<this.gridList.length; k++) {
if (neo.hitTest(this.gridList[k])) {
fr += this.gridList[k].shade._currentframe;
fr_mean++;
}
}
if (fr_mean == 0) {
neo.setFrameRandom();
} else {
fr = Math.round(fr/fr_mean);
neo.setFrame(fr);
}
gridList.push(neo);
if (gridspot.length == 0) {
delete this.onEnterFrame;
gridmade = true;
}
}
this.onMouseup = function() {
if (gridmade) {
for (var n = 0; n<gridList.length; n++) {
gridList[n].doFadeOut();
}
gridmade = false;
makeGrid();
}
};
gridmade = false;
makeGrid();
stop();
View Replies !
View Related
Mymovieclip.onMouseUp = Function()
Hi Guys,
I have just developed a simple xml photo gallery. Below is the code that I have used to generate the gallery:
Code:
var gallery = createEmptyMovieClip("galleryImage",0);
for (i=0; i<total; i++) {
cur_item = gallery.attachMovie("mainImage","spec"+i, i);
cur_item.loadMovie(thumb[i], "mainImage");
cur_item.onMouseUp = function() {
getURL(javascript:openWindow("products/"+id+"/"+image[i]));
};
}
I am having difficulties to make each movie clip generated into a button that will call the javascript button:
Code:
cur_item.onMouseUp = function() {
getURL(javascript:openWindow("products/"+id+"/"+image[i]));
};
What i want to do is to allow the user to click on the movie clip and it will call javascript and open the image in a html window. For some reason I can't get it to do anything. Am i using the correct code to do this?
Please advise
Much appreciated
Daniel
View Replies !
View Related
SetInterval Works... Kindof
I have a setInterval question. I have a piece of code that I have been using on alot of my projects that waits x seconds before the timeline advances.
It works really good but on my most recent project I have navigation that skips around the timeline and it goofs up the timing. It makes setInterval act sporatically. I have each button clear the interval and this does not help my cause. Thanks ahead of time!
Here is the actionscript for the timing
PHP Code:
var seconds:Number;
function wait() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, seconds*1000);// stop for 4 seconds
}
seconds = 4;
wait();
and here is the actionscript for the buttons
PHP Code:
this.mc_thumb_na_1.onRollOver = function() {
_root.mc_slide.gotoAndPlay(1);
clearInterval(myInterval);
};
this.mc_thumb_na_2.onRollOver = function() {
_root.mc_slide.gotoAndPlay(21);
clearInterval(myInterval);
};
this.mc_thumb_na_3.onRollOver = function() {
_root.mc_slide.gotoAndPlay(42);
clearInterval(myInterval);
};
this.mc_thumb_na_4.onRollOver = function() {
_root.mc_slide.gotoAndPlay(63);
clearInterval(myInterval);
};
View Replies !
View Related
SetInterval: Scope Works Then Doesn't Work
I've created loads of classes that use setInterval. Each time I use the following syntax:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(this,"foobar",100);
}
private function foobar():Void {
trace(this);
}
}
I would get :
[Object Object] over and over and over
which would be expected.
And usually that works...but today I had a class that wouldn't work that way. When i ran the code above, it didn't set the interval at all. To get it to work I needed to write it like this:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(foobar,100);
}
private function foobar():Void {
trace(this);
}
}
the interval is called but the trace says undefined. if I pass an argument into the code:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(foobar,100,this);
}
private function foobar(passedItem:Object):Void {
trace(passedItem);
}
}
It traces [Object Object] again
The first code seems kosher and works everywhere but not in one class. anyone have a problem similar to this?
-D
View Replies !
View Related
SetInterval Function Please Help
This function outputs 1 letter at a time. But continues run this same function over and over again. Anyone know how to stop this function after it finishes outputting the last character in the x value, and move onto the next frame.
y=0;
function printer()
{
x = "David";
output.text = x.charAt(y);
y++;
}
setInterval(printer, 1500);
View Replies !
View Related
Setinterval On Function
peepz,
i tried something with setInterval to disable a function for a few seconds, but is doesn't working:
Code:
onClipEvent(load){
//set some vars in the this.
this.speedY = 0;
this.speedX = 0;
this.damping = .7;
this.easing = .2;
this.homeX = this._x;
this.homeY = this._y;
//higher is more sticky
this.stickiness=4;
//bounce prototype
this.blaat = function(){
this.onEnterFrame = function(){
//if the mouse is not over the box
if (!this.hitTest(_root._xmouse, _root._ymouse) or this.pressed == true) {
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
} else {
//otherwise, drag me with some friction
difX = this._parent._xmouse-this.homeX;
difY = this._parent._ymouse-this.homeY;
this._x = this._parent._xmouse-(difX/this.stickiness);
this._y = this._parent._ymouse-(difY/this.stickiness);
}
}
}
this.blaat2 = function(){
this.onEnterFrame = function(){
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
}
}
}
on(rollOver){
this.blaat();
}
on(release){
setInterval(this.blaat(), 1000);
this.blaat2();
this.pressed = true;
}
its a sticky button and onrelease it has to bounce back!
maybe somebody can give me some advise?
thnx,
robert
View Replies !
View Related
SetInterval Function. . .
I need a little assistance in creating a setInterval function based on my xml file. If anyone could help, I would really appreciate it!
Here's a sample of xml file:
<count id="1">
<mediatype>1</mediatype>
<information>Introduction</information>
<endtime>12</endtime>
</count>
<count id="2">
<mediatype>2</mediatype>
<information>Clip 2</information>
<endtime>50</endtime>
</count>
<count id="3">
<mediatype>3</mediatype>
<information>Clip 3</information>
<endtime>150</endtime>
</count>
This is a sample of my actionscript:
Code:
myInterval = setInterval(beginFadeOut, time());
function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time() {
sec = ((10/5)*1000);
trace("seconds called");
return sec;
}
eg.
sec = parent.childNodes[i].firstChild;
So, the value would be put in an array. I have tried several things, and have tried to ask the form, but no response.
If I need to post the .fla just let me know. Any assistance would be great!
Thanks,
cbs
View Replies !
View Related
Setinterval On Function
peepz,
i tried something with setInterval to disable a function for a few seconds, but is doesn't working:
ActionScript Code:
onClipEvent(load){
//set some vars in the this.
this.speedY = 0;
this.speedX = 0;
this.damping = .7;
this.easing = .2;
this.homeX = this._x;
this.homeY = this._y;
//higher is more sticky
this.stickiness=4;
//bounce prototype
this.blaat = function(){
this.onEnterFrame = function(){
//if the mouse is not over the box
if (!this.hitTest(_root._xmouse, _root._ymouse) or this.pressed == true) {
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
} else {
//otherwise, drag me with some friction
difX = this._parent._xmouse-this.homeX;
difY = this._parent._ymouse-this.homeY;
this._x = this._parent._xmouse-(difX/this.stickiness);
this._y = this._parent._ymouse-(difY/this.stickiness);
}
}
}
this.blaat2 = function(){
this.onEnterFrame = function(){
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
}
}
}
on(rollOver){
this.blaat();
}
on(release){
setInterval(this.blaat(), 1000);
this.blaat2();
this.pressed = true;
}
its a sticky button and onrelease it has to bounce back!
maybe somebody can give me some advise?
thnx,
robert
View Replies !
View Related
SetInterval Function
Hey guys,
I have a pretty simple question about the setInterval function (at least, I think it's simple). I am having a bit of a problem using it... I've never really used it before, and I'd much rather use it than do a frame count like I am usually doing.
Anyway, here's the code.
Code:
var ID:Number;
function tweenText() {
trace("pass");
var t1 = new Tween(this["cat"+i], "_alpha", Strong.easeOut, 0, 100, 50, false);
}
ID = setInterval(this, "tweenText", 2000);
basically, I want to run tweenText after 2000 milliseconds... Am I correc that this is what will happen? Am I using the correct structure?
-theonlycarmire
View Replies !
View Related
Obj.onMouseUp
Hi!
I am using the following script to return to an input box (inp_txt) when the stage is clicked:
obj = {};
obj.onMouseUp = function(){
Selection.setFocus(inp_txt);
}
Mouse.addListener(obj);
However, this is not working when I am in a separate scene. When I am in a separate scene, problems occur as the code is redirected to a second input area (inp_txt2).
I understand we are to never target a scene == To change scenes I have created a frame label on the first frame of the desired scene and targeted that.
So is there a reference script to determine in which scene I am to set focus to the chosen input text box?
PS Thanks AMD for your previous posts!
Thanks
View Replies !
View Related
Trouble Using The SetInterval Function
I am trying to load in external swf files into a target movie clip randomly after a set period of time, but i am having trouble creating the code following the example from the sctionscript dictionary.
Can anyone help me??!!
I need the code to be in MX
HELP!
View Replies !
View Related
How Do I Make A Function? (for SetInterval)
hello people,
i have made a script wich i want to make in to "function" so that i kan use the setInterval. with the setInterval i want to update the script. but when i make this script a function it doesn't work.
the script works fine but it only works once and when you resize your browser it doesn't adjust to it (wich i want).
the code beneath must become a function, but how?? thanx
Code:
_root.createEmptyMovieClip("barTop", 2);
with (_root.barTop){
beginFill (0x666666, 100);
moveTo (0, 0);
lineTo (0, 0);
lineTo (0, 20);
lineTo (_root.stageMC._width, 20);
lineTo (_root.stageMC._width, 0);
endFill();
}
_root.createEmptyMovieClip("barTop2", 6);
with (_root.barTop2){
beginFill (0x333333, 100);
moveTo (0, 20);
lineTo (0, 20);
lineTo (0, 22);
lineTo (_root.stageMC._width, 22);
lineTo (_root.stageMC._width, 20);
endFill();
}
_root.createEmptyMovieClip("bg", 3);
with (_root.bg){
beginFill (0xCCCCCC, 100);
moveTo (0, 22);
lineTo (0, 22);
lineTo (0, _root.stageMC._height -20);
lineTo (_root.stageMC._width, _root.stageMC._height -20);
lineTo (_root.stageMC._width, 22);
endFill();
}
_root.createEmptyMovieClip("barBottom", 4);
with (_root.barBottom){
beginFill (0xFF6600, 100);
moveTo (0, _root.stageMC._height -20);
lineTo (0, _root.stageMC._height -20);
lineTo (0, Stage.height);
lineTo (_root.stageMC._width, _root.stageMC._height);
lineTo (_root.stageMC._width, _root.stageMC._height -20);
endFill();
}
_root.createEmptyMovieClip("welkomsbloktitle", 8);
with (_root.welkomsbloktitle){
beginFill (0x666666, 100);
moveTo (10, 32);
lineTo (10, 32);
lineTo (10, 52);
lineTo ((_root.stageMC._width/100)*32, 52);
lineTo ((_root.stageMC._width/100)*32, 32);
endFill();
}
_root.createEmptyMovieClip("welkomsblok", 7);
with (_root.welkomsblok){
beginFill (0xFFFFFF, 100);
moveTo (10, 52);
lineTo (10, 52);
lineTo (10, _root.stageMC._height -30);
lineTo ((_root.stageMC._width/100)*32, _root.stageMC._height -30);
lineTo ((_root.stageMC._width/100)*32, 52);
endFill();
}
//title
_root.createTextField("title", 5, 0, 0, 300, 20);
title.type = "dynamic";
title.html = false;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.bold = true;
myTextFormat.selectable = false;
title.text = ": Creating a interface from script : : :";
title.setTextFormat(myTextFormat);
_root.createTextField("welkomstitle", 9, 10, 33, 300, 20);
welkomstitle.type = "dynamic";
welkomstitle.html = false;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.bold = false;
myTextFormat.selectable = false;
welkomstitle.text = ": Welkoms tekst : : :";
welkomstitle.setTextFormat(myTextFormat);
to see it work check the *.fla
View Replies !
View Related
Local Function / SetInterval
Why are my local functions / setIntervals not working? I'm using this code, which should work fine.
code: pause = function () {
trace("wuddup");
thisClip.play();
thisClip.clearInterval(thisClip.stall);
}
thisClip.stall = setInterval(pause(), 3000);
I've attached the source below.... just open it and goto the "02-INTROS" folder. Choose the "01-introGettingStarted" MC.
View Replies !
View Related
Refreshing Function With SetInterval
Hi,
I´ve got problem when resetting function with setInterval. The set interval function adds 1 to variable which I would like to use in further scripting. But when I reset this function it does not reset that variable to start counting from 0. Can anybody look at that script and tell me what I had done wrong. It annoys me and I cannot get through this. I´ll be pleased for any suggestions.
Thanx, Meerah
View Replies !
View Related
Refreshing Function With SetInterval
Hi,
I´ve got problem when resetting function with setInterval. The set interval function adds 1 to variable which I would like to use in further scripting. But when I reset this function it does not reset that variable to start counting from 0. Can anybody look at that script and tell me what I had done wrong. It annoys me and I cannot get through this. I´ll be pleased for any suggestions.
Thanx, Meerah
View Replies !
View Related
SetInterval Fired Up In A Function
I have written a class which I want to work with. It has a function which fires up an FS command which calls an external object. The FS call queries to see if a file exists. It waits for a returning boleean value to flag if the file exists, which does get returned.
Here is the problem:
Code:
this.loadFile = function(thisPath) {
var a = new Array();
thisVal = undefined;
thisVal = this.fileExists(thisPath);
coolio += "thats what I want";
};
....
this.fileExists = function(thisPath) {
returnVal = undefined;
aPath = thisPath;
// check to see if the file exists
fscomman("flashstudio.fileexists", "aPath,returnVal");
coolio = 0;
timerID = setInterval(checkReturn=function () {
if (returnVal == "true" || returnVal == "false") {
coolio += 1
clearInterval(timerID);
return (returnVal);
}}, 1000);
};
The issues is that the setInterval seems to get fored up in a seperate process. ie, the call from the loadFile function to the fileExists function should wait for its return value. This doesnt happen.....
I dont have this problem if I use setInterval outside of a class. As the logic flow is not dependant on it.
please please help...
View Replies !
View Related
SetInterval With OnEnterFrame Function?
this.objectMc.shake = function() {
clearInterval(shakeStart)
trace("shake")
this.onEnterFrame = function() {
trace("something")
};
}
this.objectMc.pressed = function() {
this.onPress = function() {
startDrag(this, false, 50, 300, 350, 1000);
shakeStart=setInterval(objectMc.shake,1000)
};
};
When I press my object, I see "shake" in my output window, but I don't see "something"... It seems like the enterFrame function was deleted by the setInterval !!!
This is quiet basic I think... but How can I fix this problem???
Thank U
View Replies !
View Related
SetInterval Inside Of A Function?
I can't seem to get the interval to call the function to play the next frame... Any help? thanks. I've tried to take out the single quotes.
code: function interval (btn, dir) {
function next () {
nextFrame ();
}
function back () {
prevFrame ();
}
btn.onEnterFrame = function () {
this.onRollOver = function () {
id = setInterval (dir, speed);
};
this.onRollOut = function () {
clearInterval (id);
};
};
}
interval (btn,'next')
interval (btn_back,'back')
View Replies !
View Related
Kill Function (setInterval)
peepz:
i have this to disable a function for a while but it isn't working:
Code:
on(rollOver){
this.blaat();
}
on(release){
setInterval(blaat, 10000000);
this.blaat2();
}
can someboydy help?
functions (they are for sticky buttons):
Code:
onClipEvent(load){
//set some vars in the this.
this.speedY = 0;
this.speedX = 0;
this.damping = .7;
this.easing = .2;
this.homeX = this._x;
this.homeY = this._y;
//higher is more sticky
this.stickiness=4;
//bounce prototype
this.blaat = function(){
this.onEnterFrame = function(){
//if the mouse is not over the box
if (!this.hitTest(_root._xmouse, _root._ymouse) or this.pressed == true) {
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
} else {
//otherwise, drag me with some friction
difX = this._parent._xmouse-this.homeX;
difY = this._parent._ymouse-this.homeY;
this._x = this._parent._xmouse-(difX/this.stickiness);
this._y = this._parent._ymouse-(difY/this.stickiness);
}
}
}
this.blaat2 = function(){
this.onEnterFrame = function(){
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
}
}
}
View Replies !
View Related
SetInterval W/ Anonymous Function
Ok, my actual code is much more complicated than this, but I've sheered it down as much as I can. Very little for you guys to look at.
Code:
createEmptyMovieClip("clip", 0);
clip.update = function() {
trace(this);
};
setInterval(clip.update, 500);
Very simply, the trace returns undefined every 500 ms. Calling clip.update() at any time normally and it works completely fine and returns clip. However, called from setInterval, it's giving undefined. You can trace clip.update from the function and that works fine also. So I'm not sure where it's losing the path. This is a rather curious problem... am I missing something obvious?
View Replies !
View Related
How To Use Setinterval With Function.apply()?
Hi there,
I am using the following code
Code:
motionMC.apply(text_mc,[100,1]);
function motionMC(endX,time) {
var mcTween:Tween = new Tween(this, "_x", Strong.easeOut, this._x, endX, time, true);
};
But I want to control the start time as well with setinterval
I tried
Code:
anime1 = setInterval(text_mc, "motionMC", 1000,[100, 1]);
View Replies !
View Related
SetInterval Inside A Function?
Hey guys, just ran into a bit of a snag ... trying to figure out why my code works outside of the main function, but not inside:
Code:
function thumbs():Void
{
var thumb:MovieClip;
thumbArray = new Array();
var duration:Number = 100;
var i:Number = 0;
//for (var i = 0; i < channelCount; i++)
//{
function runThumbs(){
var thumbData:Object = new Object;
deltaX = i - Math.floor(i / thumbsPerRow) * thumbsPerRow;
thumb = chan.attachMovie("c_thumb", "thumb" + i, zIndex++);
thumb._x = deltaX * (thumb._width + xSpacing) + thumbXBegin;
thumb._y = Math.floor(i / thumbsPerRow) * (thumb._height + ySpacing) + thumbYBegin;
thumbData.thumb = thumb;
thumbData.xPos = thumb._x;
thumbData.yPos = thumb._y;
thumbArray.push(thumbData);
thumb.setData(i, channels[i]);
img = "images/"+channels[i].cImg+".jpg";
image_mcl.addListener(imgListener);
image_mcl.loadClip(img, thumb.c_clip);
trace("executeCallback intervalId: " + intervalId + " count: " + i);
clearInterval(intervalId);
if(i < 10) {
i++;
intervalId = setInterval(this, "runThumbs", duration);
}
}
if(intervalId != null) {
clearInterval(intervalId);
}
intervalId = setInterval(this, "runThumbs", duration);
}
thumbs();
so if I take everything outside of the thumbs() function it works fine, but inside ... no go. I'm jsut learning about setinterval ...
oh ... and can someone please let me know what the "this" is inside the setInterval function. I know it's either function or object reference. But I'm still not clear on that part ...
View Replies !
View Related
Issue With SetInterval Function.
This is a simplified version of the actual project I'm working on, but it's basically set up the same way, I haven't been able to get much help from anyone on this yet, but maybe someone here will know how to deal with this
The main file contains a blank movie clip (loader_mc), it's set to load "mc_1.swf" by default. If one of the movie clips contained inside of mc_1.swf is clicked it changes the value of the _root variable stuff (_root.stuff) to 100. This is in turn supposed to then call the setInterval function callback0. I'm doing this because, in my more complex version, I need to have a delay to allow an animation to finish. The setInterval function callback0 is then supposed to load "mc_2.swf" into loader_mc. The problem is, for whatever reason, the damn thing gets caught in an endless loop that continually loads mc_2.swf.
Does anyone have a clue as to why it's doing this?
Here's the code, and I've also attached the entire project.
Code:
loadMovie("mc_1.swf","loader_mc");
_root.stuff = 0;
function callback0(){
clearInterval(intervalID);
loadMovie("mc_2.swf","loader_mc");
_root.stuff = 0;
}
function callback1(){
clearInterval(intervalID);
loadMovie("mc_1.swf","loader_mc");
_root.stuff = 0;
}
box.onEnterFrame = function(){
if(_root.stuff == 100){
intervalID = setInterval(callback0, 1000);
}
if(_root.stuff == 99){
intervalID = setInterval(callback1, 1000);
}
trace(stuff);
}
View Replies !
View Related
Refreshing Function With SetInterval
Hi,
I´ve got problem when resetting function with setInterval. The set interval function adds 1 to variable which I would like to use in further scripting. But when I reset this function it does not reset that variable to start counting from 0. Can anybody look at that script and tell me what I had done wrong. It annoys me and I cannot get through this. I´ll be pleased for any suggestions.
Thanx, Meerah
View Replies !
View Related
Return Function W/ SetInterval
I want to have a function that returns a value...this function will be called by setInterval.
The problem is...the function will return a value. I want to make sure that value goes to the proper variable. How can this be done?
Code:
EX:
function test(someInput){
return (someInput = 'dork');
}
interval_ID = setInterval(test, 10000, someInput);
// let's say i have a variable call "show"
// show should contain the return variable
Now, I tested out to see if I can pass a variable by address or reference to avoid 'return'...but it doesn't work. However, arrays can be used b/c it can be passed by referenced.
For example:
function test (theArray){
theArray[0]='dork';
}
var myArray = new Array();
myArray[0] = 'not a dork';
zeroArray(myArray);
trace (myArray[0]);
If you know how I can accomplish the same concept w/out using arrays, let me know.
thx in advance
View Replies !
View Related
Setinterval-function Functions Just Once
Hi!
I have a movieclip attached to a main movie.
ActionScript Code:
tritypes_btn.onPress=function() {
_root.attachMovie("tritypmove", "tritypmove_mc", 2)
_root.tritypmove_mc._x = 350;
_root.tritypmove_mc._y = 300;
}
The attached movieclip has four frames and the firs three frames have a setinterval-function.
ActionScript Code:
function wait3() {
_parent.gotoAndStop(4);
break;
}
timerHope3 = setInterval(wait3, 6000);
stop();
In the last frame of the movieclip the movieclip unloades with
ActionScript Code:
unloadMovie(tritypmove_mc);
Everything functions alright but when I press the buttone again which attach the movieclip the setintervals-functions on each movieclip does not function. Can someone explain this?
View Replies !
View Related
Kill Function (setInterval)
peepz:
i have this to disable a function for a while but it isn't working:
Code:
on(rollOver){
this.blaat();
}
on(release){
setInterval(blaat, 10000000);
this.blaat2();
}
can someboydy help?
functions (they are for sticky buttons):
Code:
onClipEvent(load){
//set some vars in the this.
this.speedY = 0;
this.speedX = 0;
this.damping = .7;
this.easing = .2;
this.homeX = this._x;
this.homeY = this._y;
//higher is more sticky
this.stickiness=4;
//bounce prototype
this.blaat = function(){
this.onEnterFrame = function(){
//if the mouse is not over the box
if (!this.hitTest(_root._xmouse, _root._ymouse) or this.pressed == true) {
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
} else {
//otherwise, drag me with some friction
difX = this._parent._xmouse-this.homeX;
difY = this._parent._ymouse-this.homeY;
this._x = this._parent._xmouse-(difX/this.stickiness);
this._y = this._parent._ymouse-(difY/this.stickiness);
}
}
}
this.blaat2 = function(){
this.onEnterFrame = function(){
//then bounce me home
this.bounceMe(this.homeX, this.homeY);
this.pressed = false;
}
}
}
View Replies !
View Related
Problem With SetInterval() Function
At the moment i am writing a small swf which uses the function setInterval().Here is the code
Quote:
function connect() {
for (i=0; i<100; i++) {
trace("Hello I am Interval()")
updateAfterEvent();
}
}
setInterval(connect(), 500);
In this code i want to output 100 messages "Hello I am Interval()" and this will loop every 500 (half of a second)... But it seems to be that the function connect() only loop for one time ,stop and do nothing.Did i do something wrong...Please correct me...
View Replies !
View Related
Adding SetInterval To A Function
Hi all,
I was just wondering if anyone could advise me on how to add an interval to this function
seven.onLoad = function(){
mx.transitions.TransitionManager.start(seven, {type:mx.transitions.Wipe, direction:0, duration:2.84, easing:mx.transitions.easing.Bounce.easeOut, startPoint:2, param2:empty});
};
I have tried to add a setInterval to this but it breaks the transition function.
All i want to do is to be able to make the above function wait for x amount of time before it is performed.
Thanks for any help anyone can offer
Jon saul
View Replies !
View Related
Cant Execute Function With SetInterval
ActionScript Code:
_root.logo._alpha = 0; //Sätt alpha på logon till 0_root.meny._alpha = 0; //Sätt alpha på menyn till 0var donealpha:Boolean = false; //skapa en Booleanvar doneshrink:Boolean = false; //skapa en Booleanvar donemove:Boolean = false; //skapa en Booleanvar doneenlarge:Boolean = false; //skapa en Booleanvar logorutashrink:Boolean = false; //skapa en Booleanvar menyalpha:Boolean = false; //skapa en Booleanvar logofadeID;var logoshrinkID;var menyalphaID;var doneenlargeID;var logorutashringID;var logomoveID;function logorutashrink(){ //Funktion för att förminska logorutanif(donealpha == true && doneshrink == true && donemove == true && doneenlarge == true){ //Om allt annat är klart if(_root.logoruta._yscale > 28){ //kolla så att logoruta är störra än 28 _root.logoruta._yscale -= 1; //minska med 1 }else{ //annars logorutashrink = true; //sätt logorutashrink till true clearInterval(logorutashringID); } }}function menyalpha(){ //Funktion för att fada fram menyn if(donealpha == true && doneshrink == true && donemove == true && doneenlarge == true && logorutashrink == true){ //om allt annat är klart if(_root.meny._alpha != 100){ //kolla så att alpha inte är 100 _root.meny._alpha += 1; //öka med 1 }else{ //annars menyalpha = true; //sätt menyalpha till true clearInterval(menyalphaID); } }}function logofade(){ //Funktion för att fada fram loggan if(_root.logo._alpha != 100){ //Kolla så att alpha in redan är 100 _root.logo._alpha += 1; //Om in så öka med 1 }else{ // om den är 100 donealpha = true; //Sätt donealpha booleanen till true clearInterval(logofadeID); }}function logoshrink(){ //Funktion för att minska loggan if(donealpha == true){ //Om logofade är klar så fortsätt if(_root.logo._xscale != 0 && doneshrink == false){ //kolla så att doneshrink är false och att xscale inte är 0 _root.logo._xscale -= 1; //Minska xscale med 1 _root.logo._yscale -= 1; //Minska yscale med 1 }else{ //om xscale är 0 eller doneshrink är true doneshrink = true; //sätt doneshrink till true clearInterval(logoshrinkID); } }}function logomove(){ //Funktion för att flytta loggan till vänstra hörnet if(donealpha == true && doneshrink == true){ //kolla så shrink och alpha på loggan är klara _root.logo._x = 30; //Flytta loggan till X 30 _root.logo._y = 30; //Flytta loggan till Y 30 donemove = true; //Sätt donemove till true clearInterval(logomoveID); }}function logoenlarge(){ //Funktion för att förstora loggan igen //trace(_root.logoruta._yscale); //trace("Alpha: " + donealpha + " Shrink: " + doneshrink + " Move: " + donemove + " Enlarge: " + doneenlarge + " Shrink: " + logorutashrink) if(donealpha == true && doneshrink == true && donemove == true){ //kolla så att dom 3 andra funktionerna är klara if(_root.logo._xscale == 40){ //kolla om xscale är 40 doneenlarge = true; //sätt doneenlarge till true clearInterval(doneenlargeID); }else{ //annars... _root.logo._xscale += 1; //öka xscale med 1 _root.logo._yscale += 1; //öka yscale med 1 } }}logofadeID = setInterval( logofade, 5); //kör logofade var 5:e mslogoshrinkID = setInterval( logoshrink, 8); //kör logoshrink var 8:e msmenyalphaID = setInterval( menyalpha, 5); //kör menyalpha var 5:e msdoneenlargeID = setInterval( logoenlarge, 8); //kör logoenlarge var 8:de mslogorutashringID = setInterval( logorutashrink, 5); //kör logorutashrink var 5:e mslogomoveID = setInterval( logomove, 1000); //kör logomove varje sekund
The first two functions wont get executed.. I have tried to put trace("test") strait under the function ...(){ but it wont execute it..
Any1 who can see the problem?
Best Regards
Latis
View Replies !
View Related
[FMX]setInterval MoveTo Function
I have four buttons on the stage which I want to move 20 pixels up (easing) and fade in from 0 to 100. But I want them to appear with a interval of 1 second. I came up with the following function:
Code:
function showClips(yPos, alpha, speed) {
var endY = yPos - this._y;
this._y += eindY /speed;
var endA = alpha - this._alpha;
this._alpha += endA / speed;
if (clips.length) {
clips[0]._visible = true;
clips.splice(0, 1);
} else {
clearInterval(id);
}
updateAfterEvent();
}
var clips = [];
var index = 0;
while (index++ < 4) {
var clip = eval("but_"+(index < 5 ? "0" : "")+index);
clip._visible = false;
clips.push(clip);
}
var id = setInterval(showClips, 1000, 304, 100, 3);
But it isn't working. The clips just appear on the stage without movement and fading. What is wrong with my function?
View Replies !
View Related
Setinterval For A Loop Function
Code:
_root.leftButton.onRelease = function() {
for(var i=0; i<6; i++){
animateThumbsToLeft(variable_1, variable2);
}
};
ok how and where do i put the setInterval script if i want to execute the "animateThumbsToLeft" function for 6 times and inbetween each time have a delay of say half a second...
i tried alot of ways and i still can't get it to work....
thanks
View Replies !
View Related
Clearing SetInterval From A Different Function
Could someone help me understand how to clear the interval in this code? I'd also like to know if there is a better way of firing makeStars() than using setInterval in a function - like I'm doing. I've looked at the Kirupa tutorial and I'm not seeing what should be done.
Basically, this attaches a number of stars within the Stage width and height properties. When the browser resizes I rewrite the stars to the screen with the new bounds. But I can't get the interval to stop, so the stars just keep getting replaced - disappearing and relocating abruptly.
It all works great outside of the resizeIt() function, but once inside she goes down hill from there. A couple of things I need cleared up (pun intended) are:
1. Am I creating a new interval each time resizeIt() is executed?
2.What is the scope of the interval(s), and does how you access them change depending on where you are in the code, or are they more global?
Thanks,
John
stop();
//number of stars to make
var numstars:Number = 100;
_root.attachMovie("background","bkgd",this.getNext HighestDepth());
var container = _root.createEmptyMovieClip("mycontainer",_root.get NextHighestDepth());
var w:Number = Stage.width;
var h:Number = Stage.height;
_root.mycontainer.lineStyle(1,0xFFFFFF,0);
_root.mycontainer.moveTo(0,0);
_root.mycontainer.lineTo(w,0);
_root.mycontainer.lineTo(w,h);
_root.mycontainer.lineTo(0,h);
_root.mycontainer.lineTo(0,0);
_root.mycontainer.endFill();
var n:Number = 0;
function makeStars():Void{
mycontainer.attachMovie("mcStar", "star"+n, n);
setProperty(mycontainer["star"+n], _y, Math.random() * Stage.height);
setProperty(mycontainer["star"+n], _x, Math.random() * Stage.width);
n++;
if(n == numstars){
//need interval cleared here to stop calling makeStars() from resizeIt() function.
clearInterval(intervalID);
n = 0;
}
}
Stage.align = "TL";
Stage.scaleMode = "noScale";
function resizeIt() {
_root.bkgd._width = Stage.width;
_root.bkgd._height = Stage.height;
_root.bkgd._x = _root.bkgd._width / 2;
_root.bkgd._y = _root.bkgd._height / 2;
bkgd.bwidth.text = Stage.width;
var intervalID:Number = setInterval(makeStars, 100);
}
var stageL:Object = new Object();
stageL.onResize = resizeIt;
Stage.addListener(stageL);
resizeIt();
onEnterFrame = function(){
//Moves stars off of mouse position and screen wraps.
for(var x:Number=0; x<numstars; x++){
setProperty(mycontainer["star"+x], _x, ((Stage.width/2 - _xmouse) * 0.03) + mycontainer["star"+x]._x);
setProperty(mycontainer["star"+x], _y, ((Stage.height/2 - _ymouse) * 0.03) + mycontainer["star"+x]._y);
if(mycontainer["star"+x]._x > Stage.width +25){
mycontainer["star"+x]._x -= Stage.width + 50;
}
else if(mycontainer["star"+x]._x < Stage.width - Stage.width -25){
mycontainer["star"+x]._x += Stage.width + 50;
}
if(mycontainer["star"+x]._y > Stage.height + 25){
mycontainer["star"+x]._y -= Stage.height + 50;
}
else if(mycontainer["star"+x]._y < Stage.height - Stage.height - 25){
mycontainer["star"+x]._y += Stage.height + 50;
}
}
}
View Replies !
View Related
[AS] SetInterval Corrupting Function?
Hi. I've made a function that hides a button, waits 5 seconds and turns it back on. When I run hideBtn(); for the three buttons only the first button works however the traces successfully output:
_level0.menuMC.homeBut
_level0.menuMC.aboutBut
_level0.menuMC.contBut
I'm thinking there is a problem with the setInterval. When I run the clearInterval the first time does it ruin it for the rest of the calls?
I'm sure there is a better way of doing it. Thanks for any help.
function hideBtn(cp) {
var currPath = cp;
currPath._visible = false;
wait = function() {
currPath._visible = true;
clearInterval(evoClr);
}
evoClr = setInterval(wait, 5000);
trace(currPath);
}
hideBtn(this._parent.homeBut);
hideBtn(this._parent.aboutBut);
hideBtn(this._parent.contBut);
View Replies !
View Related
How To Use Setinterval With Function.apply()?
Hi there,
I am using the following code
Code:
motionMC.apply(text_mc,[100,1]);
function motionMC(endX,time) {
var mcTween:Tween = new Tween(this, "_x", Strong.easeOut, this._x, endX, time, true);
};
But I want to control the start time as well with setinterval
I tried
Code:
anime1 = setInterval(text_mc, "motionMC", 1000,[100, 1]);
View Replies !
View Related
HELP With Wait Function SetInterval
FYI: I am really, really new to action script.
I have a movie clip symbol that is place on my main time line. I want the movie clip to display frames for (x) seconds then go to the next frame. I have a chunk of code that works by itself but when placed into my flash site it is causing some strange problems. Such as navigating to a label (page) prior to the movie clip that has the wait function code, freezes the flash. I am wondering if I need _root or a this in there somewhere.
The reason I want to do this is so I don't have to add a bunch of frames to get the pause time I need.
Is there a way to use the code below and not have it cause problems with the rest of my time line?
Here is the wait function code
stop();
i = 1;
function Wait() {
i++;
if (i == 7) {
gotoAndPlay(1);
} else {
nextFrame();
}
// or whatever script you would like...
// clearInterval(WaitInt); // to use the interval only once
}
WaitInt = setInterval(Wait, 5000);
// change to 5000 for 5 sec..
Here is a link where I downloaded the sample code
http://www.kirupa.com/forum/showthread.php?t=90221
Thanks for any help.
View Replies !
View Related
SetInterval On Attachmovie Function With X And Y Loc
HI. I'm new here. I have a function on my script that attaches a movieclip on a specific position and then it duplicates it several times. This movieclip has a code in order to move across the stage randomly. When I try to use SetInterval to repeat this function two weird things happen: the movieclips don't duplicate over that specific location (they appear on x=0,y=0) and if I set the location only one duplicates and the rest don't. My question is: what can I do to repeat the function every 2 seconds exactly as it is the first time it runs, without the objects not duplicating or moving from the original location?
Here's the code:
meteoros = function () {
this.attachMovie("asteroid","asteroid_mc",this.get NextHighestDepth());
asteroid_mc._x = 470;
asteroid_mc._y = 70;
//i++;
while (i<5) {
this.asteroid_mc.duplicateMovieClip("asteroid_mc"+ i,this.getNextHighestDepth());
i++;
}
};
setInterval(this,"meteoros",2000);
View Replies !
View Related
SetInterval Problem, Gives The Same Value Over And Over To Function
LATER EDIT: apparently, I managed to work around it. Anyway, the second setInterval was the one that did not work, and I put instead of:
setInterval(this, "setText", interval, setAcText());
this:
Code:
StratFlash = new setText(setAcText());
setText.prototype.updates = function() {
setText(setAcText())
// setText(setAcText());
};
setInterval(StratFlash, "updates", 4000);
to the second setInterval..
I have the following code that right now SHOULD do the following:
- show a different text every 2 seconds
Code:
// yay, starting..
/* the below setText creates the text to be shown in the flash and uses the parameter theText as the text */
function setText (theText:String):Void {
if(t != null) {t.removeTextField(); }
if(container != null) { container.removeMovieClip(); }
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
container.createTextField("t", this.getNextHighestDepth(), 30, 30, 150, 20);
var tf:TextField = container.t;
tf.text = theText;
}
/* here in function setAcText we declare the texts possible to be shown, and returning one */
var trr = null;
function setAcText():String {
num = Math.round(Math.random()*3);
switch (num) {
case 0:
trr = "New Worlds 0"; break ;
case 1:
trr = "New Worlds 1"; break ;
case 2:
trr = "New Worlds 2"; break ;
case 3:
trr = "New Worlds 3"; break ;
default:
trr = "New Worlds default";
}
return trr;
}
/* here we set an interval for the function to return a text, then an interval for the other function to construct a movieclip with a textfield to show that text */
var interval = 2000;
setInterval(this, "setAcText", interval)
setInterval(this, "setText", interval, setAcText());
stop();
The problem with it:
- the setAcText() returns a text, apparently setText grabs it but then it does this only once
- from my tests I seen that setText actually grabs another text returned from the setAcText, but heh, it still returns something
So, how can I actually make the setText do something, then do something else, then do something else, instead of actually doing the same thing over and over again?
Thank you!
View Replies !
View Related
Cant Execute Function With SetInterval
ActionScript Code:
_root.logo._alpha = 0; //Sätt alpha på logon till 0_root.meny._alpha = 0; //Sätt alpha på menyn till 0var donealpha:Boolean = false; //skapa en Booleanvar doneshrink:Boolean = false; //skapa en Booleanvar donemove:Boolean = false; //skapa en Booleanvar doneenlarge:Boolean = false; //skapa en Booleanvar logorutashrink:Boolean = false; //skapa en Booleanvar menyalpha:Boolean = false; //skapa en Booleanvar logofadeID;var logoshrinkID;var menyalphaID;var doneenlargeID;var logorutashringID;var logomoveID;function logorutashrink(){ //Funktion för att förminska logorutanif(donealpha == true && doneshrink == true && donemove == true && doneenlarge == true){ //Om allt annat är klart if(_root.logoruta._yscale > 28){ //kolla så att logoruta är störra än 28 _root.logoruta._yscale -= 1; //minska med 1 }else{ //annars logorutashrink = true; //sätt logorutashrink till true clearInterval(logorutashringID); } }}function menyalpha(){ //Funktion för att fada fram menyn if(donealpha == true && doneshrink == true && donemove == true && doneenlarge == true && logorutashrink == true){ //om allt annat är klart if(_root.meny._alpha != 100){ //kolla så att alpha inte är 100 _root.meny._alpha += 1; //öka med 1 }else{ //annars menyalpha = true; //sätt menyalpha till true clearInterval(menyalphaID); } }}function logofade(){ //Funktion för att fada fram loggan if(_root.logo._alpha != 100){ //Kolla så att alpha in redan är 100 _root.logo._alpha += 1; //Om in så öka med 1 }else{ // om den är 100 donealpha = true; //Sätt donealpha booleanen till true clearInterval(logofadeID); }}function logoshrink(){ //Funktion för att minska loggan if(donealpha == true){ //Om logofade är klar så fortsätt if(_root.logo._xscale != 0 && doneshrink == false){ //kolla så att doneshrink är false och att xscale inte är 0 _root.logo._xscale -= 1; //Minska xscale med 1 _root.logo._yscale -= 1; //Minska yscale med 1 }else{ //om xscale är 0 eller doneshrink är true doneshrink = true; //sätt doneshrink till true clearInterval(logoshrinkID); } }}function logomove(){ //Funktion för att flytta loggan till vänstra hörnet if(donealpha == true && doneshrink == true){ //kolla så shrink och alpha på loggan är klara _root.logo._x = 30; //Flytta loggan till X 30 _root.logo._y = 30; //Flytta loggan till Y 30 donemove = true; //Sätt donemove till true clearInterval(logomoveID); }}function logoenlarge(){ //Funktion för att förstora loggan igen //trace(_root.logoruta._yscale); //trace("Alpha: " + donealpha + " Shrink: " + doneshrink + " Move: " + donemove + " Enlarge: " + doneenlarge + " Shrink: " + logorutashrink) if(donealpha == true && doneshrink == true && donemove == true){ //kolla så att dom 3 andra funktionerna är klara if(_root.logo._xscale == 40){ //kolla om xscale är 40 doneenlarge = true; //sätt doneenlarge till true clearInterval(doneenlargeID); }else{ //annars... _root.logo._xscale += 1; //öka xscale med 1 _root.logo._yscale += 1; //öka yscale med 1 } }}logofadeID = setInterval( logofade, 5); //kör logofade var 5:e mslogoshrinkID = setInterval( logoshrink, 8); //kör logoshrink var 8:e msmenyalphaID = setInterval( menyalpha, 5); //kör menyalpha var 5:e msdoneenlargeID = setInterval( logoenlarge, 8); //kör logoenlarge var 8:de mslogorutashringID = setInterval( logorutashrink, 5); //kör logorutashrink var 5:e mslogomoveID = setInterval( logomove, 1000); //kör logomove varje sekund
The first two functions wont get executed.. I have tried to put trace("test") strait under the function ...(){ but it wont execute it..
Any1 who can see the problem?
Best Regards
Latis
View Replies !
View Related
[FMX]setInterval MoveTo Function
I have four buttons on the stage which I want to move 20 pixels up (easing) and fade in from 0 to 100. But I want them to appear with a interval of 1 second. I came up with the following function:
Code:
function showClips(yPos, alpha, speed) {
var endY = yPos - this._y;
this._y += eindY /speed;
var endA = alpha - this._alpha;
this._alpha += endA / speed;
if (clips.length) {
clips[0]._visible = true;
clips.splice(0, 1);
} else {
clearInterval(id);
}
updateAfterEvent();
}
var clips = [];
var index = 0;
while (index++ < 4) {
var clip = eval("but_"+(index < 5 ? "0" : "")+index);
clip._visible = false;
clips.push(clip);
}
var id = setInterval(showClips, 1000, 304, 100, 3);
But it isn't working. The clips just appear on the stage without movement and fading. What is wrong with my function?
View Replies !
View Related
SetInterval To Return A Value From A Function?
Got a little problem here guys... the story goes like this:
ActionScript Code:
function foo() {
function setValue() {
value = "ok";
}
return value
}
The problem here in my case is that the function setValue takes a couple of milliseconds to set the value variable. And when executing foo it returns undefined instead of "ok".
no problem, i'll just have foo return value with a setInterval:
ActionScript Code:
function foo() {
function setValue() {
value = "ok";
}
function checkIfSet() {
if (value) {
return value
}
}
setInterval(checkIfSet, 100);
}
...Ofcourse this doesnt work. Flash complains that there is no return value for the function foo.
What i'd need is fooScope.return value, if you catch my drift, but thats wishful coding
Can anyone help me out?
Thanks
View Replies !
View Related
Refreshing Function With SetInterval
Last edited by bambi : 2004-05-17 at 00:45.
Hi,
I´ve got problem when resetting function with setInterval. The set interval function adds 1 to variable which I would like to use in further scripting. But when I reset this function it does not reset that variable to start counting from 0. Can anybody look at that script and tell me what I had done wrong. It annoys me and I cannot get through this. I´ll be pleased for any suggestions.
Thanx, Meerah
Here is it:
ActionScript Code:
_global.alphafade = function() {
k = 0;
_global.fak = setInterval(function () {
if (k>13) {
clearInterval(fak);
k = 0;
trace("k="+k);
} else {
k=k+1
go();
trace("k="+k);
}
}, 500);
};
_global.go = function() {
kterej = _root["order"+k];
alphaFad(kterej);
};
_global.alphaFad = function(kterej) {
k = setInterval(initialize, 200, kterej);
};
_global.initialize = function(kterej) {
if (_root["alpha"+kterej]>90) {
clearInterval(k);
} else {
_root["alpha"+kterej] += 5;
}
};
on (release) {
for (j=0; j<15; j++) {
_root["alpha"+j] = 0;
}
_root.order1 = Number(1);
_root.order2 = Number(2);
_root.order3 = Number(3);
_root.order4 = Number(4);
_root.order5 = Number(5);
_root.order6 = Number(6);
clearInterval(fak);
alphafade();
}
View Replies !
View Related
SetInterval & Calling Function
Allright,
I call a function at each 10 milisecond using set interval. I have a problem calling function with set interval.
here is my code
xData="Yes";
xJack = setInterval( xJackDuff , 10, xData);
function xJackDuff(xData){
this["xS"+xData](); // Call the proper function.
// xSYes();
}
function xSYes(){
Trace("Now, i am calling the Yes function");
}
function xSNo(){
Trace("Now, i am calling the NO function");
}
My problem is the following piece of code:
this["xS"+xData]();
It works fine when i do not use setInterval, but when i do, it doesn't work.
Anyone have a clue why, is it because the setInterval is calling the function to fast, and it does'nt have time to render the code ?
View Replies !
View Related
SetInterval Will Not Initiate Function
I am trying to attach a movie to the stage and then animate it across stage.
but the interval is not calling the function every 2 seconds. I did a test and initiated the function with a button and everything works fine.
Code:
var speed:Number = 5;
var num:Number = 0;
var nInterval:Number = setInterval(loadSquare, 2000);
function loadSquare():Void {
trace("test");
var t:MovieClip = this.attachMovie("shape1", "shape"+num++, this.getNextHighestDepth());
t.gotoAndStop(Math.round(Math.random()*4));
t._x = Stage.width-50;
t._y = Math.random()*Stage.height+10;
t.onEnterFrame = mover;
}
function mover():Void {
this._x -= speed;
if (this._x<=0) {
this.removeMovieClip();
}
}
hope some one can help. Thank you all in advance.
View Replies !
View Related
Help W/ Escape From SetInterval Function...
title doesn't really explain it, i don't think, but...
oh, btw; hi, first post and all. i'm somewhat a beginner, so bear with me, pls.
i am using setInterval inside a function that calls an animation function, and calling the one with setInterval in it when an .mp3 loads - ie: plays. The effect is a db meter that bounces happily when i play the song.
my question is this: i want to stop the animation when the song stops. Currently i am calling a function with the stop button that feeds zeros to the animation, because i really don't know how to stop the original one - somehow missed that lesson . My problem is that it seems the two functions are fighting eachother. It works, but some of the control from the first function get through, so the db meter jumps occasionally. So (long post... sorry, i'm not good at explaining this stuff - i'll get better ) i want to stop the first animation function rather than start another one.
any suggestions?
PS: i really don't want to use frame actions for this. I know... call me stubborn.
thanx for any help you can give.
View Replies !
View Related
Strange Act Of 'onMouseUp'
Hi all,
When I create my own class extending the MovieClip class,
I used the 'onMouseUp' method to invoke some behaviour of my class.
When finished my own MovieClip class I attached a some couple of
instances to the _root. On testing something seemed to go wrong.
As soon as I released my mousebutton on an instance, all the other instances where affected too.
So I debugged my class by some tracing actions and found out that
the method 'onMouseUp' returned each of the instances, not the only one I released my mouse on. The method looked like this:
Code:
function onMouseUp() : Void
{
trace( this );
}
I started thinking and thought of the following reason:
1. All instances where attched to _root ( a _parent MovieClip )
2. Other methods like 'onRelease' only returned the right instance
Conclusion: onMouseUp is invoked if the mouse goes up a
MovieClip and executes its code equal to the number of instances
attached to it, because the mouse is going up on these instances too!
View Replies !
View Related
|