-
problem with onPress
Why does the onPress doesn't work here. How can i solve this problem.
thx for your help. greetings
code: for (j=0; j<rest; j++) {
_tl.attachMovie("thumb_mc", "thumb"+g, g+100);
d = eval("_tl.varReceiver.thumb"+g);
_tl["thumb"+g].loadMovie(d);
_tl["thumb"+g].onPress = function(){
trace("clicked");
}
_tl["thumb"+g]._x = x;
_tl["thumb"+g]._y = y;
g++;
x += 50;
}
-
Senior Member
Had to take out your loadMovie, I was getting errors, but the onPress worked for me....I dunno.
Adam
-
loadMovie takes a string argument. eval gives you a movieclip reference, rather than a string. This *might* get autoconverted to a string, but it's not a good way to set it up.
loadMovie replaces the original movie clip. In doing so, it erases the onPress method. Even though the call to loadMovie comes before the assignment to onPress, loadMovie takes a while to happen, and is completed after the assignment of onPress. Make in inner movie clip to call loadMovie on, and an outer clip to have the onPress method (should be a familiar pattern by now....)
-
Unknowable Donkey of Spong
You could replace this:
code: d = eval("_tl.varReceiver.thumb"+g);
with this:
code:
d=_tl.varReceiver["thumb"+g];
Putting the "thumb"+g into square brackets straight after an object name (notice no dot) forces flash to recognize it as a variable or object name and so it reacts accordingly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|