PDA

View Full Version : Why doesn't Flex Builder 3 see that my Flash IDE asset has children?


brianemsu
08-03-2009, 07:39 PM
I'm having a bit of trouble understanding why I keep getting a little red 'x' error in Flex Builder saying that my MovieClip asset doesn't contain a property that I know it has in Flash... here's an example:

In Flash, I have a MovieClip named "MyMC" with a linked class for Flex Builder. It has a child of type "MyArrow", with an instance name of "myArrow". In Flex Builder, I can access the myArrow property of MyMC just fine when I compile but there is always an "Error 1120: access of undefined property myArrow" in the problems panel. I have set Flash publish setting to export SWC file and Flex Builder is seeing that, it's just not seeing some things like this... How can I make this error go away?
Thanks!

-b

Flash Gordon
08-03-2009, 08:35 PM
can you attach a stripped down sample of what you mean? Are you compiling in Flex or Flash?

Peter Cowling
08-03-2009, 09:25 PM
Undefined means either just that or incorrectly defined. Not really the best error message, but than quite a few...lack.

Reading this:


It has a child of type "MyArrow", with an instance name of "myArrow". In Flex Builder, I can access the myArrow property of MyMC just fine when I compile but there is always an "Error 1120: access of undefined property myArrow"


You state MyArrow, and then go onto cite myArrow. Possibly the source of the issue, but if not, as Flash Gordon states, some code is really needed.

brianemsu
08-03-2009, 09:38 PM
edit: ( compiling in Flash )

In Flash, I have a movieClip of type "MyMC". I have enabled the 'export for actionscript' functionality for this asset, I have created an external class by the name "MyMC" and have opened the class file in Flex Builder.

In Flash, I have created another movieClip of type "Button" and added it as a child of "MyMC". I have set the instance name of the child to "myButton".

In Flex Builder, I have something like this:

package
{
public class Main extends MovieClip
{
public var mc:MyMC;

public function Main()
{
mc = new MyMC();
mc.myButton.x = 100; // this line causes error 1119: access of
// possibly undefined property myButton
// through a reference with static type MyMC
}
}
}

I'm also getting errors from the MyMC class file like this:

package
{
public class MyMC extends MovieClip
{
public function MyMC()
{
this.addEventListener( MouseEvent.MOUSE_OVER, onMouseOverEvent );
}

private function onMouseOverEvent( e:MouseEvent ):void
{
this.myButton.play(); // causes an error 1120: access of
// undefined property myButton.
}
}
}


The application compiles fine and there are no actual problems, it's just that Flex Builder doesn't see that there is an automatically declared variable ( myButton ) inside of MyMC, thus problems are shown in the problems panel.

I am guessing that this might be remedied by turning off the "auto declare stage instances" setting in Flash and manually declaring the myButton property in MyMC class. The only problem with that is there are a lot of other properties that have been auto declared that I would have to go back and write and that would be a lot of extra work... I just want the Flex Builder error to go away. any ideas?

brianemsu
08-03-2009, 10:13 PM
agh! Nevermind, I feel stupid... I just added the line:

public var myButton:MyButton;

to the MyMC class and it works fine now... thanks.

brianemsu
08-03-2009, 11:33 PM
Thanks for moving this... I'm always in the Actionscript section and forgot there was a Flex one below. I'll be sure to post here about these issues.
-b