Copy link to clipboard
Copied
These is a file im working with in a tutorial
VirtualZoo.as
package zoo {
trace("check");
public class VirtualZoo {
private var pet;
public function VirtualZoo ( ) {
this.pet = new VirtualPet("Stan");
var oldName = pet.getName();
pet.setName("Marcos");
var consume = pet.eat;
consume(300);
}
}
}
the other class is unimportant. When I run this in debug mode in flexBuilder I am not seeing my trace statement in the output. Any reason why? I have also tried putting the trace statement in the constructor and it still doesn't work.
Copy link to clipboard
Copied
I am surprised that even compiles to be honest However, the trace should definitely belong in the VirtualZoo constructor. If you don't see it you are probably not instantiating a VirtualZoo class and the problem is something other than the trace.
Copy link to clipboard
Copied
As I sent it to you it wouldn't compile. I didn't send the whole program. What happened first was I got an error saying "Afile found in a source-path must have the same package structure as the definition's package 'zoo.'" First I restarted my app. I placed all .as file here e:\VirtualZoo\src\zoo and I got this message : Application filesrc\VirtualZoo.as does not exist. Doesn't help if I move the VirtualZoo.as file up to the src folder, it just gives me the first alarm. I put the trace block in just to see if anything was happening at all.
Copy link to clipboard
Copied
Okay, if you want it to be in package zoo you need to make a folder called zoo under your /src/ dir and move it there. Otherwise just do this and don't define a package location:
package {
public class VirtualZoo {
private var pet;
public function VirtualZoo ( ) {
this.pet = new VirtualPet("Stan");
var oldName = pet.getName();
pet.setName("Marcos");
var consume = pet.eat;
consume(300);
}
}
}
Copy link to clipboard
Copied
I do have a folder /src/zoo where i put all the .as files. Trace still doesn''t run and I get this message : Application file src\VirtualZoo.as does not exist
Copy link to clipboard
Copied
Try reading this:
http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/packages.html
Also make sure you have this line:
import zoo.VirtualZoo;
At the top of any file that is trying to use this class if they aren't in the same zoo folder.
EDIT:
Also, you are not going to see any trace statements until your application compiles so that is the first step.
Copy link to clipboard
Copied
I don't understand why i need the import statement. All of the files are in the same folder and package. I tried to build it and then run in debug mode and just got a whole lot of errors. I have never had trouble like this with any other programming language.
Copy link to clipboard
Copied
It depends on how your project is setup. Unfortunately, with my limited visibility into how you are setup these are the best answers I can give you. As long as class B is in the same folder as class A you don't need import statements in class A for class B and vice versa. However, beyond that, you do.
If you can describe your project setup a bit more or even zip up your code if you are able I can give you further advice.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now