A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Tweening error

  1. #1
    Member
    Join Date
    Nov 2009
    Posts
    33

    Tweening error

    Hey... I'm having some trouble wit a tween in my movie...

    What I want the tween to do is that when it's finished, repeat the loop in the opposite direction.

    As far as I can see, this should work, although when I try it I get this error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at AnotherMazeGame_fla::MainTimeline/Tween8aHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.transitions::Tween/set time()
    at fl.transitions::Tween/nextFrame()
    at fl.transitions::Tween/onEnterFrame()

    Can anyone help?

    Code:
    var tween8a:Tween=new Tween(motion8a_mov, "x", Regular.easeInOut, 67.3, 480.3, 168, false);
    var tween8b:Tween=new Tween(motion8b_mov, "x", Regular.easeInOut, 480.3, 67.3, 168, false);
    
    tween8a.addEventListener(fl.transitions.TweenEvent.MOTION_FINISH, Tween8aHandler);
    tween8b.addEventListener(fl.transitions.TweenEvent.MOTION_FINISH, Tween8bHandler);
    
    function Tween8aHandler(e:fl.transitions.TweenEvent):void{
    	if(motion8a_mov.x<=67.3){
    		tween8a.start();
    	}
    	else if(motion8a_mov.x>=480.3){
    		tween8a.yoyo();
    	}
    }
    function Tween8bHandler(e:fl.transitions.TweenEvent):void{
    	if(motion8b_mov.x>=480.3){
    		tween8b.start();
    	}
    	else if(motion8b_mov.x<=67.3){
    		tween8b.yoyo();
    	}
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    This should work, if motion8a_mov is not null.
    PHP Code:
    import fl.transitions.*;
    import fl.transitions.easing.*;

    var 
    tween8a:Tween = new Tween(motion8a_mov,"x",Regular.easeInOut,67.3,480.3,168,false);
    var 
    tween8b:Tween = new Tween(motion8b_mov,"x",Regular.easeInOut,480.3,67.3,168,false);

    tween8a.addEventListener (TweenEvent.MOTION_FINISHTween8aHandler);
    tween8b.addEventListener (TweenEvent.MOTION_FINISHTween8bHandler);

    function 
    Tween8aHandler (e:TweenEvent):void
    {
        if (
    motion8a_mov.<= 67.3)
        {
            
    tween8a.start ();
        }
        else if (
    motion8a_mov.x>=480.3)
        {
            
    tween8a.yoyo ();
        }
    }
    function 
    Tween8bHandler (e:TweenEvent):void
    {
        if (
    motion8b_mov.>= 480.3)
        {
            
    tween8b.start ();
        }
        else if (
    motion8b_mov.x<=67.3)
        {
            
    tween8b.yoyo ();
        }

    Import all classes only once.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Nov 2009
    Posts
    33
    I've tried that code but I get the same error...

    What happens in the movie is the tween plays once, then reverses, but then instead of replaying the tween, it jumps to reversing again, and continues to reverse instead of going back and forth.

    The actual error pops up when the movie goes back to the first frame of the movie (this script is at fram 96).

    It's possible that it isn't as much tween error as I thought.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    It works for me but only when tested in one frame. Do you have a script in frame 1?
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Member
    Join Date
    Nov 2009
    Posts
    33
    no, the script is at frame 96...

Tags for this Thread

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