Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

trace() function not running

Explorer ,
May 16, 2013 May 16, 2013

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.

TOPICS
ActionScript
960
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 16, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 16, 2013 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);

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2013 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 16, 2013 May 16, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 16, 2013 May 16, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines