Skip to main content
Known Participant
April 24, 2008
Question

Access of possibly undefined property

  • April 24, 2008
  • 2 replies
  • 678 views
I'm sure this is just a rookie mistake, but I'm getting the following error:

1119: Access of possibly undefined property scaleX through a reference with static type Function.
It comes from the zoomCounty function at the bottom of the code:


// main county

package
{
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
import flash.display.Sprite;
import flash.utils.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;

var countyEndSize:Number = 2.5;
var countyEndPositionX:Number = 650;
var countyEndPositionY:Number = 220;

var framesForZoomIn:Number = 10;
var framesForZoomout:Number = 10;




public class County extends MovieClip // what extends means is that in addition to all the below properties and methods you're also
// adding the methods of movieclips
// County adds the properties of movieclips plus a mouseclick listener and a return of the name of the selected county?
{

// this event listener had to be within its own function to work
// this is a constructor
// this is a method too
// this is a constructor because its named after the class
public function County()
{
addEventListener(MouseEvent.CLICK , selectedCounty); // if the mouuse is clicked it calls the next function below which returns the name of the
// selected movieclip county.



}

// this is also a method
private function selectedCounty(event:MouseEvent):void
{
trace("County selected is " + this.Name()); // this calls upon the next function which gets the qualified class name of the movieclip
var currentCounty = this.Name();


}

// another method of course
// this function returns name of the county
public function Name()
{

return getQualifiedClassName(this); // puts the countie's name in the Name variable?

}

public function zoomCounty():void
{
{
var countyTweenZoomX:Tween = new Tween(selectedCounty, "scaleX", Regular.easeInOut, selectedCounty.scaleX , (selectedCounty.scaleX +countyEndSize), framesForZoomIn, false);
var countyTweenZoomY:Tween = new Tween(selectedCounty, "scaleY", Regular.easeInOut, selectedCounty.scaleY , (selectedCounty.scaleY +countyEndSize), framesForZoomIn, false);
var countyTweenPositionX:Tween = new Tween(selectedCounty, "x", Regular.easeInOut, selectedCounty.x , countyEndPositionX, framesForZoomIn, false);
var countyTweenPositionY:Tween = new Tween(selectedCounty, "y", Regular.easeInOut, selectedCounty.y , countyEndPositionY, framesForZoomIn, false);
/*var textTweenAlpha:Tween = new Tween(countyTextFieldBelo, "alpha", Regular.easeInOut, countyTextFieldBelo.alpha , 1, (framesForZoomIn +10), false);
addChild(countyTextFieldBelo);*/
}





}



}
}



This topic has been closed for replies.

2 replies

Inspiring
April 24, 2008
Vivaretro,
I am not a total actionscript master, but there are a few issues with the class I think, which after cleanup, should not generate errors. First, you should put the variable definitions after the Class declaration - after "public class County extends MovieClip {". Also, where does the variable "selectedCounty" get defined? Right now you have it as a function name, so the Tween is looking at how to get a .scaleX from the function, which is not going to work and is going to cause an error. I changed a few things in your code and am now able to compile it without errors, but I still get one when I click on the item that I assigned the Class to, which is another issue, since I don't know what other code lives in your application. At any rate, try out this.

- B
vivaretroAuthor
Known Participant
April 24, 2008
Thanks very much for your help! I'm going to give this a try. I probably should have mentioned that there is
also a flash IDE with all the state's counties in it as well as 34 as files 1 for each county that looks like this:

package
{


public class Clackamas extends County

{
// empty on purpose all it does is extend all the details of County to the Morrow MovieClip

}
}

the selectedCounty is defined the MouseEvent in the County function call
Inspiring
April 24, 2008
Viv,
Can you post the code that is generating this error?

- B
vivaretroAuthor
Known Participant
April 24, 2008
Sorry, thought I'd attached it. Here you go. Thanks for looking at it. The error comes from the
zoomCounty function at the bottom

// main county

package
{
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
import flash.display.Sprite;
import flash.utils.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;

var countyEndSize:Number = 2.5;
var countyEndPositionX:Number = 650;
var countyEndPositionY:Number = 220;

var framesForZoomIn:Number = 10;
var framesForZoomout:Number = 10;




public class County extends MovieClip // what extends means is that in addition to all the below properties and methods you're also
// adding the methods of movieclips
// County adds the properties of movieclips plus a mouseclick listener and a return of the name of the selected county?
{

// this event listener had to be within its own function to work
// this is a constructor
// this is a method too
// this is a constructor because its named after the class
public function County()
{
addEventListener(MouseEvent.CLICK , selectedCounty); // if the mouuse is clicked it calls the next function below which returns the name of the
// selected movieclip county.



}

// this is also a method
private function selectedCounty(event:MouseEvent):void
{
trace("County selected is " + this.Name()); // this calls upon the next function which gets the qualified class name of the movieclip
var currentCounty = this.Name();


}

// another method of course
// this function returns name of the county
public function Name()
{

return getQualifiedClassName(this); // puts the countie's name in the Name variable?

}

public function zoomCounty():void
{
{
var countyTweenZoomX:Tween = new Tween(selectedCounty, "scaleX", Regular.easeInOut, selectedCounty.scaleX , (selectedCounty.scaleX +countyEndSize), framesForZoomIn, false);
var countyTweenZoomY:Tween = new Tween(selectedCounty, "scaleY", Regular.easeInOut, selectedCounty.scaleY , (selectedCounty.scaleY +countyEndSize), framesForZoomIn, false);
var countyTweenPositionX:Tween = new Tween(selectedCounty, "x", Regular.easeInOut, selectedCounty.x , countyEndPositionX, framesForZoomIn, false);
var countyTweenPositionY:Tween = new Tween(selectedCounty, "y", Regular.easeInOut, selectedCounty.y , countyEndPositionY, framesForZoomIn, false);

}





}



}
}