Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

onPress doesn't work on image...

 
Jump to:  
 
AunStudio
PostPosted: 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
PostPosted: 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);
}
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates

wyniki na żywo Filmiki Stwarzanie świata - Miłosz Czesław Armatura Łazienki Wii