A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: I´m having an #1009 error

  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    55

    I´m having an #1009 error

    Hi there

    I have this error in my project:

    TypeError: Error #1009: Cannot access a property or method of a null object reference
    at com.greensock::TweenLite/init()
    at com.greensock::TweenLite/renderTime()
    at com.greensock.core::SimpleTimeline/renderTime()
    at com.greensock::TweenLite$/updateAll()

    This is my code


    Code:
    package {
    	
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
    	import flash.events.*;
    	
    	public class Painel extends MovieClip
    	{
    		public function Painel():void
    		{
    			setupClips();
    			addEventListener(Event.ENTER_FRAME, loop);
    		}
    		
    		private function setupClips():void
    		{
    			var len:int = con2.numChildren;
    			
    			for(var i:int=0; i<len; i++)
    			{
    				var mc:MovieClip = MovieClip(con2.getChildAt(i));
    				mc.buttonMode = true;
    				mc.loc = [mc.x, mc.y];
    				mc.addEventListener(MouseEvent.ROLL_OVER, onOver);
    				mc.addEventListener(MouseEvent.ROLL_OUT, onOut);
    				mc.addEventListener(MouseEvent.CLICK, onClick);
    				
    			}
    		}
    		
    		
    		private function onOver(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc.enlarge, 0.2, {
    												 alpha:1
    												 });
    								}
    		
    		
    		
    		private function onOut(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc, 0.2, {
    												 alpha:0
    												 });
    								}
    								
    								
    								
    		private function onClick(e:MouseEvent):void
    								{
    									
    								}
    								
    								
    		
    		private function loop(e:Event):void
    		{
    			var distx:Number = mouseX / 650;
    			var disty:Number = mouseY / 450;
    			TweenLite.to(con2, 2, { 
    						rotationY:(-70 +(140*distx)), 
    						rotationX:(70 -(140*disty)),
    						ease:Expo.easeOut 
    						 });
    		}
    	}
    }
    I have 5 movieclips inside the con2 movieclip and i´ve tried to instance them before but it didn´t work. When i load my SWF when i hover the mouse over each MC flash gives this error and the MC disappear.

    I´m a newbie with flash,please help me with this. Thanks very much.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    They don't have an enlarge property/child. Or at least, not on the frame they are on when the function is called.

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    55
    5TonsofFlax thanks very much fro your help.

    I didn´t put the movie clip "enlarge" on the stage.

  4. #4
    Member
    Join Date
    Jan 2008
    Posts
    55
    ALright i´m still a long way out from completing my project.

    If you see in my code i´ve made the movieclips rotating when the mouse hovers the stage.

    I´m following this tutorial http://www.gotoandlearn.com/play.php?id=103 and i want to have the same effect but with the style from this website from bbc:

    http://www.bbc.co.uk/switch/meta4orce/launch.shtml

    When i press the movieclip container2 i want it to open the container3 that is on frame 10 but when i do that the container2 stops rotating and just stays static.

    Here´s the code:

    Code:
    package {
    	
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
    	import flash.events.*;
    	
    	public class Painel extends MovieClip
    	
    	{
    		private var inFocus:MovieClip;
    		
    		public function Painel():void
    		{
    			setupClips();
    			addEventListener(Event.ENTER_FRAME, loop);
    		}
    		
    		private function setupClips():void
    		{
    			var len:int = con2.numChildren;
    			
    			for(var i:int=0; i<len; i++)
    			{
    				var mc:MovieClip = MovieClip(con2.getChildAt(i));
    				mc.buttonMode = true;
    				mc.loc = [mc.x, mc.y];
    				mc.addEventListener(MouseEvent.ROLL_OVER, onOver);
    				mc.addEventListener(MouseEvent.ROLL_OUT, onOut);
    				mc.addEventListener(MouseEvent.CLICK, onClick);
    				
    			}
    		}
    		
    		
    		private function onOver(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc.enlarge, 0.2, {
    												 alpha:1
    												 });
    								}
    		
    		
    		
    		private function onOut(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc.enlarge, 0.2, {
    												 alpha:0
    												 });
    								}
    								
    								
    								
    		private function onClick(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									
    									if(inFocus == null)
    									{
    										gotoAndPlay(10);
    									}
    								}
    								
    								
    		
    		private function loop(e:Event):void
    		{
    			var distx:Number = mouseX / 650;
    			var disty:Number = mouseY / 450;
    			TweenLite.to(con2, 2, { 
    						rotationY:(-70 +(140*distx)), 
    						rotationX:(70 -(140*disty)),
    						ease:Expo.easeOut 
    						 });
    		}
    	}
    }
    How can i keep both rotating even on frame 10?

  5. #5
    Member
    Join Date
    Jan 2008
    Posts
    55
    Afterall the problem is different. I will be more accurate and describe you that con2 is the Menu movieclip and the con3 is the EPisodes part just like in BBC´s meta4orce website.

    The problem now is that the Menu stay static when i start the SWF and only moves after i click it.
    I also get the #1009 error Cannot access a property or method of a null object reference
    at com.greensock::TweenLite/init()
    at com.greensock::TweenLite/renderTime()
    at com.greensock.core::SimpleTimeline/renderTime()
    at com.greensock::TweenLite$/updateAll()

    Here´s the code:

    Code:
    package {
    	
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
    	import flash.events.*;
    	
    	public class Painel2 extends MovieClip
    	
    	{
    		private var inFocus:MovieClip;
    		
    		public function Painel2():void
    		{
    			setupClips();
    			addEventListener(Event.ENTER_FRAME, loop);
    		}
    		
    		private function setupClips():void
    		{
    			var len:int = con2.numChildren;
    			
    			for(var i:int=0; i<len; i++)
    			{
    				var mc:MovieClip = MovieClip(con2.getChildAt(i));
    				mc.buttonMode = true;
    				mc.loc = [mc.x, mc.y];
    				mc.addEventListener(MouseEvent.ROLL_OVER, onOver);
    				mc.addEventListener(MouseEvent.ROLL_OUT, onOut);
    				mc.addEventListener(MouseEvent.CLICK, onClick);
    				
    			}
    		}
    		
    		
    		private function onOver(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc.enlarge, 0.2, {
    												 alpha:1
    												 });
    								}
    		
    		
    		
    		private function onOut(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									TweenLite.to(mc.enlarge, 0.2, {
    												 alpha:0
    												 });
    								}
    								
    								
    								
    		private function onClick(e:MouseEvent):void
    								{
    									var mc:MovieClip = MovieClip(e.currentTarget);
    									
    									if(inFocus == null)
    									{
    										gotoAndPlay(2);
    									}
    								}
    								
    								
    		
    		private function loop(e:Event):void
    		{
    			var distx:Number = mouseX / 650;
    			var disty:Number = mouseY / 450;
    			TweenLite.to(con2, 2, { 
    						rotationY:(-70 +(140*distx)), 
    						rotationX:(70 -(140*disty)),
    						ease:Expo.easeOut 
    						 });
    			
    			TweenLite.to(con3, 2, { 
    						rotationY:(-70 +(140*distx)), 
    						rotationX:(70 -(140*disty)),
    						ease:Expo.easeOut 
    						 });
    			
    		}
    	}
    }

  6. #6
    Member
    Join Date
    Jan 2008
    Posts
    55
    ok i´ve solved the error #1009 but i have another problem.

    How do i code so that the con3 display when i press the con2 movieclip?

  7. #7
    Member
    Join Date
    Jan 2008
    Posts
    55
    Ok i´ve solved this problem also.

    I had to put con3.visible = false; in the setupClips(); fucntion and then con3.visible = true; in the onClick(); function.

    Now i have inside the con3 movieclip other movieclips that i want to transform in links to videos a bit similar to BBC`s website. The user presses the movieclip and then a video displays somewhere on the stage. I´m used to code using animations in the timeline but coding to use objects in the 1st frame is new to me.

    I would appreciate your help or else i will feel like i´m speaking alone

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I don't know what you're asking. To get a video to show when the user clicks, just hook up the function which shows/loads the video to a MOUSE_CLICK listener on the instance you want to act as the button.

    Also, please use ' rather than ´. For some reason, ´ shows as chinese characters in the gmail notification messages.

  9. #9
    Member
    Join Date
    Jan 2008
    Posts
    55
    Quote Originally Posted by 5TonsOfFlax View Post
    I don't know what you're asking. To get a video to show when the user clicks, just hook up the function which shows/loads the video to a MOUSE_CLICK listener on the instance you want to act as the button.

    Also, please use ' rather than ´. For some reason, ´ shows as chinese characters in the gmail notification messages.
    Imagine that you have inside the con3 movieclip another movieclip called con3.video1.
    This movieclip will be clicked so that a video display's.

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