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








[MX04] OnEnterFrame / SetInterval Problem.


Scenario: I have several images that make up the background of my movie - which runs continuously. These change via masking / tweening on the main timeline. I have some movieclips that will move text across the screen, wait a few seconds, then fade out - all using AS. This works fine the first time thru the main movie .

However, when the movie cycles thru subsequent times the "text" movieclips do not work - the text is already fading when it enters the stage and there is no wait. I have found many tut's telling me how to move and fade a movieclip and it is simple @#$%#@

Please help!!

below is the code for the movieclips that run the text. You may notice several clearInterval's in the code - thats because it seems to me that the interval is still running when the movie starts the second time and I'm trying to clean all the intervals up


Code:
this._alpha = 100;
this._visible = true;
this._x = 900;
this._visible = true;


this.onEnterFrame = function() {

// move the text across the stage until it reaches it's target
if (this._x > _global.target) {
_global.speed = (_global.target - this._x)/_global.speedVar;
this._x += _global.speed;
}
else {
delete this.onEnterFrame;
}
// set a Timer and call function fadeImage
clearInterval(alpha_interval);
var alpha_interval:Number = setInterval(fadeClip, _global.timeBeforeFade, this);
};

// functions
// Fade
function fadeClip(target_mc:MovieClip):Void {

if (_alpha > 0) {
target_mc._alpha -= _global.fadeRate;
clearInterval(alpha_interval);
}
else {
target_mc._visible = false;
clearInterval(alpha_interval);
// target_mc.stop();
}

}




ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-24-2006, 05:43 PM


View Complete Forum Thread with Replies

Sponsored Links:

SetInterval Vs OnEnterFrame?
Anyone know which is less hungry on the old processor? I guess it depends on the interval and framerate, but for example i have 2 prototypes to move a mc with deceleration, the outcome is the same but is one a better method than the other?

code:
///FIRST USING ONENTERFRAME
MovieClip.prototype.moveWithDecel = function(spid, Xdest, Ydest, toLoad) {
this.spid = spid;
this.Xdest = Xdest;
this.Ydest = Ydest;
this.onEnterFrame = function() {
this._y += (Ydest-this._y)/spid;
this._x += (Xdest-this._x)/spid;
if (Math.abs(Xdest-this._x)<5 && Math.abs(Ydest-this._y)<5) {
this._y = (Ydest);
this._x = (Xdest);
delete (this.onEnterFrame);
if (toLoad !== undefined) {
_root.menuLoad(toLoad);
}
}
};
};

///THE SECOND ONE WITH SET INTERVAL
MovieClip.prototype.moveIntWithDecel = function(spid, Xdest, Ydest, interval) {
if (!interval) {
interval = 50;
}
this.spid = spid;
this.Xdest = Xdest;
this.Ydest = Ydest;
var mcN = this, MID = setInterval(function () {
if (Math.abs(Xdest-mcN._x)<2 && Math.abs(Ydest-mcN._y)<2) {
mcN._x = Xdest;
mcN._y = Ydest;
clearInterval(MID);
} else {
mcN._y += (Ydest-mcN._y)/spid;
mcN._x += (Xdest-mcN._x)/spid;
updateAfterEvent();
}
}, interval);
};


thanks

View Replies !    View Related
SetInterval And OnEnterFrame In Mx
Hi guys
I have 3 mcs on stage and this script in frame 1 that draws a line between them.
code:
stop();
function draw() {
mc.clear();
mc.lineStyle(0, 0x000000, 60);
mc.moveTo(h1._x, h1._y);
mc.lineTo(h2._x, h2._y);
mc.lineTo(h3._x, h3._y);
}
setInterval(draw, 2);

the setInterval is allways on.
After the animation plays on button i have the next script that plays the scene back
code:
on (release) {
_root.onEnterFrame = function() {
_root.prevFrame();
if (_root._currentframe == 1) {
delete _root.onEnterFrame;
}
};
}


The problem is that when the scene plays back the lines remain behind


If anyone have anyideas how 2 make this one work please help.

Thank You

View Replies !    View Related
SetInterval Vs OnEnterframe
Hey there friends,
Question for experienced users...

What are the true benefits of running timing functions with setInterval and onEnterframe?

What is advisable, I am a part of a team designing a couple of games but I am unsure of what's best to use...
Some people say setInterval and some other say NO... WAIT! never user setInterval, use onEnterframe, it's not too accurate but veery light...

So I am confused.

Please advise,

Thanks,

Cërf.

View Replies !    View Related
[F8] SetInterval Vs OnEnterFrame
hey guys...curious of some insight...if i have a function that can be called from setInterval or onEnterframe, which is the "safer" of the two options for calling the funciton? Does one (setInterval vs onEnterFrame) use more memory than another? if i have to run this function several times on the same frame, will that make a difference. For the sake of argument, lets say we are discussing motion AND alpha tweens on 5-10 mcs in one frame.

