Functions in a class

Ok, I have found defining classes in .as files can be very
useful for me. I have a few functions that are being called over
and over again in different movies. There is what I want / need to
do in order to stream line the creating and updating of the flash
site. I want to see if I can put those same functions into a class
(.as file) so I can access them from anywhere in the flash movie.
The problem is when I just try to copy and paste the functions to
the .as file (func.as) and then call the function by,
func.FunctionName I get errors. The movie is calling the functions
when buttons are pressed. Any ideas? I will attach some functions I
am using that I would like to move to the func.as file.

OK........ Couple of things I see....
func.as
package{
public class func{ // This is the name of your class and as
such, it needs a constructor.....
public function func() {
// Doesn't need to do anything
Your import should be inside your package but outside the
class definition
You need to import your package into your Flash shell before
you can call the BackToMenu funciton (this is the real reason for
the error).
If you get an error about not being able to nest packages,
you'll need to adjust things
package com.mysite.common {
the above line will assume that you have folders relative to
your flash shell of the same names.....
com \ mysite \ common \ func.as
If this doesn't make sense, just let me know. We'll get it
straightened out.

Similar Messages

  • How to load function from derived class from dll

    Dear all,
    how to access extra function from derived class.
    for Example
    //==========================MyIShape.h
    class CMyIShape
    public:
    CMyIShape(){};
    virtual ~CMyIShape(){};
    virtual void Fn_DrawMe(){};
    // =========== this is ShapRectangle.dll
    //==========================ShapRectangle .h
    #include "MyIShape.h"
    class DLL_API ShapRectangle :public CMyIShape
    public:
    ShapRectangle(){};
    virtual ~ShapRectangle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_ChangeMe(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapRectangle();
    // return the created function
    return m_Obj;
    // =========== this is ShapCircle .dll
    //==========================ShapCircle .h
    #include "MyIShape.h"
    class DLL_API ShapCircle :public CMyIShape
    public:
    ShapCircle(){};
    virtual ~ShapCircle(){};
    virtual void Fn_DrawMe(){/*something here */};
    virtual void Fn_GetRadious(){/*something here */};
    __declspec (dllexport) CMyIShape* CreateShape()
    // call the constructor of the actual implementation
    CMyIShape * m_Obj = new ShapCircle();
    // return the created function
    return m_Obj;
    in exe there is no include header of of ShapCircle and ShapRectangle 
    and from the exe i use LoadLibrary and GetProcAddress .
    typedef CMyIShape* (*CREATE_OBJECT) ();
    CMyIShape*xCls ;
    //===================== from ShapeCircle.Dll
    pReg=  (CREATE_OBJECT)GetProcAddress (hInst ,"CreateShape");
    xCls = pReg();
    now xCls give all access of base class. but how to get pointer of funciton Fn_GetRadious() or how to get access.
    thanks in advance.

    could you please tell me in detail. why so. or any reference for it. i love to read.
    i don't know this is bad way.. but how? i would like to know.
    I indicated in the second sentence. Classes can be implemented differently by different compilers. For example, the alignment of member variables may differ. Also there is the pitfall that a class may be allocated within the DLL but deallocated in the client
    code. But the allocation/deallocation algorithms may differ across different compilers, and certainly between DEBUG and RELEASE mode. This means that you must ensure that if the DLL is compiled in Visual Studio 2010 / Debug mode, that the client code is also
    compiled in Visual Studio 2010 / Debug mode. Otherwise your program will be subject to mysterious crashes.
    is there any other way to archive same goal?
    Of course. DLL functionality should be exposed as a set of functions that accept and return POD data types. "POD" means "plain-ole-data" such as long, wchar_t*, bool, etc. Don't pass pointers to classes. 
    Obviously classes can be implemented within the DLL but they should be kept completely contained within the DLL. You might, for example, expose a function to allocate a class internally to the DLL and another function that can be called by the client code
    to free the class. And of course you can define other functions that can be used by the client code to indirectly call the class's methods.
    and why i need to give header file of ShapCircle and shapRectangle class, even i am not using in exe too. i though it is enough to give only MyIShape.h so with this any one can make new object.
    Indeed you don't have to, if you only want to call the public properties and methods that are defined within MyIShape.h.

  • Calling a function in another class that is not the App delegate nor a sngl

    Hi all-
    OK- I have searched and read and searched, however I cannot figure out an easy way to call a function in another class if that class is not the app delegate (I have that down) nor a singleton (done that also- but too much code)
    If you use the method Rick posted:
    MainView *myMainView = [[MainView alloc] init];
    [MyMainView goTell];
    That works, however myMainView is a second instance of the class MainView- I want to talk to the instance/Class already instantiated.
    Is there a way to do that without making the class a singleton?
    Thanks!

    I had some trouble wrapping my head around this stuff at first too.
    I've gotten pretty good at letting my objects communicate with one another, however I don't think my method is the most efficient or organized way but I'll try to explain the basic idea.
    When you want a class to be able to talk to another class that's initialized elsewhere, the class your making should just have a pointer in it to the class you want to communicate with. Then at some point (during your init function for example) you should set the pointer to the class you're trying to message.
    for example in the app-delegate assume you have an instance of a MainView class
    and the app-delegate also makes an instance of a class called WorkClass
    If you want WorkClass to know about MainView just give it a pointer of MainView and set it when it's instantiated.
    So WorkClass might be defined something like this
    //WorkClass.h
    @import "MainView.h"
    @interface WorkClass : NSObject
    MainView *myPointerToTheMainView;
    @property (retain) myPointerToTheMainView;
    -(void)tellMainViewHello;
    @end
    //WorkClass.m
    @import "WorkClass.h"
    @implementation WorkClass
    @synthesize myPointerToTheMainView;//this makes getter and setter functions for
    //the pointer and allows us to use the dot
    //syntax to refrence it.
    -(void)tellMainViewHello
    [myPointerToTheMainView hello]; //sends a message to the main view
    //assume the class MainView has defined a
    //method -(void)hello
    @end
    now somewhere in the app delegate you would make the WorkClass instance and pass it a reference to the MainView class so that WorkClass would be able to call it's say hello method, and have the method go where you want (to the single instance of MainView owned by the app-delegate)
    ex:
    //somewhere in app-delegate's initialization
    //assume MainView *theMainView exists and is instantiated.
    WorkClass *myWorkClass = [[WorkClass alloc] init];
    myWorkClass.myPointerToTheMainView = theMainView; //now myWorkClass can speak with
    // the main view through it's
    // reference to it
    I hope that gets the basic idea across.
    I'm pretty new to Obj-c myself so if I made any mistakes or if anyone has a better way to go about this please feel free to add
    Message was edited by: kodafox

  • Calling a function inside another class

    I have the following two classes and can't seem to figure to figure out how to call a function in the top one from the bottom one. The top one get instantiated on the root timeline. The bottom one gets instantiated from the top one. How do I call functions between the classes. Also, what if I had another call instantiated in top one and wanted to call a function in the bottom class from the second class?
    Thanks a lot for any help!!!
    package
         import flash.display.MovieClip;
         public class ThumbGridMain extends MovieClip
              private var grid:CreateGrid;
              public function ThumbGridMain():void
                   grid = new CreateGrid();
              public function testFunc():void
                   trace("testFunc was called");
    package
         import flash.display.MovieClip;
         public class CreateGrid extends MovieClip
              public function CreateGrid():void
                   parent.testFunc();

    kglad,
    Although I agree that utilizing events the way you attempted in your suggestion is better for at least a reason of eliminating dependency on parent, still you code doesn't not accomplish what Brian needs.
    Merely adding event listener to grid instance does nothing - there is no mechanism in the code that invokes callTGMFunction - thus event will not be dispatched. So, either callTGMFunction should be called on the instance (why use events - not direct call - in this case?), or grid instance needs to dispatch this event based on some internal logic ofCreateGrid AFTER it is instantiated - perhaps when it is either added to stage or added to display list via Event.ADDED. Without such a mechanism, how is it a superior correct way OOP?
    Also, in your code in ThumbGridMain class testFunc is missing parameter that it expects - Event.
    Am I missing something?
    I guess the code may be (it still looks more cumbersome and less elegant than direct function call):
    package
         import flash.display.MovieClip;
         import flash.events.Event;
         public class ThumbGridMain extends MovieClip
             private var grid:CreateGrid;
             public function ThumbGridMain():void
                 grid = new CreateGrid();
                 grid.addEventListener("callTGMFunction", testFunc);
                 addChild(grid);
            // to call a CreateGrid function named cgFunction()
             public function callCG(){
                 grid.cgFunction();
             public function testFunc(e:Event):void
                 trace("testFunc was called");
    package
         import flash.display.MovieClip;
         import flash.events.Event;
         import flash.events.Event;
         public class CreateGrid extends MovieClip
             public function CreateGrid():void
                 if (stage) init();
                 else addEventListener(Event.ADDED, callTGMFunction);
             // to call a TGM function
             public function callTGMFunction(e:Event = null):void
               // I forgot this one
                removeEventListener(Event.ADDED, callTGMFunction);
                this.dispatchEvent(new Event("callTGMFunction"));
            public function cgFunction(){
                 trace("cg function called");
    I think this is a case of personal preference.
    With that said, it is definitely better if instance doesn't rely on the object it is instnatiated by - so, in this case, either parent should listen to event or call a function directly.

  • Binding function pointer to class member fnction

    Hi,
    I have created a function pointer to class nonstatic member function. But facing some compilation issue. Can someone help on this.
    #include "stdafx.h"
    #include "iostream"
    #include <functional>
    using namespace std;
    using namespace std::placeholders;
    class A
    public:
    void Fun(void* param, bool b){cout<<"Hi\n";}
    typedef void (A::*fptr)(void*,bool);
    int _tmain(int argc, _TCHAR* argv[])
    fptr obj;
    auto f = std::bind(&A::Fun, &obj,_1,_2);
    f(NULL,1);
    return 0;

    See some samples about std::bind and std::function
    http://en.cppreference.com/w/cpp/utility/functional/bind
    http://en.cppreference.com/w/cpp/utility/functional/function
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Call function inside running class

    Hey All,
    i have a two question in classes.
    1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
    is this doable ?
    2- What super() mean ?
    Thanks a lot.

    this is the default call, and when i call the method by this way its will run the default class function before call the method.
    here my example:
    i need to call checkboxes  function in ChannelsMain class without pass by the grey script.
    Note: the call_cb is working and the trace is working
    so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
    package com.link
         import fl.controls.CheckBox;
         import flash.events.*;
         public class ChannelsMain
              var cbLength:uint = Main.PV.channel_id.length;
              public function ChannelsMain()
                   // constructor code
                   for (var i:int = 0; i < cbLength; i++)
                        var cb:CheckBox = new CheckBox;
                        cb.name = Main.PV.channel_id[i];
                        cb.label = Main.PV.channel_name[i];
                        cb.x = 50;
                        cb.y = 50 + i * 30;
                        cb.addEventListener(Event.CHANGE,call_cb);
                        Main.MS.addChild(cb);
                        //call xml function
                        if(i == cbLength - 1)
                             new ChannelsXML();
              private function call_cb(evt:Event)
                   trace(evt.currentTarget.name,evt.currentTarget.selected);
              public function checkboxes(evt)
                   trace(evt);

  • Infocube via function module or classes

    hi
    Is there any function module or classes to extract key figure from an infocube based on selection criteria?
    thanks.

    Check the links :
    http://www.geocities.com/victorav15/sapr3/abapfun.html
    http://www.sapgenie.com/abap/functions.htm
    http://members.tripod.com/abap4/SAP_Functions.html

  • Table Link between Functional Location and Class

    Functional location has 'class' ( under section 'general data' in tab 'location'). Could anybody suggest the table name where I can get one to one mapping between the functional location and it's 'class'.
    I have put the functional location in KSSK-OBJEK   but when I am providing the functional location say 
    ?0100000000000838737 in this field of table KSSK, it is resulting no output. Could you please elaborate
    more or suggest something.
    Thanks,
    Hetal

    Hi Gurus
    I am also looking for same information.
    Would you please advise where to get this Internal Type?
    Also would you please advise what is the use of table KSSK in whole process?
    Thanks in advance
    Kris

  • Auto-complete not working on variables/functions within a class in FlashBuilder 4.5

    Hi all,
    I'm using Flash Builder 4.5 (not burrito), and I'm not getting auto-complete on variables or functions within the class I'm working in.  It will auto-complete classes, and even variables within another variable, but not a variable within that class.
    As an example, let's say I have a class with this var:
    private var myDate:Date = new Date();
    If I start typing myD, I can't get myDate to autocomplete.  But once I type myDate., I'll get auto-complete for all the variables/functions in the Date class.
    I've tried re-installing FlashBuilder and switching workspaces, but with no luck.
    Also tried creating a brand new test project, but it didn't work there either.
    Anyone have any ideas what might be wrong?
    Thanks!

    Hi,
    After you type "myD" If u press cntrl + space it should auto-complete to myDate. Please raise a bug in http://bugs.adobe.com/flex with the sample project as i am not able to reproduce.
    On the other hand if you were expecting code hint to show up as soon as you type "myD" (without pressing cntrl+space) , Please follow the below step.
    Go to Window -> Preferences -> Flash Builder -> Editor
    check the "use additional custom triggers" check box. Leave the keys as default value .
    That should work for you .

  • Documentation of Function Modules and Class Methods

    Hi
        I would like to know the function modules that handle the documentation of function modules and class methods.Is it possible to assign the same documentation of a function module to a method as method documentation?
        Are these documentations stored in some system tables?
    Thanks in advance,
    Hema

    The documentation text is stored as Standard text.
    you can see these details in the function module->
    goto->documentation->
    you will now see a screen, there GOTO->HEADER.
    YOU will see a screen with the below details.
    Text Name       Z0MM_SCM_FNC_EVCOR_DELIVERY
    Language        EN
    Text ID         FU   Function module
    Text object     DOKU       Online Documentation
    in this case TEXT NAME = FUNCTION MODULE NAME.
    These details are stored in STXH &STXL . But you can use select from these tables. you have to use READ_TEXT to read the documentation to the program.
    regards
    srikanth

  • Can Access Outside Dll's Friend Functions On Own Class

    Can Access Outside Dll's Friend Functions On Own Class?
    For Example:
    System.Web.Util's SecUtility ?SecUtility is : internal static class SecUtility

    See the answer by nobugz to this
    thread.

  • HashCode function in Object class.

    Hi! to all!
    I have got a confusion about hashCode function of Object class, which returns an integer.
    What is the real purpose of introducing this method in Object class.
    Please comment.

    hashCode() method of the object is intorduced for the benefit of collections like HashTables. Typically
    hashCode method should return distinct integers for distinct objects which are decided distinct based on
    equals method of the object. Though this is not mandatory , if distinct objects have distinct
    hashCodes, it will improve the performance of HashTables.A good distribution of hash codes will indeed help in the performance of a HashMap or Hashtable. However, by definition, hashcodes are not necessarily distinct for objects that are distinct based on equals. Two objects for which "equals" is true should have the same hashcode, but two objects which have the same hashcode don't have to have "equals" be true. There is a limited number of hashcodes (the range of int), but an unlimited number of objects. So, some objects will necessarily have the same hashcode. The pigeonhole principle describes this situation:
    http://en.wikipedia.org/wiki/Pigeonhole_principle

  • InitializeUpdate function of the class CardManager from com.ibm.jc

    Hi,
    I am currently trying to create an Applet loader for JavaCard and I am getting in trouble with the initializeUpdate function of the class CardManager. Bellow is the code I write to initialize the communication with the javacard/reader...
              //list all the readers with a card present
              readers = TerminalFactory.getDefault().terminals().list(State.CARD_PRESENT);     
              if(readers.isEmpty()){
                   return;
              //establish connection with the reader
              term = (PCSCJCTerminal)JCTerminal.getInstance("PCSC",readers.get(0).toString().substring(15));
              term.open();
              atr = new ATR(term.waitForCard(2000));
              //connect to card
              System.out.println("Getting card ...");
              card = new JCard(term,atr,2000);
              //select Cardmanager
              System.out.println("Selecting card manager ...");
              cardmanager = new CardManager(card, CardManager.daid);
              cardmanager.select();
              //setup keys
              byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
              cardmanager.setKey(new OPKey(1, 1, OPKey.DES_ECB, dfltKey));
              cardmanager.setKey(new OPKey(1, 2, OPKey.DES_ECB, dfltKey));
              cardmanager.setKey(new OPKey(1, 3, OPKey.DES_ECB, dfltKey));
              //authenticate to cardmanager
              System.out.println("Authenticate to card manager ...\n");
    *          cardmanager.initializeUpdate(1, 0,CardManager.SCP_01_05);*
              cardmanager.externalAuthenticate(OPApplet.APDU_CLR);
    When I am launching the program, everything goes well until the initializeUpdate function which throw the exeption:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/jc/CL3
         at com.ibm.jc.OPApplet.initializeUpdate(Unknown Source)
         at com.jnet.tools.LoadApplet.initConnection(LoadApplet.java:80)
         at com.jnet.tools.LoadApplet.load(LoadApplet.java:88)
         at com.jnet.benchmarks.ClientBenchs.runTest(ClientBenchs.java:636)
         at com.jnet.benchmarks.ClientBenchs.main(ClientBenchs.java:485)
    Caused by: java.lang.ClassNotFoundException: com.ibm.jc.CL3
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Since I am quiet new in Java, I don't know what this exception means. I think that all the parameters of the function are good since I am using the same when I load "manually" the Applets on the card with the same parameters and it works. My JRE is 1.6 (but I also tried in 1.5), and the JCOP tools version is 3.2.7.
    I also tried with a different card with a different AID and different SCP parameter but I always have the same error.
    Thank in advance for the future replier

    862087 wrote:
    Hi,
    I am currently trying to create an Applet loader for JavaCard and I am getting in trouble with the initializeUpdate function of the class CardManager. Bellow is the code I write to initialize the communication with the javacard/reader...
              //list all the readers with a card present
              readers = TerminalFactory.getDefault().terminals().list(State.CARD_PRESENT);     
              if(readers.isEmpty()){
                   return;
              //establish connection with the reader
              term = (PCSCJCTerminal)JCTerminal.getInstance("PCSC",readers.get(0).toString().substring(15));
              term.open();
              atr = new ATR(term.waitForCard(2000));
              //connect to card
              System.out.println("Getting card ...");
              card = new JCard(term,atr,2000);
              //select Cardmanager
              System.out.println("Selecting card manager ...");
              cardmanager = new CardManager(card, CardManager.daid);
              cardmanager.select();
              //setup keys
              byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
              cardmanager.setKey(new OPKey(1, 1, OPKey.DES_ECB, dfltKey));
              cardmanager.setKey(new OPKey(1, 2, OPKey.DES_ECB, dfltKey));
              cardmanager.setKey(new OPKey(1, 3, OPKey.DES_ECB, dfltKey));
              //authenticate to cardmanager
              System.out.println("Authenticate to card manager ...\n");
    *          cardmanager.initializeUpdate(1, 0,CardManager.SCP_01_05);*
              cardmanager.externalAuthenticate(OPApplet.APDU_CLR);When I am launching the program, everything goes well until the initializeUpdate function which throw the exeption:
    Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/jc/CL3
         at com.ibm.jc.OPApplet.initializeUpdate(Unknown Source)
         at com.jnet.tools.LoadApplet.initConnection(LoadApplet.java:80)
         at com.jnet.tools.LoadApplet.load(LoadApplet.java:88)
         at com.jnet.benchmarks.ClientBenchs.runTest(ClientBenchs.java:636)
         at com.jnet.benchmarks.ClientBenchs.main(ClientBenchs.java:485)
    Caused by: java.lang.ClassNotFoundException: com.ibm.jc.CL3
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)Since I am quiet new in Java, I don't know what this exception means. I think that all the parameters of the function are good since I am using the same when I load "manually" the Applets on the card with the same parameters and it works. My JRE is 1.6 (but I also tried in 1.5), and the JCOP tools version is 3.2.7.
    I also tried with a different card with a different AID and different SCP parameter but I always have the same error.
    Thank in advance for the future replierRepost with code tags

  • How to initialize a function in another class

    Hello,
    I have one class 'run.as'
    In this class i add an movieclip to the stage with it's own
    class.
    So in the constructor of run.as i have:
    _ElevatorDoors = new ElevatorDoors (200,200);
    _ElevatorDoors .name ="liftdeuren";
    addChild(_ElevatorDoors );
    Oke, that works.. the doors appear on the stage.
    In this run.as i also have a function that will open these
    doors.
    _ElevatorDoors.OpenCloseDoors();
    This is a function in the ElevatorDoors class. In this class
    i have an motionTween.
    And when the tween is finished i want to initialize a
    function in the run.as
    I don't know how to do that. I know if you extend the run.as
    class you could use super. and then the function.
    But the ElevatorDoors class has been extended to the
    MovieClip.
    Does anyone has a suggestion how to do this?
    Thanks in advance.

    I have 3 classes:
    run.as (main class)
    elevatorDoors.as (extends MovieClip)
    elevator.as (extends MovieClip)
    In the run.as i added the 2 classes (elevatorDoors.as and
    elevator) with addChild..
    From the run.as i can call functions from these classes.
    But when i want to call a function from the elevatorDoors.as
    to it's main class it works.
    And in the mainclass (run.as) i call a function in the
    elevator.as class.
    Altough i can call the function trough the mainclass i can't
    set the properties of the elevator.as movieclip.
    I don't know how to set it's properties.

  • Calling a function from another class - help!

    I realize that this is probably a basic thing for people who have been working with JavaFX for a while, but it is eluding me, and I have been working on it for over a week.
    I need to call a function that is in another class.  Here's the deal.  In EntryDisplayController.java, there are 2 possible passwords that can be accepted - one will give full access to the car, the second will limit functions on the car.  So when a password is entered and verified as to which one it is, I need to call a function in MainDisplayController.java to set a variable that will let the system know which password is being used - full or restricted.
    So in MainDisplayController.java I have this snippet to see
    public class MainDisplayController implements Initializable, ControlledScreen {
        ScreensController myController;
        public static char restrict;
         * Initializes the controller class.
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            // TODO
        public void setRestriction(){
            restrict = 0;
            restrictLabel.setText("RESTRICTED");
        public void clearRestriction(){
            restrict = 1;
            restrictLabel.setText("");
    And in EntryScreenDisplay.java I have this snippet:
    public class EntryDisplayController implements Initializable, ControlledScreen {
         @FXML
        private Label passwordLabel ;
        static String password = new String();
        static String pwd = new String("");
         ScreensController myController;
         private MainDisplayController controller2;
         * Initializes the controller class.
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            setPW(pwd);    // TODO
         @FXML
        private void goToMainDisplay(ActionEvent event){
            if(password.equals ("123456")){
              controller2.clearRestriction();
               myController.setScreen(ScreensFramework.MainDisplayID);
               pwd = "";
               password = "";
               setPW(pwd);
            else if(password.equals ("123457")){
               controller2.setRestriction();
                myController.setScreen(ScreensFramework.MainDisplayID);
               pwd = "";
               password = "";
               setPW(pwd);
            else{
                password = "";
                pwd = "";
                setPW(pwd);
    When I enter the restricted (or full) password, I get a long list of errors, ending with
    Caused by: java.lang.NullPointerException
      at velocesdisplay.EntryDisplayController.goToMainDisplay(EntryDisplayController.java:60)
    Line 60 is where "controller2.setRestriction(); is.
    As always, thanks for any help.
    Kind regards,
    David

    You never set the controller2 variable to anything, which is why you get a null pointer exception when you try to reference it.
    public static variables (and even singletons) are rarely a good idea as they introduce global state (sometimes they can be, but usually not).
    If a static recorder like this can only have a binary value, use a boolean, if it can have multiple values, use an enum.
    Some of the data sharing solutions in dependency injection - Passing Parameters JavaFX FXML - Stack Overflow might be more appropriate.
    I also created a small framework for roll based solutions in JavaFX which perhaps might be useful:
    http://stackoverflow.com/questions/19666982/is-there-a-way-to-implement-a-property-like-rendered-on-javafx
    https://gist.github.com/jewelsea/7229260
    It was just something I hacked together, so it's not a fully polished solution and you probably don't need something quite so complex.
    What you need is a model class shared between the components of your application.  Dependency injection frameworks such as afterburner.fx can help achieve this in a fairly simple to use way.
    If you don't want to go with a dependency injection framework, then you could use either a static singleton model class for your settings or pass the model class using the mechanism in defined in the passing parameters link I provided.  For a model class example, see the ClickCounter class from this example.   That example doesn't use FXML, but to put it together with the passing parameters solution, for your restriction model, you would have something like the following:
       private class Restricted {
         private final ReadOnlyBooleanWrapper restricted;
         public Restricted(boolen isRestricted) {
           restricted = new ReadOnlyBooleanWrapper(isRestricted);  
         public boolean isRestricted() {
           return restricted.get();
         public ReadOnlyBooleanProperty restrictedProperty() {
           return restricted.getReadOnlyProperty();
    Then in your EntryDisplayController you have:
    @FXML
    public void goToMainDisplay(ActionEvent event) {
         // determine the restriction model as per your original code...
         RestictionModel restrictionModel = new RestrictionModel(<appropriate value>);
      FXMLLoader loader = new FXMLLoader(
      getClass().getResource(
       "mainDisplay.fxml"
      Stage stage = new Stage(StageStyle.DECORATED);
      stage.setScene(
       new Scene(
         (Pane) loader.load()
      MainDisplayController controller =
        loader.<MainDisplayController>getController();
      controller.initRestrictionModel(restrictionModel);
      stage.show();
    class MainDisplayController() {
      @FXML private RestrictionModel restrictionModel;
      @FXML private RestrictLabel restrictLabel;
      public void initialize() {}
      // naming convention (if the restriction model should only be set once per controller, call the method init, otherwise call it set).
      public void initRestrictionModel(RestrictionModel restrictionModel) {
        this.restrictionModel = restrictionModel;
         // take some action based on the new restriction model, for example
        restrictLabel.textProperty.bind(
          restrictionModel.restrictedProperty().asString()
    If you have a centralized controller for your navigation and instantiation of your FXML (like in this small FXML navigation framework), then you can handle the setting of restrictions on new screens centrally within the framework at the point where it loads up FXML or navigates to a screen (it seems like you might already have something like this with your ScreensController class).
    If you do this kind of stuff a lot, then you would probably benefit from a move to a framework like afterburner.  If it is just a few times within your application, then perhaps something like the above outline will give you enough guidance to implement a custom solution.

Maybe you are looking for

  • Intercompany elimination at legal entity and profit centre level

    All, I have a question regarding intercompany elimination. As far as I understand, BPC can only hold one Interco dimension per application. If you want to perform an intercompany elimination for two dimensions which do not roll up into each other, tw

  • Problem in compiling with ant?

    Hi, I have problem with compiling using ant ..i have build file...and properly place directories....... C:/>ant build It's giving an error as "Exception in thread "main" java.lang.NoClassDefFoundError: build" can any one help me to solve this problem

  • My Powerbook G4 refuses to recognise it's battery.............

    My powerbook refuses to recognise that it has a battery installed. Naturally this happened just weeks after the extended warranty ran out! The battery icon on the top right side of the toolbar has a cross in it and yes, I have checked it with another

  • Google chrome install wont close when click the X

    google chrome install wont close when click the X . I dont know why but it is like the X is not there, ~I click in the X button and nothing happens in this browser, i am tlaking about the google site and the box in the uppper corner right,these happe

  • Faces Corkboard Sorting

    Is it possible to tell it to sort by last name (surname) instead of simply "By Name"? It would make finding specific people much easier (I know you can just go by their, well, face, but mentally, you'd know where to look if their last name starts wit