A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Access of possibly undefined property... argh!!!!

Threaded View

  1. #1
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341

    Access of possibly undefined property... argh!!!!

    Hi!

    I have this simple piece of code below:

    Code:
    function createShapes():void
    {
    	var X:int=50;
    	var Y:int=55;
    	
    	for(var i:int=0;i<35;i++)
    	{
    		var shape:MovieClip = new numberBox_mc();
    		shape.x = X;
    		shape.y = Y;
    		shape.eatNumber.text = "";
    		shape.name = "shape"+i;
    		addChildAt(shape, i);
    		X+=60;
    		if (X == 410)
    		{
    			X=50;
    			Y+=60;
    		}
    	}
    }
    
    function feedShapes():void
    {
    	for(var i:int=0;i<35;i++)
    	{
    		var myshape:DisplayObject = getChildByName("shape"+i);
    		// error happens in the next line of code
    		myshape.eatNumber.text = String(i);
    	}
    }
    The compiler keep spiting out the following error message:
    1119: Access of possibly undefined property eatNumber through a reference with static type flash . display : DisplayObject .

    What really annoys me is the 'possibly' word within the message. It doesnt make any sense to me and sounds as if the compiler would be trying to guess things. Doesnt it at least seems to be obvious enough that this code will be ran against one or more mcs that will be created at run time - and therefore doesnt exist YET? What if I would be creating it totally from scratch, programatically????

    Anyway, how to turnaround this odd behavior?

    PS: Yes, I have the 'numberBox_mc' mc at the library!

    Last edited by yanmoura; 01-03-2010 at 11:24 AM.
    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

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