View Replies !    View Related
OnEnterFrame Vs SetInterval
So...

I have a script im trying to debug and am not getting anywhere... here's the problem:

Im trying to script 3 images to fade between each other, pause for a few seconds and then loop around to the beginning when the last image fades in (when image 3 fades out, image 1 should fade in). I have a script that mostly works but it has 2 problems: 1) the first time the script cycles thru, the first fade goes between image 1 and image 3 for some reason but then it will work from 1 to 2 to 3 to 1 to 2 to 3, etc. 2) it tries to fade between 4 images even though there are only 3 in my array.

Here is the code i have:


Code:
//set the list of image instances to fade between
var imageArray:Array = ["image1","image2","image3"];
var movieArray:Array =[];

//set all but the first image to alpha 0 to start and populate the movie Array
for (var i:Number = 0; i < imageArray.length; i++) {
var theMovie = this.attachMovie(imageArray[i],"mc_"+imageArray[i],this.getNextHighestDepth(),{_x:0,_y:0});
movieArray.push(theMovie);
if (i !== 0) {
this.theMovie._alpha = 0;
}
}
trace(movieArray);

// set the defaults
var currImage:Number = 0;
var nextImage:Number = 1;

//set the fade speed
fadeAmount = 3;

//fade in
function fadeIn(theImage) {
//trace(theImage);
theImage._alpha += fadeAmount;
if (theImage._alpha>=100) {
theImage._alpha = 100;
delete this.onEnterFrame;
}
}

//fade out
function fadeOut(theImage) {
//trace(theImage);
theImage._alpha -= fadeAmount;
if (theImage._alpha<=0) {
theImage._alpha = 0;
delete this.onEnterFrame;
}
}

function changeImage() {

movieArray[currImage].onEnterFrame = function() {
fadeOut(movieArray[currImage]);
fadeIn(movieArray[nextImage]);
trace('test inside onenterframe');
}

if (currImage = 0) {
trace(currImage);
} else if (nextImage < movieArray.length) {
currImage = nextImage;
nextImage ++;
} else if (nextImage = movieArray.length) {
currImage = movieArray.length
nextImage = 0;
}

}

setInterval(changeImage, 4000);

stop();
if anyone can just take a quick look at this and tell me if they can see where the problem lies and point me in the right direction i would be forever in their debt.

View Replies !    View Related
OnEnterFrame Or SetInterval ?
Ok I've got a question...

I've made a little function that's to be update. I always use onEnterFrame (create empty MC then affect to the onEnterFrame he function I want). But I've read somewhere that's not very good (slow down the animation).

My question is:
Is it true?
If i use the setInterval method and put an interval lower than the frame rate, is the function will be updated imediatly or is it waiting the next frame to update it... I've read that with setInterval the function TRY to be update the more closely to the interval when the interval is lower than the frame rate. So the update CAN NOT BE DONE AT THE SAME INTERVAL ??? (even if I use updateAfterEvent() )

Plz give me some explain on this...
Thx

View Replies !    View Related
-----onEnterFrame Or SetInterval------
HI guys ... I'm currently working on my first flashMX website.

Fancy effects included in my site require me to use onEnterFrame() to constantly move objects and checks whats going on.
I'm just a bit worried that all this code on an onEnterFrame() will slow down my site ?? But I'm not 100% sure becuse it's my first one.....And I don't really want to recode it!!

Does anybody have any tips?? Or maybe even a different way of coding it.

I was also thinking about trying to use a setInterval() were possible to take some of the weight of the onEnterFrame().

Any hints or tips would be cool .. cheers

View Replies !    View Related
Using SetInterval Instead Of OnEnterFrame
How could I use setInterval instead of onEnterFrame in this case?

The original:

this.onEnterFrame = function() {
trace(titles[this._name]);
}

What I would like:

titleInterval = setInterval( function(){ trace(titles[this._name]); }, 100 );

Obviously the way I'm using the interval method doesn't work. I basically want to know how to use 'this.' within a function.

View Replies !    View Related
OnEnterFrame Vs SetInterval
Hello everyone...

I dont know if this has been discussed here before...

i was having a conversation with a flash developer and he was going on about how using setInterval is much better than using onEnterFrame for actionscripted animations as the latter suffers from platform dependance (muc slower on Macs and slow processors) and also because once killed (delete onEnterFrame) can't be reinstated.

Yesterday i received some help in this forum and the person who helped me pointed that i should use onEnterFrame as opposite as setInterval as is easier to use and less buggy...



Anybody willing to shed some light on the subject?

Cheers in advance for your advice!!

D

View Replies !    View Related
OnEnterFrame Vs SetInterval
hi all...

in the past, i've used both onEnterFrame and setInterval as timers to call other functions. is one of these methods more processor-intensive than the other?

