searched whiled but I couldent find the answer here on Stack so I hope someone can help me.
I trying out Flash prof CS6 and Flashbuilder, I have created in Flash a Movieclip called square_mc and instantiated it with the name square.
I have linked a class file called Main.as to FLash builder, and in flash builder I write:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
public function Main()
{
super();
circle.addEventListener(MouseEvent.CLICK, onToolClick);
}
function onToolClick(event:MouseEvent):void{
trace("klickade på ontoolclick");
}
}
}
in Flash builder I get the warning "access of undefined property circle" But when I run it , it works like a charm.
Im guessing its just that Flashbuilder don't know that I already instantiated it with the name circle in Flash, and therefor gives the warning.
Is there a way I can make Flashbuilder understand that its there and working?
Option 1: To remedy this, I usually uncheck "Automatically Declare Stage Instance" in the ActionScript Settings (File > ActionScript Settings) in Flash CS6. Then in Flash Builder declare the MovieClip you have on the stage in Flash CS6 as such:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
public var circle:MovieClip; // manually declare circle
public function Main()
{
super();
circle.addEventListener(MouseEvent.CLICK, onToolClick);
}
function onToolClick(event:MouseEvent):void{
trace("klickade på ontoolclick");
}
}
}
Option 2: If you don't want to manually declare all the movies on the stage, option 2 is to create a reference to circle as a separate variable for Flash Builder:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
private var _circle:MovieClip;
public function Main()
{
super();
_circle = this.getChildByName( "circle" ) as MovieClip;
_circle.addEventListener(MouseEvent.CLICK, onToolClick);
}
function onToolClick(event:MouseEvent):void{
trace("klickade på ontoolclick");
}
}
}
This should stop Flash Builder from giving you the error message :)