# Can't get my child

**URL:** <https://forum.kirupa.com/t/cant-get-my-child/247258>\
**Category:** Uncategorized\
**Created:** [December 20, 2007, 3:25am UTC](https://forum.kirupa.com/t/cant-get-my-child/247258 "2007-12-20T03:25:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![notSoMuch](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@notSoMuch](https://forum.kirupa.com/u/notSoMuch)\
**Post date:** [December 20, 2007, 3:25am UTC](https://forum.kirupa.com/t/cant-get-my-child/247258/1 "2007-12-20T03:25:31Z")

</div>

well, I’ve got an xml file that loads photos/thumbnails. This is contained in an external.as file, and is working well. The problem is that my fla contains menus with movieclip buttons that used to animate on rollover.

I took all of the code out of the fla, because I read that it will cause conflicts. SO, how do I access those animated buttons, tell them when to stop or play from the external file without a hundred error messages? Am I missing something obvious?

menu buttons are: itemTwo, itemThree are placed in a MC titled: bioClip

DocumentOne is the .as file

I was using hitTestPoint to check to see it they should play or not. anyway, here is the code:

package {  
import flash.display.DisplayObjectContainer;  
import flash.display.SimpleButton;  
import flash.display.LoaderInfo;  
import flash.display.MovieClip;  
import flash.display.Loader;  
import flash.display.Sprite;  
import flash.events.MouseEvent;  
import flash.events.Event;  
import flash.net.URLLoader;  
import flash.net.URLRequest;  
import fl.transitions.easing.\*;  
import fl.transitions.Tween;  
import fl.controls.ProgressBar;  
public class DocumentOne extends Sprite {  
private var \_xml:XML;  
private var \_currentImage:int=0,\_currentThumb:int=0,\_numThumbs:int;  
private var \_loader:Loader = new Loader();  
private var \_progressBar=new ProgressBar();  
private var \_thumbArray:Array=new Array();  
private var \_tweenY:Tween;  
private var \_oldTweenY:Number, \_thumbHeight:Number;  
private var \_thumbContainer:Sprite=new Sprite(),\_thumbContainerMask:Sprite=new Sprite();  
public function DocumentOne() {  
this.\_tweenY=new Tween(\_thumbContainer,“y”,Back.easeOut,0,0,0,true);  
this.\_tweenY.stop();  
\_thumbHeight=getChildByName(“bar”).height; // / 4;  
\_thumbHeight=47;  
\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderCompleteEvent);  
//\_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO\_ERROR, ioErrorHandler);  
\_progressBar.source=\_loader.contentLoaderInfo;  
\_progressBar.setSize(200,10);  
\_progressBar.setStyle(“barPadding”,2);  
\_progressBar.x=(stage.stageWidth - \_progressBar.width)/2 + 17;  
\_progressBar.y=(stage.stageHeight - \_progressBar.height) \* 9 / 10;  
addChild(\_progressBar);  
bar.buttonMode = true;  
\_thumbContainerMask.graphics.beginFill(0);  
\_thumbContainerMask.graphics.lineTo(getChildByName(“bar”).width,0);  
\_thumbContainerMask.graphics.lineTo(getChildByName(“bar”).width,getChildByName(“bar”).height);  
\_thumbContainerMask.graphics.lineTo(0,getChildByName(“bar”).height);  
\_thumbContainerMask.graphics.endFill();  
\_thumbContainer.mask=\_thumbContainerMask;  
getChildByName(“bar”).addEventListener(MouseEvent.MOUSE\_MOVE,scroll) ;  
(getChildByName(“bar”) as DisplayObjectContainer).addChild(\_thumbContainer);  
(getChildByName(“bar”) as DisplayObjectContainer).addChild(\_thumbContainerMask);  
(getChildByName(“box”) as DisplayObjectContainer).addChild(\_loader);  
getChildByName(“prev\_btn”).addEventListener(MouseEvent.CLICK, onPrevButtonClickEvent);  
getChildByName(“next\_btn”).addEventListener(MouseEvent.CLICK, onNextButtonClickEvent);  
var xmlLoader:URLLoader = new URLLoader();  
xmlLoader.addEventListener(Event.COMPLETE, onImagesXMLLoadComplete);  
xmlLoader.load(new URLRequest(“images4.xml”));  
portClip.stop();  
portClip.buttonMode = false;  
portClip.addEventListener(Event.ENTER\_FRAME, everyFrame);  
portClip.addEventListener(Event.ENTER\_FRAME, menuStop);  
bioClip.stop();  
bioClip.buttonMode = false;  
bioClip.addEventListener(Event.ENTER\_FRAME, everyFrame1);  
bioClip.addEventListener(Event.ENTER\_FRAME, menuStop1);  
//var itemTwo:MovieClip = new MovieClip(); --------------NONE OF THIS WORKED, SO I COMMENTED IT-----------  
//(getChildByName(“stage.bioClip”) as DisplayObjectContainer).addChild(itemTwo);

```
        //itemTwo.gotoAndStop(1);
        //stage.bioClip.itemTwo.buttonMode = true;
        //itemTwo.addEventListener(Event.ENTER_FRAME, everyFrameBio2);
        //itemTwo.addEventListener(Event.ENTER_FRAME, menuStopBio2);
        //itemTwo.addEventListener(Event.ENTER_FRAME, resetBio2);

```

// portClip CODE TO MOVE ON MOUSEOVER------------------------  
function everyFrame(event:Event):void  
{  
if (portClip.hitTestPoint(mouseX, mouseY, true))  
{  
portClip.play();  
}  
else  
{  
portClip.prevFrame();  
}  
}

// portClip CODE TO STOP MENU AT 20 FRAMES------------------  
function menuStop(event:Event):void  
{  
if (portClip.currentFrame == 20)  
{  
portClip.gotoAndStop(20);  
}  
}  
// bioClip CODE TO MOVE ON MOUSEOVER------------------------  
function everyFrame1(event:Event):void  
{  
if (bioClip.hitTestPoint(mouseX, mouseY, true))  
{  
bioClip.play();  
}  
else  
{  
bioClip.prevFrame();  
}  
}

// bioClip CODE TO STOP MENU AT 20 FRAMES------------------  
function menuStop1(event:Event):void  
{  
if (bioClip.currentFrame == 20)  
{  
bioClip.gotoAndStop(20);  
}  
}

// itemTwo CODE TO MOVE ON MOUSEOVER------------------------  
function everyFrameBio2(event:Event):void  
{  
if (itemTwo.hitTestPoint(mouseX, mouseY, true))  
{  
itemTwo.play();  
}  
else  
{  
itemTwo.prevFrame();  
}  
}

// itemTwo CODE TO STOP MENU AT 20 FRAMES------------------  
function menuStopBio2(event:Event):void  
{  
if (itemTwo.currentFrame == 20)  
{  
itemTwo.gotoAndPlay(1);  
}  
}

// itemTwo CODE TO MOVE ON MOUSEOVER------------------------  
function resetBio2(event:Event):void  
{  
if (bioClip.currentFrame == 1)  
{  
itemTwo.gotoAndStop(1);  
}

}

//---------------------------NOW THE PRIVATE FUNCTIONS FOR LOADING XML IMAGES------------------------------------  
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
}  
private function get currentImage():int {  
return \_currentImage;  
}  
private function set currentImage(number:int):void {  
\_currentImage=number\<0?\_xml.photos.length()-1:number\>\_xml.photos.length()-1?0:number;  
}  
private function onImagesXMLLoadComplete(event:Event):void {  
try {  
\_xml = new XML(event.target.data);  
\_loader.load(new URLRequest(\_xml.photos[currentImage].large.toString()));  
\_numThumbs=\_xml.photos.length();  
for (var i:uint=0;i\<\_numThumbs;i++) {  
\_thumbArray\*=new Loader();  
\_thumbArray\*.y=i \* \_thumbHeight;  
\_thumbArray\*.addEventListener(MouseEvent.CLICK,loadImage);  
\_thumbArray\*.name=i;  
\_thumbContainer.addChild(\_thumbArray\*);  
}  
loadNextThumb();  
} catch (error:TypeError) {  
trace(error.message);  
}  
}  
private function loadImage(event:MouseEvent):void {  
currentImage=event.target.name;  
\_loader.load(new URLRequest(\_xml.photos[currentImage].large.toString()));  
new Tween(\_progressBar,“alpha”,Bounce.easeOut,\_progressBar.alpha,1,2,true);  
}  
private function loadNextThumb():void {  
\_thumbArray[\_currentThumb].contentLoaderInfo.addEventListener(Event.COMPLETE, onThumbCompleteEvent);  
//\_thumbArray[\_currentThumb].contentLoaderInfo.addEventListener(IOErrorEvent.IO\_ERROR, ioErrorHandler);  
\_thumbArray[\_currentThumb].load(new URLRequest(\_xml.photos[\_currentThumb].small.toString()));  
}  
private function onThumbCompleteEvent(event:Event):void {  
event.target.removeEventListener(Event.COMPLETE, onThumbCompleteEvent);  
[//event.target.removeEventListener](https://event.target.removeEventListener)(IOErrorEvent.IO\_ERROR, ioErrorHandler);  
[//event.target.content.width=getChildByName](https://event.target.content.width=getChildByName)(“bar”).width;  
event.target.content.width=57;  
event.target.content.height=\_thumbHeight - 10;  
if (++\_currentThumb\<\_numThumbs) loadNextThumb();  
}  
private function onLoaderCompleteEvent(event:Event):void {  
event.target.content.width=getChildByName(“box”).width;  
event.target.content.height=getChildByName(“box”).height;  
new Tween(\_progressBar,“alpha”,Bounce.easeOut,\_progressBar.alpha,0,2,true);  
}  
private function onPrevButtonClickEvent(event:Event):void {  
–currentImage;  
\_loader.load(new URLRequest(\_xml.photos[currentImage].large.toString()));  
new Tween(\_progressBar,“alpha”,Bounce.easeOut,\_progressBar.alpha,1,2,true);  
}  
private function onNextButtonClickEvent(event:Event):void {  
++currentImage;  
\_loader.load(new URLRequest(\_xml.photos[currentImage].large.toString()));  
new Tween(\_progressBar,“alpha”,Bounce.easeOut,\_progressBar.alpha,1,2,true);  
}  
private function scroll(event:MouseEvent) {  
var newTweenY:Number=(\_thumbContainer.height - \_thumbContainerMask.height) \* Math.floor(-getChildByName(“bar”).mouseY / \_thumbContainerMask.height \* \_numThumbs / 1.5 + 1)/(\_numThumbs / 1.5 - 1);  
if (this.\_oldTweenY!=newTweenY) {  
this.\_oldTweenY=newTweenY;  
this.\_tweenY.continueTo(newTweenY,Math.abs(this.\_tweenY.position - newTweenY) / (\_numThumbs \* 9));  
}  
}  
}  
}

Sorry about the huge mess. Any ideas?
