You must be logged in to post Login Register
Search 

How do I reference a movieclip instance from external AS3 class

User Post

10:40 am
November 21, 2010


pmcclory

New Member

posts 1

1

Hi, I've been searching around all afternoon, and am pulling my hair out! Any help would be most appreciated! I am very new to AS3 and so please forgive any stupid questions!!


1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.


2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)


Basically here is the bit of code I am trying implement within Hero.as :


if (myPlatform.hitTestPoint(x,y,true)) { // if a platform is hit

trace(“hitME”);

y–;

tGravity = 0; // reset

break;

}


Here's the error that I get:


1120: Access of undefined property myPlatform


This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1.


I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable? Is there a really easy way to do this with some syntax/command that I have not learned yet?


Thank you in advance :)

Topic RSS 
Search