Actionscript 3 Menu with dynamically loaded options and mouse overs

intasesa

New Member
working on (as the title states) a menu with dynamically loaded options with mouse overs. The chain of events as I see it (this could be flawed) is:?Use loop to place one empty MovieClip for each entry in the XML file, down a number of pixels each time. We will call these 'entries'.?Inside each entry add a textField (text from XML), draw a rectangle with alpha=0 (to be the highlight on mouseover), and add another movieclip from the library.?Add mouseover & mouseout eventListeners to each 'entry' which set the invisible rectangle to alpha=1, and change the color of the text and movieclip from library.Following is the function that initiates all of this. *edit: Fixed more really dumb stuff.\[code\]//Load List Optionsfunction loadHighlight():void{ var yTmp:Number = 0; for (var i:Number = 0; i < photo_total; i++) { var Highlight:MovieClip = new MovieClip(); photoHighlights = Highlight; photoHighlights.addEventListener(MouseEvent.MOUSE_OVER, highlightOvr); //Draw Invisible Rectangle var rectngle:Shape = new Shape(); rectngles = rectngle; rectngles.graphics.beginFill (0x0DAC54); rectngles.graphics.drawRect(0, 0, 1170, 144); rectngles.graphics.endFill(); rectngles.alpha = 0; rectngles.y=yTmp; rectngles.x= 0; photoHighlights.addChildAt(rectngles, 0); //Load photosArray var photoname = photo_data.@TEXT;; var photolist:TextField = new TextField(); photosArray = photolist; photosArray.textColor = 0x0DAC54; photosArray.x = 26.95; photosArray.y = 92.65; photosArray.embedFonts = true; photosArray.antiAliasType = AntiAliasType.ADVANCED; photosArray.defaultTextFormat = listformat; photosArray.selectable = false; photosArray.wordWrap = true; photosArray.text = photoname; photosArray.autoSize = TextFieldAutoSize.LEFT; photosArray.mouseEnabled = false; photoHighlights.addChildAt(photosArray, 1); //Load thumbFrames var thumbFrame:thmbFrame = new thmbFrame(); thumbFrame.x= 962; thumbFrame.y= 21; photoHighlights.addChildAt(thumbFrame, 1); thmbFrames.push(thmbFrame); MediaPage.photoSelect.photoList.addChild(photoHighlights); yTmp = yTmp + 153; }}function highlightOvr(event:MouseEvent):void{ event.target.rectngles.alpha=1; event.target.photosArray.textColor = 0x000000; event.target.thmbFrames.color = 0x000000; event.target.addEventListener(MouseEvent.MOUSE_OUT, highlightOut); }function highlightOut(event:MouseEvent):void{ event.target.rectngles.alpha = 0; event.target.photosArray.textColor = 0x0DAC54; event.target.thmbFrames.color = 0x0DAC54; event.target.removeEventListener(MouseEvent.MOUSE_OUT, highlightOut);}\[/code\]The issue now has become one of referring back to the children of the placed movieClips. I know this isn't right:\[code\]event.target.rectngles.alpha = 0;\[/code\]I just don't know what is. How do I refer to the generated movieClips and their children?I know there is a simple way to do this, but I don't know what it is.Also, it seems the way I'm doing this is a bit convoluted according to ShaunHusain's response. Any links to clearly worded resources explaining more efficient ways of accomplishing this are much appreciated.Thanks Once Again,-T.EDIT: Fixed some incredibly stupid stuff I did.
 
Back
Top