Skip navigation
Currently Being Moderated

Call Class Function from FLA

Aug 30, 2012 6:33 AM

This maybe simple but I have two as files and I want to call a function inside a class and I am not sure how to do this. EX I want to call the function Main() after I import the packages.  Can anyone help?

 

Package CODE:

package code

{

          import flash.display.Sprite;

          import flash.display.MovieClip;

 

 

          public class allActivities extends flash.display.Sprite

          {

                    public static var testGlobal:String = "testValue";

 

                    private function Main():void

                    {

                              trace("Initilize Global Variables");

                    }

 

 

          }

}

package code

{

          public class activityone

          {

                    private function Maintwo():void

                    {

                              trace("testGlobal " + allActivities.testGlobal);

                    }

          }

 

 

}

 

FLA CODE

import code.*;

 
Replies
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 30, 2012 6:49 AM   in reply to TheScarecrow

    1.  Main needs to be public

    2.  there needs to be a allActivities instance reference in your fla's main timeline if that's what you mean by calling from fla

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2012 6:50 AM   in reply to TheScarecrow

    If you want to be able to call the Main function from the fla you need to make it a public function.  Making it private means access to it is restricted to within the class. 

     

    After you straighten that out, in your fla file try creating an instance of the class and use that to call on the Main function...

     

    var aa:allActivities = new allActivities();

     

    aa.Main();

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2012 7:25 AM   in reply to TheScarecrow

    You're welcome

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 30, 2012 8:22 AM   in reply to TheScarecrow

    ditto, you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points