• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Calling a movieClip from Linkage in Library panel

Explorer ,
Dec 26, 2018 Dec 26, 2018

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?

Views

274

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 26, 2018 Dec 26, 2018

Copy link to clipboard

Copied

LATEST

Hi TvDirector

I reckon in the third script section / line 01, try:

     myhomePage.on("pressmove", function(evt){

without this.

Klaus

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines