Copy link to clipboard
Copied
Use alone “alert”,It can be run.
If use "on click", an error occurs.
Browser console.log "Uncaught SyntaxError: missing ) after argument list"
It should be an error caused by the name in "for"
But i don't know how to solve
var map1 = [{id:11}, {id:12}, {id:13},{id:14}, {id:15}, {id:16},{id:17}, {id:18}, {id:19}],jswz = 0
Object.prototype.myUcase = function() {
alert("map1" + this.id) //It can be run
this.on("click", function() {alert("map" + this.id)} ;//error, Unable to run
}
for(i = 0; i < map1.length; i++) {
//asa0 to asa8,This is a movie-clip on stage
exportRoot["asa" + i].id=map1[i].id
exportRoot["asa" + i]=map1[i]
exportRoot["asa" + i].myUcase()//Error,
}
Copy link to clipboard
Copied
you didn't close your "on" method and you have an extraneous right bracket. ie, you're missing a right paranthesis at the end of your shown code and you have mismatched brackets.
other than that, i can't determine what that's supposed to do even if it were syntactically correct.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
i'm not sure what you mean by that, but
map1 is properly defined without syntax error while dt has a syntax error (comma after last element).
Copy link to clipboard
Copied
Thank you very much for your answer
I found the cause of the problem.
exportRoot["asa" + i]=map1[i]
It is equivalent to replacing the movie clip with array elements.
This operation is not feasible.
Needs to be modified to:
map1[i]=exportRoot["asa" + i]
Replace array elements with movie clips.
Code can now be executed normally
var map1 = [{id:11}, {id:12}, {id:13},{id:14}, {id:15}, {id:16},{id:17}, {id:18},{id:19}],jswz = 0;
Object.prototype.myUcase = function() {
alert("map1" + this.id)
this.on("click", function() {alert("map" + this.id)})
}
for(i = 0; i < map1.length; i++) {
//asa0 to asa8,This is a movie-clip on stage
exportRoot["asa" + i].id=map1[i].id
map1[i]=exportRoot["asa" + i]
exportRoot["asa" + i].myUcase();
}
Copy link to clipboard
Copied
you're welcome.