A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] where to insert setInterval

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] where to insert setInterval

    Hi,

    I'm trying to have this gallery run by itself but eventhough it works, it doesn't load the pictures in the thumbnails when the trace gives me a right variable. Besides, I get more values than expected from it.

    The images are on boxes attached dynamically and the onPress handler works perfectly tracing one value at a time:

    Code:
    this.onPress = function():Void  {
    		temp = id;
    		this.id = _parent.box1.id;
    		_parent.box1.id = temp;
    		
    		_parent.box1.targetBox.attachMovie("image - "+temp, "image - "+temp, getNextHighestDepth());
    		this.targetBox.attachMovie("image - "+id, "image - "+id, getNextHighestDepth());
    		
    		_parent.box1.boxMask._width = _parent.box1.targetBox._width;
    		_parent.box1.boxMask._height = _parent.box1.targetBox._height;
    		_parent.box1.boxOutline._width = _parent.box1.targetBox._width;
    		_parent.box1.boxOutline._height = _parent.box1.targetBox._height;
    		_parent.box1.swapDepths(this);
    }
    but if I changge the code to:

    Code:
    function swapImages():Void {
    		id--;	
    		temp = id;
    		trace("temp = "+temp);
    		id = _parent.box1.id;
    		trace("id = "+id);
    		_parent.box1.id = temp;
    		
    		_parent.box1.targetBox.attachMovie("image - "+temp, "image - "+temp, getNextHighestDepth());
    		this.targetBox.attachMovie("image - "+id, "image - "+id, getNextHighestDepth());
    		_parent.box1.swapDepths(this);
    		
    		_parent.box1.boxMask._width = _parent.box1.targetBox._width;
    		_parent.box1.boxMask._height = _parent.box1.targetBox._height;
    		_parent.box1.boxOutline._width = _parent.box1.targetBox._width;
    		_parent.box1.boxOutline._height = _parent.box1.targetBox._height;
    		
    				if(id == 0){
    			clearInterval(interval_id);
    			trace("Interval cleared");
    		}
    	}
    			
    
    
    var interval_id:Number = setInterval(swapImages, 2000);
    it will work but only on the main image tracing the values of all the clips.

    Any ideas of how to face this? If you open up the attached fla, comment the first part of the code and uncomment the end part of it.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Is this what you require ??
    PHP Code:
    var count:Number 0;

    function 
    swapImages()
    {
        
    count++;
        if (
    count _parent.b)
        {
            
    clearInterval(interval_id);
            
    trace("Interval cleared");
        }
        else
        {
            
    temp id;
            
    id _parent.box1.id;
            
    _parent.box1.id temp;
            
    _parent.box1.targetBox.attachMovie("image - " temp,"image - " temp,this.getNextHighestDepth());
            
    targetBox.attachMovie("image - " id,"image - " id,this.getNextHighestDepth());
            
    _parent.box1.swapDepths(this);

            
    _parent.box1.boxMask._width _parent.box1.targetBox._width;
            
    _parent.box1.boxMask._height _parent.box1.targetBox._height;
            
    _parent.box1.boxOutline._width _parent.box1.targetBox._width;
            
    _parent.box1.boxOutline._height _parent.box1.targetBox._height;

            var 
    bMxscale:Tween = new Tween(_parent.box1.boxMask"_xscale"Regular.easeInOut50_parent.box1.boxMask._xscale1true);
            var 
    bMyscale:Tween = new Tween(_parent.box1.boxMask"_yscale"Regular.easeInOut50_parent.box1.boxMask._yscale1true);
            var 
    bOxscale:Tween = new Tween(_parent.box1.boxOutline"_xscale"Regular.easeInOut50_parent.box1.boxOutline._xscale1true);
            var 
    bOyscale:Tween = new Tween(_parent.box1.boxOutline"_yscale"Regular.easeInOut50_parent.box1.boxOutline._yscale1true);

            var 
    xTween:Tween = new Tween(_parent.box1"_x"Strong.easeInOutthis._x175.2true);
            var 
    yTween:Tween = new Tween(_parent.box1"_y"Strong.easeInOut30_parent.thumbscale 6.5.2true);
        }
        
    yTween.onMotionFinished = function()
        {
            
    trace("temp = " temp " : id = " id " count = " count);
            
    trace("-------------------------------");
        };
    }

    var 
    interval_id setInterval(swapImages2000); 

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    thanks, FruitBeard,

    Sure. It works and I'll take a better look at it later, but can you see why the thumbnail doesn't load the image? Id has a different value and ome thinks it should...

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