?
Solved

Adding onRelease event to dynamically loaded images

Posted on 2009-06-30
1
Medium Priority
?
471 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 37

Accepted Solution

by:
CyanBlue earned 2000 total points
ID: 24747569
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 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