-
Senior Member
[RESOLVED] [F8] Guru's got one for ya...file.as class error
**Error** C:\LOCATION\ihsCode.as: Line 18: Instance variables cannot be accessed in static functions.
var newX:Number = GetNewX(mcArray[i]);
This is the error I'm getting. And I'm not sure how to solve it. This is located in an AS file. Please let me know if things are not set up correctly, as I'm relearning the syntax for AS (all I use now-a-days is C#).
Here is the code where the error happens:
Code:
public static function ShrinkNetwork(mc:MovieClip, mcArray:Array):Void
{
for (var i:Number = 0; i <= mcArray.length; i++)
{
if (mcArray[i] != mc)
{
var newX:Number = GetNewX(mcArray[i]);
var newY:Number = GetNewY(mcArray[i]);
}
}
}
private function GetNewX(mc:MovieClip):Number
{
var xRatio:Number;
var newOriginX:Number;
var newWidth:Number;
var ppX:Number;
var newX:Number;
xRatio = mc._x / Stage.width;
newOriginX = shrinkPercentage * Stage.width;
newWidth = Stage.width - newOriginX;
ppX = newWidth * xRatio;
newX = ppX + newOriginX;
return newX;
}
private function GetNewY(mc:MovieClip):Number
{
var yRatio:Number;
var newOriginY:Number;
var newHeight:Number;
var ppY:Number;
var newY:Number;
yRatio = mc._y / Stage.height;
newOriginY = shrinkPercentage * Stage.height;
newHeight = Stage.height - newOriginY;
ppY = newHeight * yRatio;
newY = ppY + newOriginY;
return newY;
}
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
Senior Member
your var**ble is being declared inside a function but the if statement is trying to use it ........its outside its scope move the var**bles outside the private function and heck maybe even move the if statement inside the public function.......I don't know if you can do that because I haven't tested it but moving your var**bles some place else will probably fix it i mean give it a try and tell me what happens.
-
Senior Member
I see what your saying, but that doesn't really address my problem. The problem is within the static function. If I set the function to just
Code:
public function ShrinkNetwork(mc:MovieClip, mcArray:Array):Void
Then it removes that error and gives me the error in my project stating that there is no static function called ShrinkNetwork(param1, param2); So I'm stuck between a rock and a hard place and not sure what to do.
Xero Patience Studios
Web Design
Software Development
Graphic/Logo Design
-
Senior Member
[RESOLVED] Guru's got one for ya...file.as class error
So something dumb was causing this big mess. I have been calling all my funct staticly, instead of creating a new object in my project. That's what I did, and it works fine.
Xero Patience Studios
Web Design
Software Development
Graphic/Logo 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|