Hey KarmaKat well, generally you don't need to add listeners directly on buttons in a movieclip, because you can take advantage of even bubbling. basically this allow you to add a listener for button events at any point in the displaylist, and by default these events will be triggered by button events occuring further up the displaylist heirarchy.
in your case, doing menu_Tex.addEventListener(MouseEvent.MOUSE_DOWN, onHomeClick); will give you the same result as doing: menu_Tex.home.addEventListener(MouseEvent.MOUSE_DOWN, onHomeClick); obviously, having a listener at a higher point in the heriarchy will potentially mean receiving events from many diffferent buttons. in this case, you can insert a switch statement or similar in your event handler, to separate out the various buttons from their events hth! Rob On Sat, Aug 8, 2009 at 9:55 PM, KarmaKat <[email protected]> wrote: > > Hi All, > > I realize there are a few posts skirting around this issue but I am > still having some issues wrapping my mind around it. > > What I am trying to do: > Extend an embedded SWF with more actionscript so as to make buttons > work in a moviematerial. > > I have successfully embedded a movie material that retains its > actionscript, and made this work ( without extending it), but only if > the swf is self contained. > > > Some people say that code gets stripped when you embed rather than > load a SWF in Flex, which is true in some instances, but not all. I > find it works fine IF you embed a SWF file as a whole, not just a > symbol within it. > > Such as: > > > [Embed(source="/menu.swf")] > public static const MenuClass:Class; > public static const menu_SWFAsset:MovieClipAsset = new MenuClass(); > public static const menu_Tex:MovieMaterial = new MovieMaterial > (menu_SWFAsset); > > > However... I have more actionscript for the buttons that must be > activated outside of the flash publishing of this swf to avoid > conflicts that happen when a swf imports stuff that also tells it to > embed itself through extension, among other things. > > So... > > 1. I have menu.swf, it has a button in it on the stage called home. > > 2. I publish the menu.swf with no document class speciified. > > 3. It gets embedded as above. > > > How do i access the instance of home? I realize this maybe a scope > issue or just my lack of understanding of classes and targetting and > extending... any help would be appreciated dearly! > > In flex I tried to create a package and class like this: > > > public class Menu extends flash.display.MovieClip > { > > public var home:Button; > > public function Menu() > { > > home.addEventListener(MouseEvent.MOUSE_DOWN, onHomeClick); > > private function onHomeClick(event:MouseEvent) : void > { > trace("home clicked"); > > > return; > }// end function > > } > > > > > Unfortunately, nothing happens when I click on the button... Any > ideas? -- Rob Bateman Flash Development & Consultancy [email protected] www.infiniteturtles.co.uk www.away3d.com