for example:

ActionScript Code:
onEnterFrame = function()
{
        timer ++;
        if ( timer >= 90 )
        {
                // do it
        }
}


vs the obvious/standard setInterval ?

just out of curiosity. it seems that setInterval may be lighter, but why? i realize that you're running that EnterFrame every frame and adding to a variable, but does setInterval run on some kind of internal timer that is less processor intensive?

thanks.

View Replies !    View Related
SetInterval Vs OnEnterFrame
Is it better to use setInterval function rather then listening on the onEnterFrame event?

Richard

View Replies !    View Related
[AS] OnEnterFrame Vs SetInterval
Hi!
I have been developing a library of MovieClip Extensions during last year, while working on different projects.

The library is a set of motion/appearance functions such as mc.fade(alpha, steps) or mc.slideX(x,steps) etc, and its based on the ability to reprogram the onEnterFrame MovieClip event.

I am seriously thinking on updating the library using setInterval instead because of the following reasons:

+ be able to mix different processes on the fly (when reprograming the onEnterFrame event you kill the current one)

+ Flash 5 Compatibility

But the main target for me would be performance issues.

Does anybody faced and deeply tested performance differences between both methods?

In other words, do you think I will get better CPU cost and therefore better performance using setInterval?

Thanks,

View Replies !    View Related
Q: SetInterval Vs OnEnterFrame
Hi
Does anyone regularly use setInterval rather than onEnterFrame to call functions?

Especially when you are using a slower framerate, say to accommodate streaming video.

What are the disadvantages when you start setting the interval shorter than the framerate?

View Replies !    View Related
Efficiency: OnEnterFrame Vs SetInterval
im setting up a file in as2.0 that employs a custom Insect class that will essentially be a whole lot of bugs moving and interacting with one another on the stage. there will be lots of them present on stage at any given moment, and they will be rotating and moving around constantly. Im wondering if i should use onEnterFrame commands or setInterval commands to define the animation of their movements. Of the two, is one more efficient than the other in terms of processing time? Alternatively, is there an even more efficient way to animate relatively slow and deliberate motion?

Cheers
j

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
Difference Between Setinterval And OnEnterFrame?
I have an event that I want to repeat over and over...what's the difference between setINterval and onEnterFrame, from a design and efficency perspective? Besides that setINterval lets you pick an interval time, of course.

View Replies !    View Related
OnEnterFrame Or SetInterval(), Many Questions..
how can I create my own function with itself onEnterFrame functionality?
without creating special MC? should it be an Object? how?

I need to call a function that will do some onEnterFrame events for some time and then it ends.

is it possible to put uniqe name to this notation?

Code:
onEnterFrame = function () { }
and the just call it? then how to stop it?

I know there is a setInterval() function, but I realy don't like it because it's so stupid (sorry), it can be stopped only with usin some global ID variable, why isn't there an option "repeat it n times"?

