Solved

Adding onRelease event to dynamically loaded images

Posted on 2009-06-30
1
464 Views
Last Modified: 2013-11-11
I have the following code where I'm trying to add an onRelease event to a dynamically created movieclip, but it's not working at all.  Any ideas what I'm missing please?
function test($parsedObject:Object):Void {
 

  	for (i = 0; i < 10; i++) {

		mcName = this.createEmptyMovieClip("square_mc"+i, this.getNextHighestDepth());

		mcName._x = 10;

		mcName._y = 1 + (i * 50);

		mcName.onRelease = function() {

			trace("FOO");

		}		

		mcName.loadMovie(partner[i].ICON_URL[0].value);

   	}

	

}

Open in new window

0
Comment
Question by:equentin
1 Comment
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
Comment Utility
You basically have to 'wait' until the image is fully loaded so that you can do anything with it such as making it to be 50% transparent or making it to be clickable...  You can either add in a loop to check if the file is fully loaded, or use MovieClipLoader.loadClip()/onLoadComplete instead of the loadMovie() function...

You might want to check on this page to learn more about the MovieClipLoader class if you are not familiar with it...
     http://www.actionscript.org/resources/articles/3/1/MovieClipLoaders-Part-1/Page1.html

CyanBlue
function test($parsedObject:Object):Void {

	myMCL = new MovieClipLoader();

	myListener = new Object();

	myListener.onLoadComplete = function(targetMC)

	{

		targetMC.onPress = function()

		{

			trace("FOO");

		}

	}

	myMCL.addListener(myListener);

	

	for (i = 0; i < 10; i++) {

		mcName = this.createEmptyMovieClip("square_mc"+i, this.getNextHighestDepth());

		mcName._x = 10;

		mcName._y = 1 + (i * 50);

		myMCL.loadClip(partner[i].ICON_URL[0].value, mcName);

	}

}

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now