|
-
How to access a function from another AS file?
I need a bit of assistance in a game I’m making.
Basically I’ve got the ‘mysteryNumber’ inside the ‘init’ function working but I need functions in the other ActionScript files to access the ‘mysteryNumber’.
So basically I have a:
Main.as (with the mysteryNumber function)
function init():void
{
startMessage = "???";
mysteryNumber = Math.ceil(Math.random() * 1);
libPage.output_txt.text = startMessage;
}
LibPage.as (function that calls the mysteryNumber using an if/else statement)
public function get mysteryNumber()
{
if (1 == mysteryNumber)
{
libPage.output_txt.text = "Number 1";
}
This if statement will work if I put it inside the Main.as file but I will be needing it in several .as files.
I’m not sure whether I should be using getters/setters or an event dispatcher but I also don’t know much about how to use them.
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
|