Skip to main content
Known Participant
May 16, 2013
Question

trace() function not running

  • May 16, 2013
  • 3 replies
  • 988 views

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.

This topic has been closed for replies.

3 replies

jhlawleyAuthor
Known Participant
May 16, 2013

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.

Nabren
Inspiring
May 16, 2013

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.

jhlawleyAuthor
Known Participant
May 16, 2013

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.

Nabren
Inspiring
May 16, 2013

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);

        }

    }

}

jhlawleyAuthor
Known Participant
May 16, 2013

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

Nabren
Inspiring
May 16, 2013

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.