Copy link to clipboard
Copied
So I have a project that I'm working on that is using TweenMax to animate - I want to add an on pressmove function -
So I add elements to the stage with the following code -
var myHomePage = new lib.homePage();
myHomePage.x = myHomePage.y = 0;
myHomePage.alpha = 0;
stage.addChild(myHomePage);
This allows me to animate via TweenMax like this
this.startMainMenu=function(){
TweenMax.to(myHomePage, 0.5, {alpha:1});
TweenMax.from(myHomePage, .5, {regY:384,regX:512,scaleX:2,scaleY:2, ease:Back.easeOut});
}
With "homePage" being a movieClip in the library with the linkage set to "homePage"
Animates in as expected - but now if I want to add a mouse event it doesn't recognize "myHomePage"
this.myhomePage.on("pressmove", function(evt){
if ((this.y < 161)&&(this.y > -41)){this.y = evt.stageY + this.offset.y;}
if (this.y >161.1) {this.y = 160;};
if (this.y ==162) {this.y = 160};
if (this.y <-41) {this.y = -40;};
if (this.y ==-41) {this.y = -40};
});
Returns an error that "Cannot read property 'on' of undefined"
I believe my challenge is that there is no "instance name" assigned to the movieClip - It doesn't actually live on a timeline - I am adding it to the stage via "stage.addChild(myHomePage);
Any help?
Copy link to clipboard
Copied
Hi TvDirector
I reckon in the third script section / line 01, try:
myhomePage.on("pressmove", function(evt){
without this.
Klaus