Hi Guys,
Long time ago I’ve been creating some as 2.0 projects, all of them based on the code within the timeline.
I wanted to start learning as 3.0 based on classes rather on timeline but I find it confusing and difficult to understand introduction into the classes.
I can’t get to understand why the following example is not working :
I’ve got 3 files:
main.fla with main class “Main”
no code
Main.as
package
{
import flash.display.MovieClip;
import projectconfig.Configurator;
public class Main extends MovieClip
{
var projectConfigurator:Configurator;
public function Main():void
{
projectConfigurator = new Configurator();
[COLOR=#ff0000] trace(projectWidth);[/COLOR]
}
}
}
Configurator.as
package projectconfig
{
public class Configurator
{
var projectWidth:uint = 1200;
trace("Configurator loaded");
[COLOR=red] trace(projectWidth);[/COLOR]
}
}
Can anybody help me out how to use value of “projectWidth” from Configurator class in the Main class?
The [COLOR=red]code in red[/COLOR] doesn’t work and I can’t work it out why.
I’ve noticed that if I recode **Configurator.as **this way:
package projectconfig
{
public class Configurator
{
var projectWidth:uint = 1200;
trace("Configurator loaded");
[COLOR=blue]public function Configurator() {[/COLOR]
[COLOR=red] [/COLOR][COLOR=black]trace(projectWidth);[/COLOR]
[COLOR=blue] }
[/COLOR] }
}
[COLOR=blue]Changes in blue[/COLOR] - then the Configurator.as traces **projectWidth **value, but still I can’t use it in Main.as.
Thanks