0
votes

Okay, so I'm building a small game in AS3, and I have a lot of helper functions, so I've created Helper.as, just to clean it up.

Now, my problem is that I'm not allowed to access these functions. Here is what I have so far.

Helper.as

//
public static function colorTransformer(obj, color)
{
   var colorTransform:ColorTransform = new ColorTransform();
   colorTransform.color = color;
   obj.transform.colorTransform = colorTransform;
}

And calling the function in Main.as

import Helpers;

Helpers.colorTransformer(myObj, myColorVar);

ERRORS:

Helpers.as, Line 24 1046: Type was not found or was not a compile-time constant: ColorTransform. Helpers.as, Line 24 1180: Call to a possibly undefined method ColorTransform.

1
No error message, no answer possible. - laurent
Sorry, forgot. I've added the errors - Jeppe Strøm
Maybe you must import the flash.geom.ColorTransform package in Helper.as - AsTheWormTurns
Please check your question for consistency. You list 'Helper.as' and then 'import Helpers'. Please check that everything is correct. - Sam DeHaan
@Sam DeHaan: there's no need for the .as suffix. Moreover, if that class is in the same folder there's no need for the import too. - AsTheWormTurns

1 Answers

0
votes

Your Class in which You are imported Healper class like this:

package  
{
import Healper;
import flash.display.MovieClip;

public class Main extends MovieClip      
{
    public function Main() 
    {
        Healper.colorTransformer(stage,0x00000);
    }
}   
}

and your Healper.as should be like this:

package  {
import flash.geom.ColorTransform;

public class Healper {

    public function Healper() 
    {
        // constructor code
    }

    public static function colorTransformer(obj, color)
    {
       var colorTransform:ColorTransform = new ColorTransform();
       colorTransform.color = color;
       obj.transform.colorTransform = colorTransform;
    }
}   
}