Hello,
I have been using Flash Builder to write an actionscript class (hence stage instances aren’t being automatically declared) and have come across a problem with event propagation and nested movieclip targeting which is probably quite easy to solve but I’ve searched and searched and I am still struggling with it.
My simplified example is as follows:
On my stage I have two movieclips (folder1 and folder2) which are inside a movieclip (folder_group). In my class I have added eventlisteners to the folder_group and want to trace the name of the folder I hover over e.g. folder1.
package
{
import flash.display.*;
import flash.events.*;
public class Main extends MovieClip
{
public function Main()
{
var folder_group:MovieClip = new MovieClip();
var folder1:MovieClip = new MovieClip();
var folder2:MovieClip = new MovieClip();
addChild(folder_group);
folder_group.addChild(folder1);
folder_group.addChild(folder2);
folder_group.addEventListener(MouseEvent.MOUSE_OVER, $mouseover);
folder_group.addEventListener(MouseEvent.MOUSE_OUT, $mouseout);
}
private function $mouseover(evt:MouseEvent):void
{
evt.target.alpha = 0.5;
trace(evt.target.name);
}
private function $mouseout(evt:MouseEvent):void
{
evt.target.alpha = 1;
}
}
}
This works if I write it in Flash Professional and declare the stage instances automatically but in Flash Builder, which can’t do this, I get the following errors:
ReferenceError: Error #1056: Cannot create property folder_group on Main.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at Main()
Whether I use Sprite instead of MovieClip I still get the same #1056 error.
I must not be declaring the movieclips or adding them to the display list correctly. Does anyone have any suggestions?
I am extremely grateful for your help.
Cheers!