A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Pausing Actionscript

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Posts
    5

    Pausing Actionscript

    I've got a problem. I need to pause the execution of a script in the middle of a do/while loop.

    I am drawing buttons (using attachMovie) and then animating them (with mx.transitions.Tween) but I want each one to start animating a short while after the previous one. I've tried a few things but nothing has worked so far. I'm a little weary about splitting the script up since it took me a little while to get it all working.

    Anyone have any thoughts?

    The code I'm using is:
    Code:
    i = 1;
    do{	
    	this.attachMovie("clipButton","siteButton"+i,this.getNextHighestDepth());
    	this["siteButton"+i]._x = -150;
    	this["siteButton"+i]._y = 25*(i-1);
    	this["siteButton"+i].txt.text = buttons["site"+i];
    	this["siteButton"+i].x = i;
    	this["siteButton"+i].onRelease = function() {
    		_global.titleBar = buttons["site"+this.x];
    		_global.image = buttons["image"+this.x];
    		_global.blurb = buttons["desc"+this.x];
    		_global.visit = buttons["link"+this.x];
    		_global.dc = buttons["dc"+this.x];
    		_parent.pageHolder.info.visit.onRelease = function() {
    			getURL("http://"+visit,"_blank");
    		}
    		_parent.pageHolder.gotoAndPlay("close");
    	}
    	this["siteButton"+i].onRollOver = function() {
    		this.play();
    	}
    	this["siteButton"+i].onRollOut = function() {
    		this.gotoAndStop(1);
    	}
    	
    	var easeType = mx.transitions.easing.Strong.easeOut;
    	myTween = new mx.transitions.Tween(this["siteButton"+i], "_x", easeType, this["siteButton"+i]._x, 0, 1, true);
    
    	i = i+1;
    }while(i <= buttons.total);

  2. #2
    Junior Member
    Join Date
    Apr 2003
    Posts
    5

    Solved

    For anyone interested I have used this workaround. I don't think it's the best way, but it works

    The script I am now using on the one frame is:
    Code:
    if(i <= buttons.total){	
    	this.attachMovie("clipButton","siteButton"+i,this.getNextHighestDepth());
    	this["siteButton"+i]._x = -150;
    	this["siteButton"+i]._y = 25*(i-1);
    	this["siteButton"+i].txt.text = buttons["site"+i];
    	this["siteButton"+i].x = i;
    	this["siteButton"+i].onRelease = function() {
    		_global.titleBar = buttons["site"+this.x];
    		_global.image = buttons["image"+this.x];
    		_global.blurb = buttons["desc"+this.x];
    		_global.visit = buttons["link"+this.x];
    		_global.dc = buttons["dc"+this.x];
    		_parent.pageHolder.info.visit.onRelease = function() {
    			getURL("http://"+visit,"_blank");
    		}
    		_parent.pageHolder.gotoAndPlay("close");
    	}
    	this["siteButton"+i].onRollOver = function() {
    		_parent.title.title.title.text = buttons["site"+this.x];
    		_parent.title.gotoAndPlay(2);
    		this.play();
    	}
    	this["siteButton"+i].onRollOut = function() {
    		_parent.title.gotoAndPlay("close");
    		this.gotoAndStop(1);
    	}
    	var easeType = mx.transitions.easing.Strong.easeOut;
    	myTween = new mx.transitions.Tween(this["siteButton"+i], "_x", easeType, this["siteButton"+i]._x, 0, 1, true);
    	i = i+1;
    }
    Then I have a break for 2 frames (for the pause I wanted) before the simple piece of script:
    Code:
    gotoAndPlay(2);

  3. #3
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    check out Ladislav Zigo's tweening class: http://laco.wz.cz/tween/ it allows you a lot of flexibility and you can use delays, callbacks, etc. it also has 40+ different easing styles including bounce, elastic, back, strong, sine, expo, etc. there is also a custom easing tool MXP for it that allows you to create your own easing styles...

    it's very easy to use with even a limited amount of actionscript knowledge...
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center