also the timing can't be set to FPS (only manualy), I can't imagine why do not exist any system property for FPS (or I can't find it?), I need it so much!!!

thx a lot


ps: im using MX.

View Replies !    View Related
[F8] Can SetInterval Be Used In Conjunction With OnEnterFrame?
Hi,

I have a screen with numbers in a dynamic text field (channel_txt.text). When one of two buttons is pressed, the numbers scroll up or down (between 1 and 99) in the screen. My question is: is there a way to slow the scrolling down using setInterval, even though I'm using onEnterFrame? Or do I need to use another method? I went the onEnterFrame route because I want the numbers to keep scrolling as long as the user has the mouse down over the button.

The reason that I need to slow it down is because I'm embedding the movie in presentation software (Articulate) that requires the movie to be set at 30 fps. At this speed, the numbers fly up and down.

This is my code for the left button (select_mc, which scrolls the numbers down):


Code:
on (press) {
select_mc.onEnterFrame = function() {
channel_txt.text --;
if (channel_txt.text < 1) {
channel_txt.text = 99;
}
}
}
on (release, releaseOutside) {
select_mc.onEnterFrame = function() {
null;
}
}
Many thanks for checking it out and any advice.
Todd

View Replies !    View Related
_RAPID : OnEnterFrame VS SetInterval
I am working on modifying a gradual color-changer. I want to ensure the color transition to run as smooth as possible, so it requires a very rapid process.

The question is : Which one does have better performance, onEnterFrame(with 120 fps) or setInterval(every 1 milsec) ???

Regards

View Replies !    View Related
OnEnterFrame Dont Like SetInterval
Hi guys
I have 3 mcs on stage and this script in frame 1 that draws a line between them.

ActionScript Code:
stop();
function draw() {
    mc.clear();
    mc.lineStyle(0, 0x000000, 60);
    mc.moveTo(h1._x, h1._y);
    mc.lineTo(h2._x, h2._y);
    mc.lineTo(h3._x, h3._y);
}
setInterval(draw, 2);

the setInterval is allways on.
After the animation plays on button i have the next script that plays the scene back


ActionScript Code:
on (release) {
    _root.onEnterFrame = function() {
        _root.prevFrame();
        if (_root._currentframe == 1) {
            delete _root.onEnterFrame;
        }
    };
}

The problem is that when the scene plays back the lines remain behind

This is an exemple and i know that i can do the reverse animation on stage but for my site i need to use onEnterFrame.

If anyone have anyideas how to make this one work please help.

Thank You

View Replies !    View Related
Help With SetInterval / Delete OnEnterFrame
Hi,

Having some difficulty removing an onEnterFrame function for a scaling effect on a map. If I don't remove it, the function seems to loop, causing massive resource usage and slowing down the HTML page its on.

What I want to do is let the function happen when a button is clicked, then for it to stop once its scaled once. The function has to be called from a zoom in, zoom out and a reset button.

I have the basic code below, but this isn't working. Any help would be greatly appreciated.


Code:

//the zoom in button actions
zoomIn_btn.onPress = function() {
clearInterval(zoomInterval);
zoomInterval = setInterval(_root, "zoomIn", 100);
zoomIn();
nicescale();
};
//the scaling effect
function nicescale() {
map_mc.onEnterFrame = function() {
this._xscale = this._yscale += (this.scale-this._xscale)/2;
if (this.activeMovement) {
this._x += (this.x-this._x)/2;
this._y += (this.y-this._y)/2;
}
};
};
//remove the scaling effect
function removescale() {
delete map_mc.onEnterFrame;
scaleInterval = setInterval(_root, "scaleInterval", 100);
}
I know I need to call the 'removescale' function, but at the moment it's not working so I've removed it from the zoomIn_btn.onPress function.

cheers,
iain

View Replies !    View Related
Remove OnEnterFrame With SetInterval
Hello, I need really quick aid with this one ,
what I'm trying to do is remove on regular intervals the onEnterFrame function and I'm trying it with setInterval, but something bugs, please check if you can tell me what I'm not doing right..:

Code:

this.onEnterFrame = function ()
{
    this._y = this._y - this.speed;
    if (this._y <= 900)
    {
        delete this.onEnterFrame;
        this.removeMovieClip();
    } // end if
};


function clearBubbles()
{
       delete this.onEnterFrame;
        this.removeMovieClip();
}

interval5 = setInterval(clearBubbles, 1);

View Replies !    View Related
Convert OnEnterFrame To SetInterval Animation
Hi all. I received some great help with my previous problem of getting my animation to stop and now I like to see if I can get the animation to use setInterval instead of onEnterframe if that's possible.

This is the current function as it is now:

ActionScript Code:
function moveDown1():Void {
        this.nButtonPositionY = 380;
        this.nButton1X = 675;
        this.onEnterFrame = function() {
            if (nButtonPositionY > this._y) {
                this._y += this.Speed;
            }else if (Math.abs(this._y - nButtonPositionY) < 1) {
                delete this.onEnterFrame;
            };
            if (nButton1X > this._x) {
                this._x += this.Speed;
            }else if (Math.abs(this._x - nButton1X) < 1) {
                delete this.onEnterFrame;
            };
        };
    }


I'm calling it in the timeline like so:

ActionScript Code:
contactbtn_mc.onRelease = function() {
    contactbtn_mc.moveDown1();
   
};


Now, to be honest I've never worked with setInterval before so I'm not entirely sure where to begin. My thoughts are that I need to either
set a conditional on the onRelease function using a clearInterval when the mc reaches the target position
-or-
completely redo the function in a different way

Am I at least on the right track with one of those theories?

View Replies !    View Related
[MX04] OnEnterFrame
Hi,
I have a simple puzzle that once completed needs to display a message and button to enable the user to click to proceed to another page (in html)
can somebody help me with the code that I need to check if all the draggable items are in place and then proceed to the button and text, please?

View Replies !    View Related
[MX04] Is It Possible To Find Out Which Mc's Are Running Functions OnEnterFrame()
i have done everything i can to optimize my code and movies to make everything run as smoothly as possible and decrease processor load... BUT, thins are still running slow and processor load is pretty heavy. I have made sure I have deleted every onEnterFrame() running from within the functions themselves.. but the only thing i can figure is that some aren't deleting properly...

So i was wondering if there is a way to output (at any random time i want to) any and all MC's running onEnterFrame loops?....

or can anyone offer another solution for how to pinpoint what is causing the lag?....

Thanks in advance

View Replies !    View Related
[MX04] Help With SetInterval Pls
my MC has a 1 second animation within it,
I wanted to set a timing to it so that it would play the animaton every 10 seconds, I have this code inside my MC on the first frame;

stop();
var myInterval = setInterval(timing, 10000);
function timing() {
gotoAndPlay("logo_animation");
}

it works but, after a while it goes crazy, it keeps on animating every 5 seconds and every 2 seconds and keeps changing the timing by itself

I don't have a stop action on the last frame so that after it animates, it goes back to frame one and stops,

how can I overcome this ?

thanks.

View Replies !    View Related
[MX04] SetInterval Not Firing?
Hi,

I have this simple movie that dynamically types out a paragraph of text from a provided string into a dynamic text field.

I had it set up so that the "onEnterFrame" event puts a letter into the field with every passing frame.

Everything worked great until i changed the "onEnterFrame" event to a "setInterval" event - now it won't work at all!

I know the setInterval is firing as i have changed the code in the function to a simple "trace" command & that worked fine - so the problem has to be with the code in the function.

Here is the actual code. Fla also attached

code: in_txt.background = true;
in_txt.backgroundColor = "0x000000";
in_txt.textColor = "0xFF6600";
main_str = " Any organisational skills you may posses will assist you in your financial dealings in years to come, however you must also be adaptable and open to change.";
temp_str = "";
counter = main_str.length;
down = 0;
function addLetter() {
if (down<=counter) {
temp_str = temp_str.concat(main_str.slice(down, (down+1)));
}
this.in_txt.text = temp_str;
down++;
}
setInterval(addLetter, 100);
//_root.onEnterFrame = addLetter;

View Replies !    View Related
[MX04] Looping A SetInterval
Hi,

I'm trying to make a red block increase in height using a setInterval to loop the increase height code until it hits it's predetermined height.

For some reason, my red block (Funds) just doesn't want to rise.

The MC I'm trying to change is call Funds.

Could anybody suggest to me what the bugger ah'm doin' wrong?

Ta.

Neily


PHP Code:



onClipEvent (mouseUp) {
    var FundsHeight =(FundingVariables.Funds/FundingVariables.Target)*155;
    

        function IncreaseFunds(){
         _root.Funds._height++;
           if (_root.FundsRaised._height==FundsHeight) {
          clearInterval(FundInterval);
       }
    }
    
    FundInterval = setinterval(IncreaseFunds, 100);

}

View Replies !    View Related
[MX04]setInterval Inside A Function
i am making a function that will automaticly set an interval in when that intervil finishe: restart it but with twice the delay....

basicly i want to time the levels in a game and ech time a level finishes make the next one twice as long.

Code:
function endlevel() {
trace("Level Done")
_root.delay = _root.delay*2;
trace(_root.delay);
clearInterval(intervalID);
var intervalID = setInterval(endlevel,_root.delay);
}

the delay veriable doubles but the intervill does not....why??

View Replies !    View Related
[MX04] Having Trouble With SetInterval Not Clearing
OK, what I an building is a thumbnail gallery for a photo album. When the user goes through the pages, the current page of thumbnails fade out, and the new thumbnails fade in. I do this by using a for loop and calling the fade function listed below. OK, everything works fine EXCEPT when I start clicking through the pages at a fast rate...apparently too many intervals are being created or something is messed up, because it soon goes to crap. If I click at a reasonable rate, like once per second, it runs fine. How can I prevent things going to muck?


Code:

function fadeMovieClip(mClip:MovieClip, nRate:Number):Void{
if(mClip._alpha >= 0 && mClip._alpha <= 100){

var nAlpha:Number = mClip._alpha;
mClip._alpha = nAlpha + nRate;
updateAfterEvent();
}
else {
if(mClip._alpha > 100){
mClip._alpha = 100;
}
else if(mClip._alpha < 0){
mClip._alpha = 0;
}
clearInterval(fIntervalIDs[mClip]);
}
}

in the for loop, I'm doing something like this:

Code:
fIntervalIDs[xpic] = setInterval(fadeMovieClip, 50, xpic, -10);


Where fIntervalIDs is declared as: var fIntervalIDs:Object = new Object();

View Replies !    View Related
[MX04] Getting A Function To Repeat/setInterval Problem
Hey gang... this should be the last question for a while.

After some help from the boards, I have created a function that duplicates some MCs, runs the animation, and then removes the clips when they reach a certain point on the _y axis. I need for that function to repeat every so often (let's say 5 secs for this example)... I thought it was a simple setInterval, but it's acting all wonky.

Can someone help me sort it out?

code: condensation = function () {
var condensationNum = Math.round(Math.random()*4)+1;
for (i=0; i<condensationNum; i++) {
attachMovie("drops", "dupMC"+i, i);
this["dupMC"+i]._x = Math.round(Math.random()*200)+500;
this["dupMC"+i]._y = Math.round(Math.random()*155)+195;
var scale = Math.round(Math.random()*50)+50;
this["dupMC"+i]._xscale = scale;
this["dupMC"+i]._yscale = scale;
}
this.onEnterFrame = function() {
with (this) {
for (i=0; i<condensationNum; i++) {
if (this["dupMC"+i].dropMC._y+this["dupMC"+i]._y>525) {
this["dupMC"+i].stop();
if (this["dupMC"+i]._alpha>1) {
this["dupMC"+i]._alpha -= 10;
} else {
this["dupMC"+i].removeMovieClip();
}
}
}
}
};
};
this.onEnterFrame = function() {
myInterval = setInterval(condensation(this), 5000);
};

The problem is that I have 2 onEnterFrames called from the _root, but I don't know where to put the other one. The only things I've got on the stage with instance names are the MCs created within the function, and since I suck at loops I have no idea what how change the pathing of the onEnterFrame found within the function so that I can use the _root for the other one. I hope that makes sense...

Any help is most appreciated!

-Sandy

View Replies !    View Related
[MX04] Urgent-Problem With SetInterval And Print ? Here Is The Code..
Hi, the problem I have is that when I call my function printpage, it prints. But when I put a delay (when i press the button and after 2 sec the print dialog pops up) when I click ok the page is not printed.


var myInterval:Number;
function delay() {
myInterval = setInterval(printpage, 1000);


}

function printpage() {

var my_pj:PrintJob = new PrintJob();
if (my_pj.start()) {
if (my_pj.addPage(this)) {
my_pj.send();
}
}
delete my_pj;
}

View Replies !    View Related
[MX04] SetInterval Function Running Finite Number Of Times...
Hi,

I was wondering if someone could look over this(see code below). It basically stops responding and offers to stop running the script.

What I'm trying to do is run a function a finite number of times with an interval between each time it runs.

There may be a better way of doing it otherwise but any suggestions would be brill, Ta.

Neily


PHP Code:



onClipEvent (mouseUp) {
    var Counter=0;
    
    do {
        setInterval(TraceTest,1000);
    } while (Counter<=10);

    setInterval(TraceTest,1000);
    
    function TraceTest(){
        trace("Function Called" + Counter);
        Counter++;
    }
}

View Replies !    View Related
OnEnterFrame=null, OnEnterFrame=undefined & Delete OnEnterFrame....
onEnterFrame=null, onEnterFrame=undefined & delete onEnterFrame....


Which one to use??? What are the performance considerations. If all my movieclips on-stage are running a MovieClip.prototype.onEnterFrame = function() {run initial stuff before setting onEnterFrame=null/undefined... }, will there be performance hits? It's sad that delete onEnterFrame doesn't work unless I delete the prototype enterFrame as well, which would make the clips reinitailise itself again once you declare the enterFrame prototype again (i need to do this since there's more movieclips that end up appearing on-stage, and they need to automatically initialises themselves the moment they appear).

It seems that setting enterFrame to null or undefined is the safest way to go about it, since dealing with multiple .swfs would mean using the same MovieClip.prototype, which means I can't afford to flush out one zone of enterFrames (by deleting both null enterframes and MovieClip.prototype.onEnterFrame) if it means the other zones still needs to initialise their clips first...it's just too troublesome and buggy a mechanism to implement! Once MovieClip.prototype.onEnterframe is declared, it should stay. Will there be performance hits as a result of this?

Is there anyway to do this without tricking the engine to call the onLoad function for MCs by typing "//" into each movieclip actionscript box --- or by troublesomingly creating linkage-ids for every movieclip library item!? NO! That's not what i want...they'll only add to the fiile size! How do i execute a certain "constructor/initilisation" function to all Movieclips without linking them to a class in a library? Something to think about.....

View Replies !    View Related
[MX]Clip Changing With OnEnterFrame Not Changing With "setInterval"
Hi,

I have built a simple site where the logo at the top of the page has been constructed as a masked grid, the idea being that the logo is revealed as each cell in the logo has it's color changed.

The color is changed via a tween in each individual cell & I originally triggered this to happen with the following “onEnterFrame” script (newHold_array[k] being the array that holds the clips);

k = 0;
_root.onEnterFrame = function() {
thisOne = newHold_array[k];
this.holdit_mc.nhold_mc[thisOne].play();
k++;
if (k>=353) {
break;
}
};

The above code works fine but I wanted to speed up the rate of change so put a similar function in to a “setInterval” fired script

function lightUp(){
thisOne = newHold_array[k];
trace(thisOne);
this.holdit_mc.nhold_mc[thisOne].play();
k++;
if (k>=353) {
clearInterval(lightInt)
}
}

which although firing ok & able to trace out the correct cell with “trace(thisOne);” will not get the correct or any cell to play?

Fla attached.

View Replies !    View Related
"Clip Changing With "onEnterFrame" Event Now Not Changing With "setInterval.”
Hi,


I have built a simple site where the logo at the top of the page has been constructed as a masked grid, the idea being that the logo is revealed as each cell in the logo has it's color changed.


The color is changed via a tween in each individual cell & I originally triggered this to happen with the following “onEnterFrame” script (newHold_array[k] being the array that holds the clips);



ActionScript Code:
k = 0;_root.onEnterFrame = function() {thisOne = newHold_array[k];this.holdit_mc.nhold_mc[thisOne].play();k++;if (k>=353) {break;}};



The above code works fine but I wanted to speed up the rate of change so put a similar function in to a “setInterval” fired script



ActionScript Code:
function lightUp(){thisOne = newHold_array[k];trace(thisOne);this.holdit_mc.nhold_mc[thisOne].play();k++;if (k>=353) {clearInterval(lightInt)}}



which although firing ok & able to trace out the correct cell with “trace(thisOne);” will not get the correct or any cell to play?


Fla attached.

View Replies !    View Related
What Difference Between Mc.onEnterFrame And Funtion OnEnterFrame()
Dear, All,
Could anybody tell me the difference about them, I am fresh......

thanks in advance

View Replies !    View Related
Problem With OnEnterFrame And Delete OnEnterFrame
Ok here is the nuts of the problem,

When I delete the onEnterFrame function programatically I can't reassign it later.

Here is what is happening:
I have a method that I call to build a box on the screen over time. I build it overtime using the onEnterFrame function.
When the application is done it delete the onEnterFrame just fine.

Everything works as expected until you try to assign the same method over again to say for instance make the box smaller. Once I try to call it again I can't assign the onEnterFrame again... I have no idea why it is totally strange.


Code:
//Create an interface
//mc:MovieClip, x:Number, y:Number, w:Number, h:Number
InterfaceBuilderClass.prototype.createInterface = function(mc,x,y,w,h)
{

mc.dy = (h/2)*-1
mc.dx = (w/2)*-1
mc.dy1 = h/2
mc.dx1 = w/2
mc.NFRAMES = 40;
mc.controller = this;
mc.t = 0;

mc.onEnterFrame = function()
{
if (this.t++ < this.NFRAMES) {
trace(this.t);
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM

}else
{
//redraw with rounded corner
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM

this.controller.executeCallBack()
delete this.onEnterFrame;
}
}
}

Try it for yourself and see if you can make it work.

If anyone else has run into this problem I'd love to know how you resolved it.

Thanks,
Mark

View Replies !    View Related
Re-initialising OnEnterFrame After Deleting OnEnterFrame
Hello to all the actionscript guru's!

I have this thing where when I click this other thing which is controlled by a different thing which gets deleted after I click the other thing and I would like to know if I can sort of undelete the different things thing????

Okay, now in English.

I have some movieclips that move using an onEnterFrame. When you click on a movieclip, I stop the movement by deleting the onEnterFrame. Is there a way to re-initialise the onEnterFrame to get the movieclips moving again?

A thanks in advance for everyone who reads this question

View Replies !    View Related
Delete OnEnterFrame; Start OnEnterFrame?
Hi, title says it all.... any consise methods to restart a deleted onEnterFrame that has been deleted?

Thanks!

View Replies !    View Related
Delete OnEnterFrame Re-establish OnEnterFrame
i'm trying to stop an onEnterFrame [via the delete onEnterFrame] but later re-establish it, or restart it. is this even possible?? anyone got suggestions if it ain't??

View Replies !    View Related
Custom Objects And Internal SetInterval Loops -> A Problem Stopping The SetInterval
Let's say I had a class like this:


PHP Code:



var someVar = new Widget();

function Widget() {
    // Some variables, etc...
    this.int_someCommand = 0;
    // Activate the function on instantiation
    this.someCommand();
};

Widget.prototype.someCommand = function() {
    clearInterval(this.int_someCommand);
    this.int_someCommand = setInterval(this, 'someCommandLoop', 50);
};
Widget.prototype.someCommandLoop = function() {
    trace("THIS IS A WIDGET LOOP!");
}; 




...now, I was always under the impression that if you delete an object in Flash, the setInterval loops associated with it would die as well. But when I try to:


PHP Code:



// At some other point in my timeline...
delete someVar; 




or:


PHP Code:



someVar = new Object(); 




...the original loop is still running (I can tell just by reading the trace). How do I go about properly terminating a setInterval loop inside an Object without having to call a clearInterval()? Or is a clearInterval() the only way?

Thanks.

View Replies !    View Related
Tween Class, Does It Use Setinterval? Getting Strange Setinterval Type Problem
I have a gallery with small thumbnails. Upon clicking a thumbnail, I am using the Tween class to pull clips from an array and fade them between each other, loading the clips into a container.

When I click the thumbnail it loads the .swf fine and plays the Tween Class animation just as it's supposed to, however if I click any other thumbnail and go back to that first one the timing gets totally screwed up and the fades get jittery and overlap each other, much like it does with setInterval if you don't clear the intervals.

Is there a way to clear the Tween Class? Does it's timer run on setInterval?


This is the code I am using for the tween class


Thanks!


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

//content movieclips put into an array
var mcArray:Array = new Array(content1, content2);
for (var k in mcArray) {
mcArray[k]._alpha = 0;
}

// tween class has something called "OnEnterFrameBeacon" and it is added to the stage
// when we import the as file, so I wanted to get rid of it.
var n:Number = 0;

function playFades() {
if (n<mcArray.length) {
var tween_handler1:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 0, 100, 1, true);
tween_handler1.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
//n++;
var tween_handler2:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 100, 0, 3.5, true);
tween_handler2.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
n++;
playFades();
};
};
} else {
n = 0;
playFades();
}
}
playFades();

