How to reference var from frame on timeline in an object class
Posted
by
brybam
on Stack Overflow
See other posts from Stack Overflow
or by brybam
Published on 2011-01-17T01:38:12Z
Indexed on
2011/01/17
2:53 UTC
Read the original article
Hit count: 218
I'm using Flash Professional cs5/AS3
I'll try and describe this the best I can. I'm new to ActionScript.
So, in my timeline I have a var on a frame that represents "lives" and i have some code in the timeline that takes down the number of lives depending on certain events, which all works great.
so, now i wanted to make a constructor class that I could reuse for a bunch of movie clip objects and I only want these objects to be able to move if the lives variable is greater than certain number. So now, building my constructor class for these objects i just wanted put an if statement that is looking to see if the lives are greater than a certain number, which if it is then should make these objects do what i want...But, when i run the project I get "1120: Access of undefined property lives." lives is the var I made obviously like I said, and it works fine being referenced everyone else except when I make a new .as file for these objects then try and reference it. I get the same error when I try and establish "lives" in the main project class too. I'm not sure where I should put this var or how I can make it so i can reference it from an object class.
I'm not really sure how to word or describe my issue which has made it hard to search for a tutorial. Any suggestions i'm sure this has to be a simple task.
© Stack Overflow or respective owner