If Statement & SetInterval Wont Work?
hey out there,
i've a real simple battery level monitor that's fictitiously sets a level indicator.
there's a function that's called using setInterval:
Code:
stop();
batLevelNo=100;
batLevel="(100%)";
function setBatLevel() {
batLevelNo = batLevelNo-20;
batLevel = "("+batLevelNo+"%)"
bar._x = bar._x-5;
}
if (batLevelNo > 0){
setInterval(setBatLevel, 500);
}
the thing is, i want to stop calling the function when the batLevelNo gets to 0 - but the:
Code:
if (batLevelNo > 0){
setInterval(setBatLevel, 500);
}
doesn't work, it just keeps going.
i have a feeling this is something obvious and i'm being a spoon, does anyone have any suggestions?!
many thanks,
jake
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 04-08-2005, 08:29 AM
View Complete Forum Thread with Replies
Sponsored Links:
If Statement & SetInterval Wont Work?
hey out there,
i've a real simple battery level monitor that's fictitiously sets a level indicator.
there's a function that's called using setInterval:
Code:
stop();
batLevelNo=100;
batLevel="(100%)";
function setBatLevel() {
batLevelNo = batLevelNo-20;
batLevel = "("+batLevelNo+"%)"
bar._x = bar._x-5;
}
if (batLevelNo > 0){
setInterval(setBatLevel, 500);
}
the thing is, i want to stop calling the function when the batLevelNo gets to 0 - but the:
Code:
if (batLevelNo > 0){
setInterval(setBatLevel, 500);
}
doesn't work, it just keeps going.
i have a feeling this is something obvious and i'm being a spoon, does anyone have any suggestions?!
many thanks,
jake
View Replies !
View Related
SetInterval With Switch Statement Not Working
Hey...please i need some help...
Ok...on the code, everything works fine except the switch statement...
when counterLogo reaches to 2, nothing happens... the counter is actually working and adding by one with the setInterval but the switch statement is not recognizing the counterLogo sum.
Code:
counterLogo = 0;
//Start Loading Pictures
mcNorthAmerica.onRelease = function() {
function countLogo() {
counterLogo++;
trace(counterLogo);
}
count = setInterval(countLogo, 1000);
switch (counterLogo) {
case 2 :
startLoading("Logos/accenture.png");
trace("works");
break;
}
};
View Replies !
View Related
SetInterval With Switch Statement Not Working
Hey...this is a begginer question but please i need some help...
Ok...on the code, everything works fine except the switch statement...
when counterLogo reaches to 2, nothing happens... the counter is actually working and adding by one with the setInterval but the switch statement is not recognizing the counterLogo sum.
Attach Code
counterLogo = 0;
//Start Loading Pictures
mcNorthAmerica.onRelease = function() {
function countLogo() {
counterLogo++;
trace(counterLogo);
}
count = setInterval(countLogo, 1000);
switch (counterLogo) {
case 2 :
startLoading("Logos/accenture.png");
trace("works");
break;
}
};
View Replies !
View Related
Putting SetInterval In If Statement Stops It From Working?
Hey i have a movieClipLoader that loads a jpg into a empty movie clip created in AS. I want to have the picture appear after one second the first time the function is called while other things on the stage disappear, but after the first time this one second delay shouldn't appear.
I decided to use a setInterval to get the one second delay, and this works when i dont make it only work on the first photo loaded, but as soon as i put it within an if statement the other things in the if statement work but the interval doesnt work.
This is the code that works, but has a delay on every image that is loaded:
ActionScript Code:
function loadBigPicture(iValue:Number, firstTime:String):Void {
this.createEmptyMovieClip("myBigPicture"+iValue, this.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadProgress = function(target, bytes_loaded, bytes_total) {
var myLoaded = Math.floor(100*(bytes_loaded/bytes_total));
trace(iValue+" has loaded: "+myLoaded);
};
tlistener.onLoadInit = function(target_mc):Void {
target_mc._x = centerOfImageX-target_mc._width/2;
target_mc._y = centerOfImageY-target_mc._height/2;
target_mc._alpha = 0;
var mypic = setInterval(brightenBigPic, 1000);
function brightenBigPic() {
target_mc._alpha = 100;
clearInterval(mypic);
}
};
bigimage_mcl = new MovieClipLoader();
bigimage_mcl.addListener(tlistener);
bigimage_mcl.loadClip(imglocation[iValue], _level0["myBigPicture"+iValue]);
}
And the code that doesnt make the first image ever show up, but when the function is called again it works fine:
ActionScript Code:
function loadBigPicture(iValue:Number, firstTime:String):Void {
this.createEmptyMovieClip("myBigPicture"+iValue, this.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadProgress = function(target, bytes_loaded, bytes_total) {
var myLoaded = Math.floor(100*(bytes_loaded/bytes_total));
trace(iValue+" has loaded: "+myLoaded);
};
tlistener.onLoadInit = function(target_mc):Void {
target_mc._x = centerOfImageX-target_mc._width/2;
target_mc._y = centerOfImageY-target_mc._height/2;
target_mc._alpha = 0;
if (firstTime == "yes") {
trace("firstTime");
var mypic = setInterval(brightenBigPic, 1000);
function brightenBigPic() {
target_mc._alpha = 100;
clearInterval(mypic);
}
} else {
target_mc._alpha = 100;
}
};
bigimage_mcl = new MovieClipLoader();
bigimage_mcl.addListener(tlistener);
bigimage_mcl.loadClip(imglocation[iValue], _level0["myBigPicture"+iValue]);
}
Any ideas on why the interval doesnt work when its put inside the if statement, on the 2nd, firstTime traces but the interval doesnt work.
View Replies !
View Related
Putting SetInterval In If Statement Stops It From Working?
Hey i have a movieClipLoader that loads a jpg into a empty movie clip created in AS. I want to have the picture appear after one second the first time the function is called while other things on the stage disappear, but after the first time this one second delay shouldn't appear.
I decided to use a setInterval to get the one second delay, and this works when i dont make it only work on the first photo loaded, but as soon as i put it within an if statement the other things in the if statement work but the interval doesnt work.
This is the code that works, but has a delay on every image that is loaded:
function loadBigPicture(iValue:Number, firstTime:String):Void {
this.createEmptyMovieClip("myBigPicture"+iValue, this.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadProgress = function(target, bytes_loaded, bytes_total) {
var myLoaded = Math.floor(100*(bytes_loaded/bytes_total));
trace(iValue+" has loaded: "+myLoaded);
};
tlistener.onLoadInit = function(target_mc):Void {
target_mc._x = centerOfImageX-target_mc._width/2;
target_mc._y = centerOfImageY-target_mc._height/2;
target_mc._alpha = 0;
var mypic = setInterval(brightenBigPic, 1000);
function brightenBigPic() {
target_mc._alpha = 100;
clearInterval(mypic);
}
};
bigimage_mcl = new MovieClipLoader();
bigimage_mcl.addListener(tlistener);
bigimage_mcl.loadClip(imglocation[iValue], _level0["myBigPicture"+iValue]);
}
And the code that doesnt make the first image ever show up, but when the function is called again it works fine:
function loadBigPicture(iValue:Number, firstTime:String):Void {
this.createEmptyMovieClip("myBigPicture"+iValue, this.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadProgress = function(target, bytes_loaded, bytes_total) {
var myLoaded = Math.floor(100*(bytes_loaded/bytes_total));
trace(iValue+" has loaded: "+myLoaded);
};
tlistener.onLoadInit = function(target_mc):Void {
target_mc._x = centerOfImageX-target_mc._width/2;
target_mc._y = centerOfImageY-target_mc._height/2;
target_mc._alpha = 0;
if (firstTime == "yes") {
trace("firstTime");
var mypic = setInterval(brightenBigPic, 1000);
function brightenBigPic() {
target_mc._alpha = 100;
clearInterval(mypic);
}
} else {
target_mc._alpha = 100;
}
};
bigimage_mcl = new MovieClipLoader();
bigimage_mcl.addListener(tlistener);
bigimage_mcl.loadClip(imglocation[iValue], _level0["myBigPicture"+iValue]);
}
Any ideas on why the interval doesnt work when its put inside the if statement, on the 2nd, firstTime traces but the interval doesnt work.
View Replies !
View Related
Why SetInterval Won't Work?
I just want to build a menu that will fade out gradually when mouse roll out, but I tried so many ways and got no result. And finally I decided to use setInterval to control the alpha of the menu, but it still won't work! Anyone could help me with the following script? And easier way to do a fading out menu is also welcomed, thank you!!
-------------------------------------
startslide = false;
menuhide = false;
stop();
function menuhide() {
//the menu background slide away
while (_root.button_black._x>50) {
_root.button_black._x -= 10;
}
//the menu fade out gradually
while (_root.menu._alpha>0) {
_root.menu._alpha -= 10;
}
trace(_root.button_black._x);
}
_root.onEnterFrame = function() {
if (_root._xmouse>250) {
//when mouse roll out from the menu, menu begins to fade out
startslide = true;
}
if (startslide) {
setInterval(menuhide, 300);
//setInterval won't work (
}
};
View Replies !
View Related
SetInterval Won't Work
Hi all
I have the following AS for a title sequence.
code:
this.finalX = 330;
{
this._alpha = 0
this.onEnterFrame = function ()
{
if (this._alpha < 100)
{
this._alpha += 3;
}
};
};
slipery.onEnterFrame = function ()
{
this._x += 3;
if (this._x > finalX)
{
this._x = finalX;
ertigo.onEnterFrame = function (){
this._alpha +=3;
if (this._alpha < 100)
{
this._alpha +100;
}
};
};
};
Everything works fine except that I want to insert a setInterval into the script so that it pauses for x seconds after:
code: this.finalX = 330;
{
this._alpha = 0
this.onEnterFrame = function ()
{
if (this._alpha < 100)
{
this._alpha += 3;
}
};
};
Have looked up reference books and tutorials but can't seem to get setInterval to work. When I do insert something like: code: setInterval (Slipery,5000) it just negates the first fade in effect.
Any clues what I'm doing wrong?
View Replies !
View Related
I Cant Get SetInterval To Work :(
Hi all, im having problems with setInterval. it does not work for me.
I have a button that changes frames and that calls a global function that
formats the content on the page. Problem is i need to delay it a bit because the code that gets the page size is currently getting the PREVIOUS pages metrics. So a delay of about 1/2 a second should provide enough time to load the new frame and then run the format code.
However this code does not work:
The next button:
ActionScript Code:
cnt.nextFrame();
tID = setInterval(format(),250);
then in the format function I have
ActionScript Code:
clearInterval(tID);
//rest of my code to format
I tested it with a 10 second delay, and made an output text box say "page turning" when i turn the page, then in the format function it adds on to that text box "formatted"; However its running immediately, as soon as i click the page i get "page turning formatted" instead of formatted being shot there 10 seconds after.
Am i writing the setInterval function wrong? I read about it in help and it appears there are 3 variations of how you can write it, but the other ones seem to be for methods of objects, whereas i am just calling a global function on the _root timeline!
Anyways, any help would be appreciated. Or maybe an example of a working setInterval function!
Thanks
MCM
View Replies !
View Related
SetInterval Won't Work
I can't get setInterval to work in this menu system I am creating. The function will execute immediately and not delay like I want it to. Can you tell me what's up.
ActionScript Code:
stop();import mx.transitions.Tween;import mx.transitions.easing.*;/////////////////////////Button Functions/////////////////////////function menuclose(item, beg, end) { var butclose:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskclose:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, -225, .3, true);};function menuopen(item, beg, end) { var butopen:Tween = new Tween(item, "_y", Strong.easeOut, beg, end, .3, true); var maskopen:Tween = new Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, end, .3, true);};function butup() { var butin:Tween = new Tween(b1, "_alpha", Strong.easeOut, 0, 12, .5, true);};function butdown() { var butin:Tween = new Tween(b1, "_alpha", Strong.easeOut, 12, 0, .5, true);};///////////////////////Button Actions///////////////////////b1.onRollOver = function() { butup(b1); menuopen(d1, -219, -69);};b1.onRollOut = function() { butdown(); dropup = setInterval(menuclose(d1, -69, -219), 500);};
View Replies !
View Related
Second SetInterval Won't Work
Hi All,
I have a movie clip containing two setIntervals on its timeline, but the second setInterval won't work. I've uploaded the .fla if someone wouldn't mind taking a look? The movie clip is on the layer called text5.
Would really appreciate any advice.
Thanks
View Replies !
View Related
As2 Oop - Can't Get SetInterval To Work
hello all, i am stuck here
i am trying to trigger a function after a certain delay, which is why i used setInterval.
i can get the function to happen after a certain time, but clearInterval doesnt seem to work
it always worked before, when i was not writing it in oop, is there something special with this function when it's used in oop?
in the Delay.as file:
Code:
class Delay extends MovieClip {
//
///////////////
// variables //
///////////////
//
var delay:Number;
private var countdown:Number;
//
/////////////////
// constructor //
/////////////////
//
function Delay () {
}
//
///////////////////////////
// functions definitions //
///////////////////////////
//
function init (x:Number, y:Number) {
this._x = x;
this._y = y;
}
function onRelease () {
traceStuff ();
}
//
function traceStuff () {
this.countdown = setInterval (delayedtraceStuff, 2500);
}
function delayedtraceStuff () {
this.delay--;
if (delay <= 0) {
trace ("stuff");
clearInterval (this.countdown);
}
}
//
}
on test_delay.fla stage:
Code:
this.attachMovie ("square_inLib", "square", this.getNextHighestDepth ()).init (64, 64);
quite appreciated if someone could explain what im doing wrong
see attached files if need be.
View Replies !
View Related
Does SetInterval Actually Work?
Ok ive taken my previous post and am just focusing on the setInterval
Why does this example not work???
var numberOfTimes:Number = 0;
var checkInterval:Number = 0;
this.clearInterval(checkInterval);
this.checkInterval = setInterval(watchMyInterval, 100);
function watchMyInterval()
{ trace(numberOfTimes); if (numberOfTimes == 5)
{ this.clearInterval(checkInterval);
trace("this.clearInterval(checkInterval);");
}
numberOfTimes++;
}
View Replies !
View Related
Why Won't This If Statement Work? Oh Poo.
All it does is go straight to the frame label "drone_end" even if the _root.gunmodel = 1, it does this with other examples too i've always wondered why...
------------------------------------
on (release) {
if (_root.gunmodel = 2) {
gotoAndPlay ("drone_end");
} else {
tellTarget ("bullet_mark") {
nextFrame ();
}
gotoAndStop ("drone_damage1");
}
}
-----------------------------------
If (help = yes)
message = "Thanks for your help its extremely appriciated"
} else {
message = "thanks for your time anyway, cheers!"
}
}
err... i got bored of doing the usual thanks for your help thing...
Cheers Jim
View Replies !
View Related
If Statement Does Not Work...
hello hello,
i have this most basic problem, but i just cannot solve it:
i have 2 MC and one button. in the each MCs i have a tween which causes the the MC to move to the left and fade out, in the 1. frame stop();
now when i press the button, i want the the first MC to got to frame 2 (paly the tween). once the alpha of this MC has reached 20, i wnat the 2nd mc to do the same.
i tried the following code:
on(release){
_root.MC1.gotoANdPlay(2);
if(_root.MC2._alpha >= 20){
_root.MC2.gotoAndPlay(2);
}
}
but the if statement is compleatly not regarded. on release both movclips go play the tween.
what am i doing wrong...
View Replies !
View Related
My If Else If Statement Does Not Work
I have a variable set in memmory. The variable is cont. I can't get this code to work. It seems like the if, else if statement just doesn't work.
on (release) {
if (cont <> "precision.swf") {
trace ("****ingequal");
tellTarget ("/content") {
cont = "precision.swf";
gotoAndPlay (13);
}
} else if (cont = "precision.swf") {
trace ("else");
tellTarget ("/content") {
gotoAndPlay (12);
}
}
}
View Replies !
View Related
Why Won't My If/else Statement Work?
I am trying to find way in flash 4 to check to see which movie is loaded to tell me which movie to load next.
the only problem is that when it's actually working, it only will load the first movie, in other words, no matter which movie it detects, it still loads capprc.swf
On (Release)
If (GetProperty_url=pronpp.swf)
Load Movie ("capprc.swf", 1)
Else If (GetProperty_url=portpp.swf)
Load Movie ("cappoc.swf", 1)
Else If (GetProperty_url=portcp.swf)
Load Movie ("cappoc.swf", 1)
Else If (GetProperty_url=procp.swf)
Load Movie ("capprc.swf", 1)
End If
End On
the only problem is that when it's actually working, it only will load the first movie, in other words, no matter which movie it detects, it still loads capprc.swf
how do I fix this, also how do i get it not to reload the movie if it is already loaded... something like...
Else If (GetProperty_url=capprc.swf)
do not relaod
View Replies !
View Related
Why Does This If Statement Not Work?
on the "submit" button for a input text field:
on (release) {
if (!email.length || email.indexOf("@") == -1 || email.indexOf(".")) {
action = "subscribe";
adress = "email";
getURL("http://www.mediasportsgroup.com/cgi-bin/subscribe_gm.cgi", "_blank", "POST");
gotoAndStop(105);
} else {
gotoAndStop(104);
}
}
point is that it wont send the variables unless there's a valid e-mail entered in email (the inout text field)
so why doensnät it work??? thanks!
View Replies !
View Related
If Else Statement Won't Work
I'm using this code to turn my content sections _visible, my traces are firing BUT, the sections are not working :
Code:
//functions for navigation buttons
button01.onRelease = function() {
section = "01";
trace("i am in section "+section);
};
button02.onRelease = function() {
section = "02";
trace("i am in section "+section);
};
button03.onRelease = function() {
section = "03";
trace("i am in section "+section);
};
button04.onRelease = function() {
section = "04";
trace("i am in section "+section);
};
// functions for loading content
if (section == "01") {
_root.content01._visible = true;
} else if (_global.section == "02") {
_root.content02._visible = true;
} else if (_global.section == "03") {
_root.content03._visible = true;
} else if (_global.section == "04") {
_root.content04._visible = true;
}
View Replies !
View Related
Cannot Get The If/else Statement To Work
Hello all,
I am trying to load variables from php. They come into the movie ok when I put them in a dynamic text field, but I cannot get the gotoAndPlay parts in the if/else statements to work correctly. It is always going to frame 26. Any ideas on what I might be doing wrong?
myVars = new LoadVars();
myVars.load("http://www.myURL.com");
myVars.onLoad = function(){
myNewVariable = myVars.myVariable;
if (myNewVariable == "second"){
gotoAndPlay(2);
}else{
gotoAndPlay(26);
}}
Thanks in advance,
flashywhiteink
View Replies !
View Related
Can't Get IF Statement To Work...
Aight, I need to make it so when you click on a button, the code checks if there is sertain text in Text1, if there is, then put "yes" in Text2.
I got this:
Code:
on (click) {
if (text1 = "1234") {
text2 = "Yes";
}
}
I also tryed:
Code:
on (click) {
if (text1var = "1234") {
text2var = "Yes";
}
}
There is no syntax errors, but when I hit the button, nothing happens.
What's the problem.
View Replies !
View Related
Getting Else Statement To Work
hi there,
I'm trying to get the sound to stop when the user has asked for muted sound, on each scene though I have different sound files. I've tried all types of different codes on my buttons and nothing seems to work. This was where I was last at:
on (release) {
if (this.sound_on1.sound_on._visible=1) {
trace(this.sound_on1.sound_on._visible)
this.sound_on1.sound_on._visible=1;
this.sound_off1.sound_off._visible=0;
gotoAndPlay("summary",1);
_root.bgSound.stop();
} else {
this.sound_on1.sound_on._visible=0;
this.sound_off1.sound_off._visible=1;
trace(this.sound_on1.sound_on._visible)
gotoAndPlay(2);
_root.bgSound.stop();
}
}
if anyone can help, it would be greatly appreciated. I'm pulling my hair out!
View Replies !
View Related
SetInterval Won't Work With 'Next' Button
I've made a slideshow which will change pictures every 15 seconds, but I also want the option of being able to click a 'next' button if the user doesn't want to wait 15 seconds and display the next picture themselves, and then the timer should start from 15 seconds again. The timer works fine, until the next button is used, this is whats on the button:
Code:
on (release) {
nextFrame();
}
When the next button is used the timer messes up, it's no longer 15 seconds, sometimes its 8secs, sometimes its 1sec! I have no idea why this happening. Here is the code for the timer:
Code:
var intID = setInterval(function () {
_root.nextFrame();
clearInterval(intID);
}, 15000);
I have put that in every frame of the movie, I figured by using the clearInterval on every frame, when the next frame played it would start a new setInterval of 15seconds, but this is not the case.
I'd appreciate any help.
Thanks.
View Replies !
View Related
Setinterval Doesn't Work
To test setinterval I've got 4 frames with a simple 1 to 4 drawn into it. It is supposed to go from 1 to 4 every second and then go back to 1 again.
In frame 1 I'v got this code:
Code:
stop();
setInterval(function () {
nextFrame();
}, 1000);
On the last frame I've got this code so that it goes back to 1 and the process repeats itself:
Code:
clearInterval()
gotoAndPlay(1);
But it doesn't work: flash gets confused with the timing. The first 2 seconds it goes: 1 2 3 4 1 2 3 4, but then it gets out of sync and starts skipping frames: 1 3 4 1 3 4 1 1 and other combinations.
What is causing this?
View Replies !
View Related
SetInterval In Loaded Swf Does Not Work
Hi folks, I am loading a *.swf into an mc instance via loadMovie().
main movie:
ActionScript Code:
function openMovie(whichmc) {
loadMovie("myMovie.swf", _root.contentbox1);}
I use a setInterval function in some button script in "myMovie.swf" that does not work when loaded into the _root.contentbox1. (thanks CyanBlue for the diagnosis )
external swf:
ActionScript Code:
this.topbutton.onRelease = function() {
clearInterval(scroller);
quickie();}
function quickie() {
scroller = setInterval(moveHome, 5);
}
Any obvious reasons why?
Thanks,
Cheez
*link to original thread http://www.actionscripts.org/forums/...threadid=22307
View Replies !
View Related
SetInterval ClearInterval Does Not Work
My clearInterval is not working. I have a nested for loop that calls out a setInterval to display tiles of an image at random times. The animation works but the clearInterval is never fired so i get an infinite loop. Any ideas on how to target the variable intervalId in the code to clear it? Thanks,
Attach Code
import flash.display.BitmapData;
import flash.geom.Matrix;
//padding
var pad:Number = 0;
var blockSize:Number = 10;
var m:Matrix = new Matrix();
var dep:Number = 30;
var intervalId:Number;
// # of squares to run
var maxCount:Number = 304;
var count:Number =0;
var duration:Number = 200;
function executeCallback(clip:MovieClip):Void {
trace("executeCallback intervalId: " + intervalId + " count: " + count);
clip._alpha = 100;
if (count >= maxCount) {
clearInterval(intervalId);
trace("cleared interval ");
}
count ++;
}
for (var i = 0; i<box._height/blockSize; i++) {
for (var j = 0; j<=box._width/blockSize; j++) {
bmp = new BitmapData(blockSize, blockSize, true, 0x00CCCCCC);
mc = _root.createEmptyMovieClip("mc_"+j+"_"+i, dep++);
m.tx = -j*blockSize;
m.ty = -i*blockSize;
bmp.draw(box,m);
mc.attachBitmap(bmp,dep++);
mc._x = j*(blockSize+pad);
mc._y = i*(blockSize+pad);
mc._x += box._x;
mc._y += box._y+box._height+pad;
mc._alpha = 0;
duration = Math.random()*2000;
intervalId = setInterval(this, "executeCallback", duration, mc);
}
}
stop();
View Replies !
View Related
SetInterval ClearInterval Does Not Work
My clearInterval is not working. I have a nested for loop that calls out a setInterval to display tiles of an image at random times. The animation works but the clearInterval is never fired so i get an infinite loop. Any ideas on how to target the variable intervalId in the code to clear it? Thanks,
Attach Code
import flash.display.BitmapData;
import flash.geom.Matrix;
//padding
var pad:Number = 0;
var blockSize:Number = 10;
var m:Matrix = new Matrix();
var dep:Number = 30;
var intervalId:Number;
// # of squares to run
var maxCount:Number = 304;
var count:Number =0;
var duration:Number = 200;
function executeCallback(clip:MovieClip):Void {
trace("executeCallback intervalId: " + intervalId + " count: " + count);
clip._alpha = 100;
if (count >= maxCount) {
clearInterval(intervalId);
trace("cleared interval ");
}
count ++;
}
for (var i = 0; i<box._height/blockSize; i++) {
for (var j = 0; j<=box._width/blockSize; j++) {
bmp = new BitmapData(blockSize, blockSize, true, 0x00CCCCCC);
mc = _root.createEmptyMovieClip("mc_"+j+"_"+i, dep++);
m.tx = -j*blockSize;
m.ty = -i*blockSize;
bmp.draw(box,m);
mc.attachBitmap(bmp,dep++);
mc._x = j*(blockSize+pad);
mc._y = i*(blockSize+pad);
mc._x += box._x;
mc._y += box._y+box._height+pad;
mc._alpha = 0;
duration = Math.random()*2000;
intervalId = setInterval(this, "executeCallback", duration, mc);
}
}
stop();
View Replies !
View Related
Why Does This Not Work? SetInterval Prob
Hello all,
PHP Code:
var myInterval = setInterval(playText, 6000);
var p:Number = 0;
pause_btn.addEventListener(MouseEvent.MOUSE_UP,
function(evt:MouseEvent) {
if(p==0){
clearInterval(myInterval);
p++;
trace('puase p='+p);
}else{
setInterval(playText, 6000);
p--;
trace('running p='+p);
}
}
);
for some reason this code traces properly but only works the first time I pause and then resume - but after that it wont pause again??
What is wrong with this??
Thanks
View Replies !
View Related
If Statement Won't Work/Flash MX
HI!
I'll lay out what I want to happen and show you guys what I've done (its not working).
When I click on the places mc instance, I want it to check to see if the mc nature is at frame 6. If it is, I want the places mc to play frame 2. If the nature mc isn't at frame 6, I want the places mc to play frame 2 as well as play frame 2 of the nature mc. Does this make sense? Here is what I"ve come up with. I've tried a few variations of this but nothing is working.
This script is located on a button instance within the places mc.
on(release){
if(_root.nature(6);
gotoAndPlay(2);
}else{
_root.nature.gotoAndPlay(2);
gotoAndPlay(2);
*both movie clips are on the main timeline.
View Replies !
View Related
Why Mi If Statement Doesn't Work?
Hi everybody!
I have a mc called "mcRevistasAnimacion" located at the root of my flash file. Inside "mcRevistasAnimacion" in a frame layer I have this code:
code:
if (gMiNombre == "Nada")
{
stop();
}
else
{
play();
}
The variable is adopting the right values because another movie reacts with these values. What am I doing wrong?
View Replies !
View Related
Simple If/else Statement Don't Work
I've made this simple script as my first encounter with ActionScript. However, the if statement outputs same data everytime, even if the answer is correct. Not very dynamic.
TheAnswer outputs the "fraga" variable correctly, so it cannot be a variable issue?
here's my code:
fraga = inputAnswer
if (fraga== "diskmaskin") {
svar = "rätt." ;
} else {
svar = "fel." ;
}
theAnswer = "Ditt svar " + fraga + " är " + svar
View Replies !
View Related
Help Getting Timer Based On SetInterval To Work
I'm building out the basic code for a timer that does 2 things:
Counts down "bonus points" -- 10th of the total milliseconds in the timer
Count down seconds and tenths of seconds
The bonus points will tick down along with the time -- this is part of a larger quiz interactive project that I'm putting together.
I can't quite figure out the following (my math is bad, I think):
Why can't the setInterval fire off in 1 millisecond increments? Is it too fast for the Flash Player to handle?
What's wrong with my math for the milliseconds on the time? I'd like to ONLY show 10ths of a second instead of thousandths.
The file is attached. Feel free to use it for whatever, if you like. I just need some input on the issues above.
Thanks,
IronChefMorimoto
View Replies !
View Related
SetInterval In Preloader Wont Work
Please Help!
I am dynamically loading in an external JPG with a percentage progress preloader. The preload movieclip kicks in and the picture loads but the progress will only show 0%
I've tried different variations of the setInterval part of the code but it still just shows 0%. I am probabley missing something very obvious, please put me out of my misery!
Thanks.
The code i'm using is:
PHP Code:
MovieClip.prototype.loadDynamicImage1 = function(imageToLoad) {
this.createEmptyMovieClip("mcPreloadholder", 1);
this.mcPreloadholder.attachMovie("mcPreloader", "mov2", 0);
this.createEmptyMovieClip("mcImageholder", 0);
this.mcImageholder.createEmptyMovieClip("mcImage", 1);
this.mcImageholder.mcImage.loadMovie(imageToLoad);
this.mcImageholder._visible = false;
this.startPreload ();
this.loadCheckID = setInterval(this.startPreload (), 100);
}
MovieClip.prototype.startPreload = function() {
this.onEnterFrame = function() {
percentageImage = int(this.mcImageholder.mcImage.getBytesLoaded()*100/this.mcImageholder.mcImage.getBytesTotal());
this.mcPreloadholder.mov2.percent.text = Math.floor(percentLoaded) add "%";
if (this.mcImageholder.mcImage.getBytesLoaded()>1 && this.mcImageholder.mcImage.getBytesLoaded()>=this.mcImageholder.mcImage.getBytesTotal()) {
this.preloadComplete();
clearInterval(loadCheckID);
this.loadDone();
}
};
};
View Replies !
View Related
SetInterval Doesn´t Work At Server
hello, I am making a scroll that depends on the "drag" position (drag is a movieclip) and, I did a setInterval to control the drag position in event on roll over....every things work ´perfectly at home, but when I put it on a server, the set interval is more slow, the interval that I am using is 1 milliseconds, but at server it seems 10 milliseconds....
what could it be??
this is the link to my page
www.chan.art.br
to see the effect, click on "Fotos" and the pass the mouse over the fotos below....it should be faster then it is in fact
thank you all
Chan
View Replies !
View Related
SetInterval + Dynamic Txtfields = Don't Work
hello all,
i'm having trouble using setInterval() to delay some textfields. they textfields are dynamically generated and i can animate the just fine using a for loop or an if statement...i just can't figure out how to get setInterval() to delay the iteration...
Code:
anim = function(a){
for(a=0; a< _global.bldgFacts; a++){
this.holder_anim["facts" + a]["factstxt" + a]._x +=(400-this.holder_anim["facts" + a]["factstxt" + a]._x)/20;
}
}
this.onEnterFrame {
a=0;var myInterval(anim, 5000);
}
i've tried a billion different things a billion different ways and haven't done anything but confuse myself!
thanks!
View Replies !
View Related
Help Getting Timer Based On SetInterval To Work
I'm building out the basic code for a timer that does 2 things:
Counts down "bonus points" -- 10th of the total milliseconds in the timer
Count down seconds and tenths of seconds
The bonus points will tick down along with the time -- this is part of a larger quiz interactive project that I'm putting together.
I can't quite figure out the following (my math is bad, I think):
Why can't the setInterval fire off in 1 millisecond increments? Is it too fast for the Flash Player to handle?
What's wrong with my math for the milliseconds on the time? I'd like to ONLY show 10ths of a second instead of thousandths.
The file is attached. Feel free to use it for whatever, if you like. I just need some input on the issues above.
Thanks,
IronChefMorimoto
View Replies !
View Related
How Do I Make Setinterval Work In Main MC
good day all
merry christmas and a happy new year to all
please can someone tell me how i can make a SetInterval code work for mii please this is the code am using
fastFrames = function(){ myMovie_mc.nextFrame(); updateAfterEvent(); } speedyID = setInterval(fastFrames, 40);
when i use it with for example a small animation and test the movie it works well well when i export it as a SWF file and test it again it still works BUT when i import the same swf, MC into a main MC it stops working and somehow the mc changes from a mc symbol to a graphic symbol and i aint got a clue what that means anyone who understands please help mee for chrismas sake tanks alot all i got the code from here http://www.kirupa.com/developer/acti...tinterval2.htm
View Replies !
View Related
SetInterval Doesn´t Work At Server
hello, I am making a scroll that depends on the "drag" position (drag is a movieclip) and, I did a setInterval to control the drag position in event on roll over....every things work ´perfectly at home, but when I put it on a server, the set interval is more slow, the interval that I am using is 1 milliseconds, but at server it seems 10 milliseconds....
what could it be??
this is the link to my page
www.chan.art.br
to see the effect, click on "Fotos" and the pass the mouse over the fotos below....it should be faster then it is in fact
thank you all
Chan
View Replies !
View Related
Create Setinterval Doesn't Work
Hi,
I used a tut found on this forum made by dynamozx3, it worked great for me in one swf (everything on same timeline) but now it seems I have a path problem....
-menu buts are in maintimeline level0
- actions on but is for the swf on level1
Code:
b1.onRelease = function() {
_level1.gotoAndPlay("out");
this.delay = setInterval(Delegate.create(this.clipLoad),1000);
};
function clipLoad(){
loadMovieNum("me.swf", 1);
clearInterval(delay);
};
The first part works, level 1 goes and plays "out", but then nothing happens , the next movie is not loaded...
Maybe the "this" is not referring to the right level ???
Pleassssseee help me out ????
Thanks,
Irene
View Replies !
View Related
Scrolling Scene With IF Statement That Won't Work
I've got a scrolling scene that works fine, except that I want the scene to stop scrolling completely if the user's mouse isn't near one of the sides of the movie (like this scene: http://www.campariusa.com).
I found a scrolling script that works fine, except that the scene is always scrolling a little bit. I added an additional IF statement saying that if _xmouse is between 155 and 485, then the scroll should be 0, but it's not working, can anyone tell me why?
Here is the script...thanks so much for any help that you can give me.
onClipEvent ( enterFrame ) {
//slows down scroll
scroll = ((320 - _root._xmouse)/100)
//if then statements
if (((this._x >= 0) && (scroll > 0)) ||
((this._x <= -500) && (shift < 0)) || ((_root._xmouse >= 155) && (_root._xmouse <= 485))) {
shift = 0}
this._x = this._x + shift;}
View Replies !
View Related
Script Inside Of If Statement Does Not Work
Hmm... Where to start? Okay, I would like to control a seperate SWF that is loaded within my movie.
This is what I thought would work.
Set a global variable that is equal to 0.
On the other SWF, I have this script checking if the variable has changed to 1 so it can play. Here is the script
Code:
onClipEvent (enterFrame) {
trace(_global.checkForNext);
if (_global.checkForNext == 1) {
play();
} else {
trace("It's going to else!");
}
}
On a seperate SWF, I have a button that changes the checkForNext variable to 1. It does that, I have confirmed it with the trace function.
Now the weird thing is, that the code does work, but it doesn't perform the action inside! I have tried to use play(), nextScene(). But basically, it does not work. I am stumped. If you can help in anyway, much would be appreciated.
If you want to check out the FLA/FLA's... just post and I'll post them. Thanks again.
View Replies !
View Related
Load Vars In If Statement = No Work
I a load Vars object inside of an if statement the does not work. The second that I comment out the if statement the code works just fine. The thing is the if statement works because I ran some traces to check that the code is running inside of it. Any help would be appreciated, here is the code:
on (press) {
if (selectionClip.selectedXML.firstChild.childNodes.l ength>0) {
id = new Array();
rationaleS = new Array();
for (i=0; i<selectionClip.selectedXML.firstChild.childNodes. length; i++) {
id[i] = selectionClip.selectedXML.firstChild.childNodes[i].attributes.id;
}
submitData = new LoadVars();
submitData.idList = replace(id.toString(), ",", "|");
submitData.countryId = _root.countryId;
submitData.timestamp = _root.gameClockMC.gameClock;
response = new LoadVars();
response.onLoad = function(result) {
if (result) {
_root.clearLeftMenu();
_root.gotoAndPlay("portfolio");
}
}
submitData.sendAndLoad("Portals/insertPortal3L2.cfm?r=" add Math.round(Math.random()*99999), response, post);
} else {
error._visible = true;
error.errorText = "You must have at least one Assessed Threat to Submit.";
blocker.gotoAndStop(2);
}
}
Now, the error check (the reason that I added the if statement works, in fact the code in the if statement runs up till the sendAndLoad. Once again, if I remove the if statement this works just fine. Has anyone seen anything like this before
thanks
cognizen
View Replies !
View Related
Conditional Statement Wont Work ?
I have four(4) seperate buttons that set a variable
to this when clicked (the buttons work):
soundVibe1 = "yes";
soundVibe2 = "yes";
soundVibe3 = "yes";
soundVibe4 = "yes";
-
Then I have this statement :
if (soundVibe1 == yes && soundVibe2 == yes && soundVibe3 == yes && soundVibe4 == yes) {
trace("all on");
} else {
trace("");
}
-
trace seems to always read "all on" even if I don't hit any buttons, as soon as Flash reads the action the trace "all on" is triggered. What's wrong here ??
Thanks
View Replies !
View Related
If Statement With Variable (why Doesn't This Work)
I'm trying to use a variable to load jpg files (in an array) into a movie clip. I then want a back and forward button. But i want the buttons to be disabled when they come tho the end or beginning of the array (e.g 8 or 0).
I've tried this (the variable is called ToLoad, the blank MC is cont):
onClipEvent (load) {
if (_root.Toload == 8) {
this.enabled = false;
} else {
this.enabled = true;
this.onRelease = function() {
_root.ToLoad++;
_root.cont.loadMovie(_root.jpgArray[_root.ToLoad]);
};
}
}
It should work shouldn't it?
View Replies !
View Related
Simple IF Statement Doesn't Work?
Hi Ive got two variables "message" and "name" and bot of them has to be filled in before I send the email. I use the following
if (name == "" | message== "") {
do nothing;
} else { process data; }
why doesn't this work?
Ive also tried using the OR like || but still nothing?
pls help
View Replies !
View Related
Conditional Statement Wont Work
Hi again!! I have a glitch in my code again and this time I've tried EVERYTHING i can think of (Yes, even checking the instance names etc, which i so intelligently did not check last time) so now I'm turning to you guys and gals for some help!!
OK, here's the problem....
I have a variable declared as "F1"on the main timeline which is intented to hold a simple true or false value so i can calculate the number of correct answers to a basic drag and drop game.
THE FIRST METHOD: I originally tried to store the values in a variable called "score" which would basically increment whenever a word was dropped in the right place. BUT this caused a problem: if they picked the word up off this correct spot and then dropped it back in the same spot again the score increments once more!! so, technically if the player is not sure of the answer and drops the word on this spot 3 or 4 times, the score increments that many times :S this meant i could have 22 out of 20 answers correct!!
SO........I am trying this other method which will store a true or false value if the correct answer is in the right place and then calculate the number of correct answers based on the number of variables which hold the "true" value.
The code I am using to check this is placed on an actions MC:
Code:
if (_root.Fword1._x == _root.Mum._x && _root.Fword2._y == _root.Mum._y) {
F1 = true;
trace("TRUE");
} else {
F1 = false;
trace("FALSE");
}
This is the second part of the code placed on a button which just adds one to the score variable if the answer is correct.
Code:
if (_root.F1 == true) {
_root.score++
}
BUT, it isn't recognising the first part of code for some reason. I have placed a dynamic test field on the stage to test this out and even try tracing it whilst i am playing the game but it clearly isn't working. Can someone please help, since i have wasted so much time fiddling with this one problem and I'm SOOOOO close to completing it!!
View Replies !
View Related
Simple If Statement Won't Work Unless There Is Another Command
ActionScript Code:
if (character.message_Box.text !== "") {
character.message_Balloon._alpha = 100;
}
for some reason this code will not work, unless I add another command. For instance, if change it to
ActionScript Code:
if (character.message_Box.text !== "") {
character.message_Balloon._alpha = 100;
trace("Hello");
}
then it will work..someone please explain?
View Replies !
View Related
Simple If Statement Doesn't Work Help
Got the AS on my first frame on the timeline to control a movieclip. Look like this:
if (mymovie._currentframe == 10) {
mymovie.stop();
}
So it should stop on frame 10 but it doesn't. What's wrong with the script? Do I need some kind of function before?
Thanks!
View Replies !
View Related
[fmx] Very Simple If Statement Which Wont Work
Hi,
sorry for my many posts, I am putting a project together and it is throwing many problems at me and I want to learn how to fix it.
My code is so simple, and i'm sure there might be a better way to do it also, I am open to suggestions. I just have a button and a movie clip (MenuUp) and i want the button to be able to make the movie clip jump to different frames...
on (release) {
if (_root.MenuUp=0) {
MenuPopup.gotoAndStop(1);
_root.MenuUp = 1;
} else {
MenuPopup.gotoAndStop(2);
_root.MenuUp = 0;
}
}
it'd driving me mad, tracing to the output window will only give me '0' i can never get it to '1'.
Matt.
View Replies !
View Related
[fmx] Very Simple If Statement Which Wont Work
Hi,
sorry for my many posts, I am putting a project together and it is throwing many problems at me and I want to learn how to fix it.
My code is so simple, and i'm sure there might be a better way to do it also, I am open to suggestions. I just have a button and a movie clip (MenuUp) and i want the button to be able to make the movie clip jump to different frames...
on (release) {
if (_root.MenuUp=0) {
MenuPopup.gotoAndStop(1);
_root.MenuUp = 1;
} else {
MenuPopup.gotoAndStop(2);
_root.MenuUp = 0;
}
}
it'd driving me mad, tracing to the output window will only give me '0' i can never get it to '1'.
Matt.
View Replies !
View Related
RETURN Doesn´t Work Within A Function SetInterval ?
Hello...
I found out a weird behaviour which i cannot explain....
If I have a function, with a setInterval within, and a "return" statement within the setInterval... return does not work!!!
I cannot find an easy workaround and I am a bit stuck... found a solution but with too many if/else... I dont like it much...
Did this happen to you too?
View Replies !
View Related
|