0
votes

I am very new in AS3. I use FlashDevelop 4. I have no Adobe Flash, just FD (pure AS3) I have problems with classpath. I searched the database but I found nothing that could help me. So the problem is as follow.

I have the project "Testing" in C:\AS App\Testing with the file Main.as. I have, also, the folder C:\AS App\W_T. In this folder is the file write_text.as. The file Main.as looks like that:

package
{
import flash.display.*;
import flash.text.TextField;
import flash.events.*;
import W_T.write_text;
public class Main extends Sprite
{
    var t:TextField=new TextField();

    public function Main():void
    {
            stage.addChild(t);
            stage.addEventListener(MouseEvent.CLICK, write);
    }

    public function write(me:MouseEvent):void
    {
        var wt:W_T.write_text = new W_T.write_text();
            t.x = 100;
            t.y = 100;          
            t.text = wt.output();
    }
}
}

The file write_text.as looks like that:

package W_T
{
import flash.display.*;
import flash.text.TextField;
import flash.events.*;
import W_T.*;

public class write_text
{
    public function write_text()
    {
    }

    public function output():String 
    {
        var txt:String;

        txt = "From function !";
        return(txt);
    }
}
}

I make the appropriate specification in the global classpath. But I get the following errors:

Error: Type was not found or was not a compile-time constant: write_text. var wt:W_T.write_text = new W_T.write_text();

Error: Call to a possibly undefined method write_text. var wt:W_T.write_text = new W_T.write_text();

Definition W_T:write_text could not be found. import W_T.write_text;

Could you help me please to find where I have done wrong ?

Thank you.

EB

2

2 Answers

1
votes

The problem is the compiler isn't finding your write_text.as file. By default, it will be looking here:

C:\AS App\Testing\W_T\write_text.as

Try adjusting accordingly and see if it works. When you declare package W_T { } flash will look in a subfolder called W_T for a file with the same name as the public class.

When you declare just simply package { } with no name, it will look in the root of your class library path, which seems to be a folder called Testing if that's where your main.as file is living.

If you wanted to use a common folder for your class files (that isn't nested in an individual projects folder), you can tell flash develop where to find them by going to: project -> properties, then the Classpaths tab. By default flash develop will only look in folders relative to the project.

0
votes

The problem is that you haven't told the compiler (flex?) where to find the file. When you add it as classpath you only tell flash develop where to find the file, not the compiler.

First of all you have to check how you compile and secondly how you can change and add classpaths for your solution.u

I usually do this through ant script and a build.xml file and I can't unfortunately remember how the "pure as3"-projects are working in regards to compiling