View Replies !    View Related
[F8] OnEnterFrame Inside OnEnterFrame
this is a simplification of what I have:

function fadeOutBorder(thumbnail){
this.onEnterFrame = function() {
if(this["thumbnail"+thumbnail]._alpha>0) {
this["thumbnail"+thumbnail]._alpha-=5;
}else{
this["thumbnail"+thumbnail]._visible=false;
//delete _root.onEnterFrame;
}
};
}


function loadThumbnails(){
onEnterFrame{
//stuff here...
fadeOutBorder(5);
//when that^^ is called... it quits the rest of the script...
//more stuff here...
};
}


So what happens is when I call fadeOutBorder.. It just stops that onEnterFrame in the loadThumbnails function.

View Replies !    View Related
[MX04] [MX04] Action Script To Stop A Movieclip Playing
Does anybody know of any actionscript to put on a flash button that will make a movie clip stop playing when rolled over (not an offstate in the clip) but separately on the main timeline? Kind of like a stopallsounds but for a specific movieclip? I have something that is making me crazy!!

View Replies !    View Related
Mc.onEnterFrame = Foo() ?
I am trying to dynamically give MCs the onEnterFrame event handler. I have 4 MCs on stage each with the name: clip1, clip2, clip3, clip4. Each clip does the onLoad, but only the first clip rotates; furthermore, the trace in rotate only outputs the first clip...

