1 Reply Latest reply on Feb 10, 2012 7:24 AM by A. Patterson

    Old globals with new classes

    TheDollarBill Level 1

      Please forgive my ignorance:

      I'm porting some old illustrator sdk code into the illustrator cs5 sdk.  I plan on making this a hybrid plugin where the UI is built in flash builder.  I am using the FreeGrid sample as a model.


      My old code is based in the old "shell" model, where in there is a file called common.h which contains a the line "extern Globals *g;".

      I was able to keep use these globals to store some preferences for the life of the plug-in.


      Is there a way to achieve this using the new class model.  I tried to declare a public member variable in the FreeGridPlugin class called "selected".  Then I added a pointer to FreeGridPlugin instance as a member of the FreeGridDialogControler class.  But when I try to access the FreeGridPlugin methods from the FreeGridDialogControler methods I get the error "bool FreeGridPlugin::selected is private within this context".  I can't figure out what I'm doing wrong of if there's a better way to go about this, but really need to be able set edit some variables whether from the dialog controler and from elsewhere.  How can I have these variables persist, and not go away as instances of classes are created and deleted?


      Or am I just completely backwards on all this?

      Any help would be MUCH appreciated.  Thanks.

        • 1. Re: Old globals with new classes
          A. Patterson Level 4

          I know almost nothing about any of the Flash stuff, so take this with a grain of salt -- but if you're having trouble with things going away when the plugin reloads & unloads, have you tried making it persistent? I.e., make sure it never unloads? We avoid all that crap about the VTABLE fix and such by just making sure MAPublisher is in memory, all the time. You do that by doing this:


          SPAccessRef m_pluginAccess = 0;

          AIErr error = sSPAccess->AcquirePlugin(GetPluginRef(), &m_pluginAccess);


          (you can get the plugin ref in any message, so StartUp will have one)


          Just call


          AIErr error = sSPAccess->ReleasePlugin(m_pluginAccess);


          in the ShutdownPlugin message