# Roll over on dynamic objetcs

**URL:** <https://forum.kirupa.com/t/roll-over-on-dynamic-objetcs/260995>\
**Category:** Uncategorized\
**Created:** [May 21, 2008, 9:37pm UTC](https://forum.kirupa.com/t/roll-over-on-dynamic-objetcs/260995 "2008-05-21T21:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nina\_bee\_hotmai](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@nina\_bee\_hotmai](https://forum.kirupa.com/u/nina_bee_hotmai)\
**Post date:** [May 21, 2008, 9:37pm UTC](https://forum.kirupa.com/t/roll-over-on-dynamic-objetcs/260995/1 "2008-05-21T21:37:15Z")

</div>

Hi!  
I made a flash animation in AS3 that loads images using an XML file. I added a tween (using AS3 too) and now I’d like to add a roll over effect on my movieClips.  
Here is the code :

```auto
function parse(myInput:XML):void{
	var imageURLliste:XMLList = myInput.item.image;
	for(var i:Number = 0; i< imageURLliste.length(); i++){
	//for each(var image_url:XML in imageURLliste){
		var vue:XML = imageURLliste*;
		trace (vue);
		
		var clipConteneur:MovieClip = new MovieClip();
		var conteneurImage:Loader = new Loader();
		var imageRequest:URLRequest = new URLRequest(vue);
		conteneurImage.load(imageRequest);
		clipConteneur.addChild(conteneurImage);
		conteneurImage.x = posX;
		conteneurImage.name = ("vue-"+i);
		trace(conteneurImage.name);
		conteneurImage.addEventListener(MouseEvent.ROLL_OVER, RollOver);
		posX +=500;
		this.addChild(clipConteneur);
		myArray.push(conteneurImage);
		var myTweenAlpha:Tween = new Tween(conteneurImage, "alpha", Strong.easeOut, 0, 0.5, 3, true);
		
	}
}

function RollOver(evt:MouseEvent){
	conteneurImage.alpha = 1;
}

```

but when I am actually on roll over any “conteneurImage”, nothing happens…  
Help ☹  
Thanks  
Bee

---

<div class="post-metadata">

**Author:** ![hoolagon](https://avatars.discourse-cdn.com/v4/letter/h/58956e/32.png) [@hoolagon](https://forum.kirupa.com/u/hoolagon)\
**Post date:** [May 21, 2008, 10:56pm UTC](https://forum.kirupa.com/t/roll-over-on-dynamic-objetcs/260995/2 "2008-05-21T22:56:24Z")

</div>

[quote=nina\_bee@hotmai;2329338]Hi!  
I made a flash animation in AS3 that loads images using an XML file. I added a tween (using AS3 too) and now I’d like to add a roll over effect on my movieClips.  
but when I am actually on roll over any “conteneurImage”, nothing happens…  
Help ☹  
Thanks  
Bee[/quote]

its late here so no time to check this code fully but something like this is what you need…

```php
function parse(myInput:XML):void{
    var imageURLliste:XMLList = myInput.item.image;
    for(var i:Number = 0; i< imageURLliste.length(); i++){
    //for each(var image_url:XML in imageURLliste){
        var vue:XML = imageURLliste*;
        trace (vue);
        
        var clipConteneur:MovieClip = new MovieClip();
        var conteneurImage:Loader = new Loader();
        var imageRequest:URLRequest = new URLRequest(vue);
        conteneurImage.load(imageRequest);
        conteneurImage.addEventListener(Event.COMPLETE, conteneurImageLoaded);
        clipConteneur.addChild(conteneurImage);
        conteneurImage.x = posX;
        conteneurImage.name = ("vue-"+i);
        trace(conteneurImage.name);
        
        posX +=500;
        this.addChild(clipConteneur);
        myArray.push(conteneurImage);
        
    }
}
function conteneurImageLoaded(event:Event)
{
    //dont add the event listener until after the image is loaded
    event.target.addEventListener(MouseEvent.ROLL_OVER, RollOver);
    // dont tween until after the image is loaded
    var myTweenAlpha:Tween = new Tween(conteneurImage, "alpha", Strong.easeOut, 0, 0.5, 3, true);
}
function RollOver(evt:MouseEvent){
    evt.target.alpha = 1;
}

```

---

<div class="post-metadata">

**Author:** ![nina\_bee\_hotmai](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@nina\_bee\_hotmai](https://forum.kirupa.com/u/nina_bee_hotmai)\
**Post date:** [May 22, 2008, 7:47am UTC](https://forum.kirupa.com/t/roll-over-on-dynamic-objetcs/260995/3 "2008-05-22T07:47:04Z")

</div>

Hi hoolagon,  
thanks for answearing.  
This helped me a lot =)  
here is the the code (maybe someone can use it too)

```auto

function parse(myInput:XML):void{
    var imageURLliste:XMLList = myInput.item.image;
    for(var i:Number = 0; i< imageURLliste.length(); i++){
    //for each(var image_url:XML in imageURLliste){
        var vue:XML = imageURLliste*;
        //trace (vue);
        var clipConteneur:MovieClip = new MovieClip();
        var conteneurImage:Loader = new Loader();
        var imageRequest:URLRequest = new URLRequest(vue);
        conteneurImage.load(imageRequest);
        clipConteneur.addChild(conteneurImage);
        conteneurImage.x = posX;
        /*conteneurImage.name = ("vue-"+i);
        trace(conteneurImage.name);*/
        conteneurImage.addEventListener(MouseEvent.ROLL_OVER, RollOver);
        posX +=500;
        this.addChild(clipConteneur);
        myArray.push(conteneurImage);
        addChild(myArray*);
        var myTweenAlpha:Tween = new Tween(conteneurImage, "alpha", Strong.easeOut, 0, 0.5, 3, true);
        
    }
}

function RollOver(evt:MouseEvent){
    evt.target.alpha = 1
}

```

I’ll try to make it a little better this is just “raw” but it works!!!  
thanks again

Bee
