|  | onPress doesn't work on image... |  | |
| | | AunStudio |  |
| Posted: Sat May 31, 2008 12:39 pm Post subject: onPress doesn't work on image... |  |
Hi there,
I am having a problem when trying to add an onPress handler to a JPG which is loaded into a movieclip. onPress doesn't work.
ActionScript Code:
for (i=0; i<ecards.length; i++) { var mc:MovieClip = attachMovie("recipient", "recipient"+i, i); mc.loadMovie("images/button.jpg"); mc.onPress = function(){ trace(this._name); } }
"recipient" is a 100x75 rectangle (same size as JPG). if I comment the line "mc.loadMovie("images/button.jpg");" it displays only the original mc and traces the name property, but when I load the image into it, it doesn't trace it anymore.
Any help would be appreciated. Thanks in advance! |
| |
| | | AunStudio |  |
| Posted: Sat May 31, 2008 1:10 pm Post subject: Re: onPress doesn't work on image... |  |
I got a solution from Ali Inhan at Actionscript.org:
for (i = 0; i < ecards.length; i++) { var mcl:MovieClipLoader = new MovieClipLoader(); var listener:Object = new Object(); mcl.addListener(listener); listener.onLoadInit = function(m:MovieClip) { m.onPress = function() { trace(this._name); } } var mc:MovieClip = attachMovie("recipient", "recipient" + i, i); mcl.loadClip("images/button.jpg", mc); } |
| |
|
|