A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [CS3] AS3 Rending issue which is annoying me greatly

  1. #1
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988

    [CS3] AS3 Rending issue which is annoying me greatly

    As much as I like AS3, there are a lot of little things which make Willoughby go mad (and refer to himself in the third person).

    In AS2, I had a custom class that controlled the playhead, allowing me to play movie clips forward, backwards, skip frames, play to a certain frame, or whatever.

    I recreated this code in AS3, but if there are any movie clips animating inside of the movie being manipulated, they do not animate at all.

    I have created a little demonstration to show you what I mean. All the code does is move the playhead forward, and when it reaches the final frame, moves the playhead backwards.

    http://www.willoughbyweb.com/as3haet.html

    As you see in the AS3 one, Chunners doesn’t animate at all.

    Has anyone else run into this, or am I the only one who does this sort of thing?

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    can we see that fla please?
    lather yourself up with soap - soap arcade

  3. #3
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Quote Originally Posted by mr_malee
    can we see that fla please?
    Sure thing. All it is, is a bunch of frames in a movie clip and a tween on the stage. Nothing too special.

    EDIT: UPDATE TO HAVE BOTH FLAS IN THE ZIP...
    Attached Files Attached Files
    Last edited by WilloughbyJackson; 08-13-2008 at 09:06 PM.

  4. #4
    Now tell me whos watchin...... samvillian's Avatar
    Join Date
    Feb 2007
    Location
    Where do you live?
    Posts
    539
    that was the as2 version me thinks.
    If the only tool you have is a hammer, you tend to see every problem as a nail.

    Xbox 360 Modding Controller PS3 Mod Paint Spray LED Case

  5. #5
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Quote Originally Posted by samvillian
    that was the as2 version me thinks.
    Corrected with both.

    The code used in both is also show on the link I posted BTW...

  6. #6
    Wait- what now? tidenburg's Avatar
    Join Date
    Dec 2005
    Posts
    1,471
    I changed it to a graphic on a loop and it worked fine. But i'm guessing that would cause issues somewhere else along the line.
    "I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."

  7. #7
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    yeah, it seems that whenever a MovieClip enters a new frame (by means of code) it is reset. If you don't control the timeline through code, the child MovieClip's play properly, also, moving the object on its x axis work's as well.

    here's a simple function I created to deal with it:

    Code:
    var dir:Number = 1;
    
    function onEnterFrame(evt:Event) {
    		
    	this.gotoAndStop2(currentFrame + dir);
    
    	if (currentFrame == totalFrames){
    		
    		dir = -1;		
    	}
    	else if (currentFrame == 1){
    		
    		dir = 1;
    	}
    }
    
    MovieClip.prototype.gotoAndStop2 = function(frame:Object, scene:String = null):void {
    	
    	this.gotoAndStop(frame, scene);
    	
    	for(var i:int = 0; i < this.numChildren; i++){
    		
    		var child:MovieClip = this.getChildAt(i) as MovieClip;
    		
    		if(child != null){
    			
    			var frame:int = child.currentFrame >= child.totalFrames ? 1 : child.currentFrame + 1;
    			
    			child.gotoAndStop2(frame);
    		}
    	}
    }
    
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    of course you could use the Event.RENDER event on all your children and then on that eventHandler advance the child's frame. The MovieClip has changed quite significantly in AS3, I would try to avoid it or change the way you create your animations.

    I realise this is an example, but her movement could easily be replciated using an x coordinate.

    Code:
    stop()
    
    var dir:Number = 1;
    var index:int = 1;
    
    function onEnterFrame(evt:Event) {
    	
    	index += dir;
    	
    	chunners.x = (index / totalFrames) * stage.stageWidth
    		
    	//this.gotoAndStop2(currentFrame + dir);
    
    	if (index == totalFrames){
    		
    		dir = -1;		
    	}
    	else if (index == 1){
    		
    		dir = 1;
    	}
    }
    hope that helps
    lather yourself up with soap - soap arcade

  8. #8
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Thanks for the response, MM. I'll give it a shot.

    Although I realize this is an example her movement could easily be replicated using an x coordinate, most of the time when I use this code, there is some complex animation created by our graphic designer.

    Admittedly, there is always the animation/XML thing, but I'm not sure I want to deal with that every time I need to manipulate a complex animation.

  9. #9
    Junior Member
    Join Date
    Sep 2009
    Posts
    1

    Cool this piece of code might work for u . its simple and very short .

    // here u can control the animation in single frame .. hope this one will // // help u out .. happy coding


    var dir:Number = 8

    addEventListener(Event.ENTER_FRAME, animate)

    function animate (evt:Event) {
    chunners.x += dir;
    if ( chunners.x >= stage.stageWidth)
    {
    dir = -dir;
    } else if ( chunners.x <=0)
    {
    dir = -dir;
    }

    }
    Attached Files Attached Files

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