hello,
i am new to flash and i was wondering if there is a way to slow down for loops.
Like i can set how many seconds till it goes and loops again. I have tried setInterval but didnt work.here is my code:
on (press) {
enemmyX = this._x;
enemmyY = this._y;
for(starX = _root.star1._x;starX>enemmyX; starX–){
_root.star1._x = _root.star1._x-1;
// Slow down function here
}
}
help will be appreciated.
             
            
              
              
              
            
            
           
          
            
            
              it has to be something with setInterval… so maybe this works:
on (press) {
	setInterval(function() {
		enemmyX = this._x;
		enemmyY = this._y;
		for (starX=_root.star1._x; starX>enemmyX; starX--) {
			_root.star1._x = _root.star1._x-1;
			// Slow down function here
		}
	}, 1000);
}
maybe it doesn’t because i’m not very formiliar with the setInterval function, but im just trying to help
             
            
              
              
              
            
            
           
          
            
            
              or maybe this will work:
on (press) {
	function go() {
		enemmyX = this._x;
		enemmyY = this._y;
		for (starX=_root.star1._x; starX>enemmyX; starX--) {
			_root.star1._x = _root.star1._x-1;
		}
	}
  theinterval = setInterval(go, 1000);
}
             
            
              
              
              
            
            
           
          
            
            
              umm this wut i have now but it just kinda like freezes then gives me a messege.
on (press) {
enemmyX = this._x;
enemmyY = this._y;
starY = _root.star1._y;
starX = _root.star1._x;
while(starX>enemmyX || starY>enemmyY){
theinterval = setInterval(movestar, 1000);
}
function movestar(){
	if(starX>enemmyX){
		_root.star1._x=_root.star1._x-1;	
		starX = _root.star1._x;
	}
	if(starY>enemmyY){
		_root.star1._y=_root.star1._y-1;	
		starY = _root.star1._y;
	}
	clearInterval(theinterval);
}
}
             
            
              
              
              
            
            
           
          
            
            
              could you explain what you want to happen when you click the button? because i don’t know why you want to use a interval, because the code will only be executed when the button is clicked… or maybe you can put the .fla online?
             
            
              
              
              
            
            
           
          
            
            
              ok i have a button inside a movie clip and thats wut this script is inside. and then i have a moveiclip called star. and when i pres this button i want the star to come to this objects coords but slowly and thats why i am using set interval.
             
            
              
              
              
            
            
           
          
            
            
              so you want movieclip star to slowly move to the button? maybe this tutorial will help you http://www.kirupa.com/developer/mx/ASmovement.htm
             
            
              
              
              
            
            
           
          
            
            
              but thats only for entering the move i need on click.
             
            
              
              
              
            
            
           
          
            
            
              try this code:
on(press){
	star.endx = this._x;
	star.endy = this._y;
	star.onEnterFrame = function(){
		speed = 10;
		x = this.endx - this._x;
		this._x += x/speed;
		y = this.endy - this._y;
		this._y += y/speed;
	}
}
if it doesn’t work: check if the path for star is correct… or put the fla online…
             
            
              
              
              
            
            
           
          
            
            
              wow thanks alot man.  Thank you
             
            
              
              
              
            
            
           
          
            
            
              you’re welcome! i always like to help somebody 