Code in frame 1:

var clips = [clip1, clip2, clip3, clip4];

// Make each clip 50% alphaed onLoad
function init(s) {
s._alpha = 50;
}

// Rotate each clip 5 degs onEnterFrame
function rotate(s) {
trace(s);
s._rotation += 5;
}

for(i in clips) {
s = clips[i];
s.onLoad = init(s);
s.onEnterFrame = function() {
rotate(s);
}
}

Any thoughts?

tx!

View Replies !    View Related
Onenterframe
I using a bit of actionscrpt I found from your message boards which I then changed and began to understand. It was for making a menu come into the screen when pressing space. The problem I have is after it has loaded you have to click on the frame to make the menu come in when space is pressed. I believe it is something to do with the "onenterframe".

this is the code:

menu.onEnterFrame = function() {
if (Key.isDown(Key.SPACE)) {
if (menu._x<0) {
menu._x += 20;
}
} else {
if (menu._x>-80) {
menu._x -= 20;
}
}
};

have tried to change it to "onLoad" but that does not seem to be it. Would love any help as this has been driving me mad of days. my website www31.brinkster.com/anpond/ that is the old one. The one I am going to replace it with is www31.brinkster.com/anpond/movie/ Thanks for your help.

View Replies !    View Related
OnEnterFrame
Hey,

I'm jus' learning the onEnterFrame stuff...

And I've got a problem:
Why cant I use more then 1 onEnterFrame per MC?

The reasong I'm asking this is because I have different types of code, and to make the code better to look at, I want to store the code on different layers, so I would also need more then 1 onEnterFrame events... but I can't get it to work... is there a way to solve it or something?

View Replies !    View Related
Getting Out Of A OnEnterFrame()?
Hi all!

I am having problems getting out of an onEnterFrame(). What I want to do is making a movieClip invisible, but once the ._alpha is below 0 I need to break out of the onEnterFrame(). However, I cant seem to get it rigth!

Here is some code:
code:
instance.onEnterFrame = function(){
instance._alpha -= 20;
trace("alpha is"+instance._alpha);
if (instance._alpha < 0) {
return;
}
};


Hope there is any help out there!

Ciao ciao

View Replies !    View Related
OnEnterFrame
Hi

I use movieclip placed in first frame of scene:

onClipEvent(enterFrame){}

I want to know how to use button to execute this movieclip in place of using onClipEvent(enterFrame).

Thanks a lot

View Replies !    View Related
OnEnterFrame
I was just wondering how many onEnterFrames are kosher for a site. Does it matter? Or, does it just depend on the complexity of the code within?

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved