-
Member Mofo
Basic AS3 question
Can anyone tell me why this isn't working?
I get this error when I use the button:
TypeError: Error #1010: A term is undefined and has no properties.
at MD_13_fla::MainTimeline/moveProjects()
at MethodInfo-197()
PHP Code:
function moveProjects() {
if(this.project.x == 598){
this.project.x = 2000;
}else{
this.project.x == 598;
}
}
projectsBtn.addEventListener(
MouseEvent.CLICK,
function(e:MouseEvent):void {
moveProjects();
}
);
-
in named functions, "this" refers to the timeline. so "this.project" needs to be a variable declared on the timeline; that error is saying that's not the case.
-
Member Mofo
Moagrius - thank you for the help.
I'm not sure I understand. I took "this." off and then got this error:
1120: Access of undefined property project.
"project" is a movie clip sitting on the stage.
-
put "this" back. it should work fine, except for this line
PHP Code:
function moveProjects() {
if(this.project.x == 598){
this.project.x = 2000;
}else{
// should be = not ==
this.project.x == 598;
}
}
-
Member Mofo
Moagrius - thank you again, I figured it out. I had to take off "this." and I stupidly called my mc "project" instead of it's real name "projects". Oops.
-
Senior Member
In AS3 you don't need to use "this", because objects are automatically referenced to the timeline or class.
- The right of the People to create Flash movies shall not be infringed. -
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
|