Sharing functions between classes

I have Flash project that is set up something like this:
myProject.fla
- document class = myMenu.as
- the document class imports a menu item from menuItem.as
(import menuItem;)
I have a function in myMenu.as that sets the text formatting
for all the text fields on the page. I want to be able to use this
same function in menuItem.as so that all the formatting is
consistent & you only have to change it in one place. How do I
access this function from both myMenu.as & menuItem.as?
Thanks,

Create another class say Utility with this function as
public.
And create object of this class in both menuItem and myMenu
to use this function.
This is just a rough idea how you can do it. but ideally that
will depend on the class relationships/design patterns you are
using.

Similar Messages

  • Sharing SharedObjects between Classes

    I have created a varable of Shared Object inside the Document Class
         EXAMPLE -> var so:SharedObject = SharedObject.getLocal("Barns","/");
    but inside of a movieclip class I have
         if(so.data.adams == "yes"){
              adamsHighlight.visble = true}
    and I get an error
    E:\Android 2.0\ohioMap.as, Line 12
    1120: Access of undefined property so.
    what am i missing here. I thought if it was public, it is shared throughout the project
    sorry new to classes.

    it is but so is not defined in your movieclip class unless you use:
    var so:SharedObject=SharedObject.getLocal("Barns","/");
    now, the so in your document class and in your movieclip class reference the same object.  eg,
    //doc class
    so.data.testvar="hi";
    //movieclip class
    trace(so.data.testvar);  // should trace 'hi'

  • Sharing variables between classes

    Hi,
    I wrote a class to handle button functionality. I want the
    onPress event in this class to play a movieclip that is sitting in
    my .fla file, also access some boolean values in the .fla.
    What's the best way to implement this?

    Best practice is to avoid directly accessing non-static final fields of other classes - they should generally by private or if necessary protected.
    get/set methods are the usual way to do this. You can use public static final fields without having a getter.
    Static in the context of field definition identifies fields which exist at the class scope (1 copy per class) versus those (non-static) which exist at the instance scope (1 copy per instance of the class).
    If the value you want to share instance-speciifc, use a non-static field backed up by non-static get/set methods. If you want one copy per process, static fields with static get/set methods are best.
    Chuck

  • Call functions between classes

    Hi all,
    I have two java classes compiled into the DB in different schemas. How could I call the static method in classA from classB?
    I suppose I need to get the schema name in there somehow, or is it just as simple as classA.method(arg1)
    havent dared trying yet ;)

    You need to change the resolver of the referencing class to include the schema of the referenced class.
    When a class is created, whether directly by create java ddl or by loadjava it has an attribute known as a resolver which is essentially a search path for schemas to look in when resolving names referenced in the class. The resolver is a list of pairs of the form ((<pattern> <schema name>)(<pattern> <schema name>)...). When the class is resolved any name X that it references is bound to a class object by iterating over the resolver from left to right identifying each term in which the name of X matches the pattern and looking to see whether a class with the name of X exists in the schema identified by the term. If such a class exists, the search stops and the name X is bound to that class. If after looking at all the terms there is no class found, then a resolution error occurs. The pattern can either be an explicit name, or an explicit prefix followed by '*' or simply '*'. The latter is the usual pattern used, and matches any name. The default resolver given when a class is created without explicitly specifying an alternate resolver is ((* <current schema>)(* PUBLIC)). A class with this resolver will be able to resolve names in its own schema or in PUBLIC. In your case you want the referencing class to have a resolver like
    ((* <current schema>)(* <the other schema>)(* PUBLIC))
    or some variation on this. An alternate resolver can be specified in loadjava using the -resolver argument, or in create or alter java ddl using the
    resolver ((...)...) syntax. This is all documented in the java developers guide.

  • Flex sharing functions between mxml functions

    Problem is that I want to run a function from a different
    mxml file.
    Possible something stupid, but if somone can put me on the
    way...
    The solution is the use of
    parentDocument.
    mxml that calls the function:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="400" height="300">
    <mx:Form>
    <mx:FormItem label="Search" direction="horizontal">
    <mx:TextInput id="search" change="
    parentDocument.filterDemo()" />
    <mx:Button label="Clear Search" click="
    parentDocument.clearSearch()" />
    </mx:FormItem>
    </mx:Form>
    <mx:DataGrid dataProvider="{dataList}" width="400"
    height="400">
    <mx:columns>
    <mx:DataGridColumn headerText="Name" dataField="name"
    />
    <mx:DataGridColumn headerText="City" dataField="city"
    />
    </mx:columns>
    </mx:DataGrid>
    </mx:Canvas>
    page that stores the function:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical" xmlns:comp="components.*"
    creationComplete="initData()">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    [Bindable]
    private var dataList:ArrayCollection ;
    private function initData():void{
    dataList= new ArrayCollection([
    {name:"Kennedy Memorial Hospitals/UMC Stratford",
    city:"Stratford"},
    {name:"Kennedy Memorial Hospitals/UMC Washington Twp",
    city:"Turnersville"},
    {name:"Kessler Memorial Hospital", city:"Hammonton"},
    {name:"Saint Clares Hospital/Sussex", city:"Sussex"},
    public function filterDemo():void{
    dataList.filterFunction = searchDemo;
    dataList.refresh();
    private function searchDemo(item:Object):Boolean{
    var isMatch:Boolean = false
    var tevergelijken:String =
    weergave.search.text.toLowerCase();
    if(item.name.toLowerCase().search(tevergelijken) != -1){
    isMatch = true
    return isMatch;
    private function clearSearch():void{
    dataList.filterFunction = null;
    dataList.refresh();
    comp:weergave.search.text = '';
    ]]>
    </mx:Script>
    <mx:ViewStack id="bookPages" resizeToContent="true"
    x="118" y="185">
    <comp:weergave height="50%" width="50%" label="Weergave"
    id="weergave" />
    </mx:ViewStack>
    </mx:Application>

    If index is the main application, then it can be accessed via
    FlexGlobals.topLevelApplication in Flex 4.

  • Sharing Functions Across Applications(containers)

    Can anyone help with a final word on sharing functions between
    applications?
    I have read many conflicting accounts on the ability in 6i to share
    objects across application systems through the use of common functions,
    global process steps, referencing, or shortcuts. Best case scenario, I
    would like to share functions across containers, include these functions
    in multiple process models, and be able to create process flows between
    functions. Is this possible? Is the bug 1787721 which doesn't allow
    common functions across applications a true bug, or is this the new
    functionality in 6i?
    Thanks for the help.

    Hi Cynthia,
    If I understood, you want to know what the steps you need to
    follow to share a object, but before it, you need to know a
    basic new characteristc at the Designer6i.
    The basic characteristc that you must know is that you don't
    share objects to application from other one anymore, you create
    a reference to other objects in another Application from other
    one that already exists. Althoug you must pay attention that you
    can create references to objects between applications when they
    are in the same Workarea.
    It's too simple.
    Put the cursor on the Application that want to create reference
    from a previous existing object. Choose the option "Create
    Reference". Choose the object that you want to reference (Use
    the filter if you want) and than it will be work.
    I hope that I had to help you.
    Regards,
    Marcos Vinmcius B. Xavier
    E-mail : [email protected]

  • Sharing library between 2 IDs on same machine

    Hello.  I'm trying to figure out the most strategic way for my wife and me to share content without overlapping each other on our respective devices.  Here are our specifics:
    *  We each have separate Apple IDs and iPhones/iPads. 
    *  We share a single computer (laptop running Vista and latest iTunes) but have separate user accounts on it. 
    *  We select from the same pool of content on laptop (not sure if that means that we have separate libraries?), but must have distinct apps/music/other stuff (e.g. contacts) on each of our devices. 
    *  I recently added a network-accesible storage drive to hold all of our media content. 
    *  Ideally, we'd also like to be able to share our app purchases across our devices within the five-device license limit
    I'm ready to start moving our media content to the shared drive but am not sure what's the wisest way to proceed so that I'm not painted into a corner down the road.  For instance, since we maintain separate Apple IDs, does it make more sense to have separate libraries?  Or is it even possible to have a single library without having to share an Apple ID/password?  But when I move all content to the shared drive, would separate libraries result in two sets of files?  And I'm not 100% sure what role the home sharing function within iTunes should play here. 
    I'm sure that I'm making this more complicated than it needs to be, so I'm throwing myself to the experts who've been here before.  I want to ensure that I've got the best mix of shareability, device customization and lack of duplication.  Thanks much for your suggestions. 

    FWIW, check these support articles for pointers:
    How to use multiple iPods, iPads, or iPhones with one computer
    how to share music between different accounts on a single computer

  • Custom Events and Listeners between classes

    I've got a project I've been working on for weeks that I'm
    having yet another problem with. I'm trying to learn AS3 which is
    why it's taking so long but that's not important for this post.
    I wanted to create a custom event class so that I could make
    sure the event does not interfere with other "COMPLETE" events that
    are being passed between classes. In other words, I have a few
    things that need to complete prior to a function being called...
    one is some XML being loaded and another is a font loaded. So, I
    thought I would create a custom FontLoaded class that extends Event
    and make the type something like "FontLoadedEvent.LOADED". That way
    I could listen for the XML "Event.COMPLETE" and this font event
    also.
    Please tell me if I'm going down the wrong path here but I
    don't seem to be getting the dispatched event for my new custom
    event. Also, how does one detect if it's being dispatched other
    than if the eventListener is fired? Any other ways to test
    this?

    You can trace the event to see if it dispatched.
    Also, this is not a good case to create a new event. Custom
    events are used to store additional information. MouseEvent exists
    because Event doesn't have localX, localY, etc. properties. Since
    you don't seem to be throwing additional properties, you can use a
    regular event.
    trace(dispatchEvent(new Event("panelFontsLoaded"));
    addEventListener("panelFontsLoaded", onFontsLoaded);
    Static consts are used to help debug typos. The event type is
    just a string, often stored in a const.

  • Can home sharing function work in the same school wifi environment?

    Hi, there:
       I'm wondering can I use home sharing function on campus (same building, same school wifi) between two mac (mac mini & macbook pro)? I truned on both home sharing funciton using the same Apple ID, but it didn't work. Does it mean I cannot use this function in school? If it's workable, how should I do?

    That is really crappy. Oh well thank you

  • Calling Function across Classes

    How do I call a function across classes?
    I have a primary class ("ChordLib.as") that contains a function that manages options for TileList component, that includes prescribing a custom Cell Rendering class, "MyRenderer".  I want to be able to call a function in the primary "ChordLib.as" class from the "MyRenderer.as" class.  Here is the function in "ChordLib" that refers to the "MyRenderer" class. Perhaps there is a way here to pass reference of the primary class into "MyRenderer"?
    // SET CHORD LIST  //////////////////////////////////////////
    public function setChordList(song:int):void {
    var dpChords:DataProvider = new DataProvider();
    var i:uint;
    // determine chord set
    if (song == -1) {
         activeChords = allChords;
    } else {
         activeChords = songChordSets[song];
    // fill dataProvider
    for(i=0; i<activeChords.length; i++) {
         var tt = activeChords[i];
         dpChords.addItem({ label:tt, source:ChordBar, data:i, scaleContent:true }); 
    chordList.dataProvider = dpChords;
    chordList.columnWidth     = 70;
    chordList.rowHeight     = 30;
    chordList.direction = ScrollBarDirection.VERTICAL;
    chordList.setStyle("contentPadding", 5);
    chordList.setRendererStyle("imagePadding", 0);
    chordList.scrollPolicy  = ScrollPolicy.ON;
    // set style for labels
    chordList.setRendererStyle("textFormat", textFormat1);
    // set the background skin
    chordList.setStyle("skin", lightBackground);
    //set the cell renderer
    chordList.setStyle("cellRenderer", MyRenderer);
    This last line ("chordList.setStyle("cellRenderer", MyRenderer);") refers to this custom class, that includes some event listeners:
    package {
       import fl.controls.listClasses.ICellRenderer;
       import fl.controls.listClasses.ImageCell;
       import flash.events.*;
       public class MyRenderer extends ImageCell implements ICellRenderer {
          public function MyRenderer() {
                this.buttonMode    = true;
              // set state skins to same skin so background is static
              setStyle("upSkin", lightBackground);
              setStyle("downSkin", lightBackground);
              setStyle("overSkin", lightBackground);
              setStyle("selectedUpSkin", lightBackground);
              setStyle("selectedDownSkin", lightBackground);
              setStyle("selectedOverSkin", lightBackground);
              // turn off text background by setting to 0
              setStyle("textOverlayAlpha", 0);
              setStyle("textPadding", 7);
                // event listeners
                this.addEventListener(MouseEvent.CLICK, clickHandler);
                this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
                this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
           // EVENTS
           private function clickHandler(event:MouseEvent):void {
           private function mouseOverHandler(event:MouseEvent):void {
           private function mouseOutHandler(event:MouseEvent):void {
    I want to insert calls to functions that are in the primary class (that contains the first function listed here), "ChordLib.as".
    How do I do this?

    In order for ClassA to call a function of another ClassB (or instance of it) it needs to be aware of two facts: 1) That ClassB does exist and 2) that ClassB has a particular function.
    Another approach could be establishing communication between classes via events.
    From you explanation it is not clear what you want to accomplish. Do you need to call a function on Class itself or an instance of this Class?
    If former - you need to create a static function and just call it:
    inside ClassB:
    public static function classBFunction()
    ClassA can call it:
    ClassB.classBFunction()
    If you need to call the function on an instance - you, naturally, need to instantiate the class and only then call the function.
    Say you have function inside ClassB
    public function classBAnotherFunction() - note that there is no word static
    There is another fork here: either you instantiate the ClassB inside ClassA or you pass a reference of the instance of ClassB into ClassA

  • Sharing jsp between multiple controllers

    Is there a way to share a jsp between 2 different controllers?
    If I put the shared jsp in its own directory and the 2 controllers in their own directories - I seem to be able to use netui:anchors and specifying the fully qualified "href" attribute - but not the "action" attribute. For example this works (but means I have to specify the exact controller):
    <netui:anchor href="/portlets/Controller1/findAction.do">
                find
    </netui:anchor>This does <b>not </b>work:
    <netui:anchor action="findAction">
                find
    </netui:anchor>Additionally, if I want a form to be on this shared jsp - I don't know of a way to use the netui tags to accomplish this... This example results in an error (as if it's trying to find the action in Global.app):
            <netui:form action="submitSharedForm">
                <table>
                    <tr valign="top">
                        <td>Foo:</td>
                        <td>
                        <netui:textBox dataSource="{actionForm.foo}"/>
                        </td>
                    </tr>
                </table>
                <netui:button value="submitSharedForm" type="submit"/>
            </netui:form>Are there other better techniques for sharing jsps between multiple controllers (jpf)? The only other thing I was thinking of trying to have a jsp found within the same directory as the controller include the shared jsp (which seems kind of tacky)...

    You may consider using a base pageflow controller that has the common JSPs
    in its directory. I have done that before like this:
    // inheritLocalPaths=true lets us inherit the JSPs from the base pageflow
    @Jpf.Controller(
    inheritLocalPaths=true
    public class MyChildController extends MyBaseController
    Ture Hoefner
    WebLogic Portal Engineering
    <Tim Rafert> wrote in message news:[email protected]..
    Is there a way to share a jsp between 2 different controllers?
    If I put the shared jsp in its own directory and the 2 controllers in
    their own directories - I seem to be able to use netui:anchors and
    specifying the fully qualified "href" attribute - but not the "action"
    attribute. For example this works (but means I have to specify the exact
    controller):
    <netui:anchor href="/portlets/Controller1/findAction.do">
    find
    </netui:anchor>This does <b>not </b>work:
    <netui:anchor action="findAction">
    find
    </netui:anchor>Additionally, if I want a form to be on this shared jsp - I don't know of
    a way to use the netui tags to accomplish this... This example results in
    an error (as if it's trying to find the action in Global.app):
    <netui:form action="submitSharedForm">
    <table>
    <tr valign="top">
    <td>Foo:</td>
    <td>
    <netui:textBox dataSource="{actionForm.foo}"/>
    </td>
    </tr>
    </table>
    >            <netui:button value="submitSharedForm" type="submit"/>
    </netui:form>Are there other better techniques for sharing jsps between multiple
    controllers (jpf)? The only other thing I was thinking of trying to have
    a jsp found within the same directory as the controller include the shared
    jsp (which seems kind of tacky)...

  • Sharing calendars between 2010 and 2013

    Is there an incompatibility issue when sharing calendars from Office 2010 and Office 2013?

    Hi Dave,
    I'm not quite sure what kind of incompatibility issue you mean here. But as far as I know, there is not so much difference with the Calendar function between Outlook 2010 and Outlook 2013.
    Calendars that shared from Outlook 2010 should work well in Outlook 2013 and vice versa.
    If you have any specific issues regarding sharing calendars between Outlook 2010 and Outlook 2013, please feel free to post a question in our forum, we'll be happy to help you with it.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Problem with Edit IN function between LR 2.3 and PS CS3

    I recently upgraded my system to a Windows Vista 64 bit Core 2 Quad with 8 GB.  Lightroom now works and loads images the way it should. I do have one major concern and need any help possible.
    I am using LR 2.3 in 64 bit and PS CS3 ver 10.0.1 (which is 32 bit - loads slowly but otherwise works fine).  The problem I am encountering is in LR Develop / Photo / Edit In...  - using any of the menu items:
    "Edit in Abode Photoshop CS3"
    "Open as Smart Object In Photoshop"
    "Merge to Panorama in Photoshop"
    "Merge to HDR in Photoshop"
    "Open as layers in Photoshop"
    Photoshop opens but no image(s) are exported and I receive the message in LR - "The file could not be edited because Adobe Photoshop CS3 could not be launched."
    Photoshop, however, was launched but no image exported and so I can't work on the image in PS.  The appropriate TIFF image is created in LR for the first two menu items - nothing for the last three menu items.
    I can create a partial work around by setting PS as an external editor, however, I can't use 4 of 5 of the menu items.
    All the menu items work fine in Windows XPpro.
    Any help is much appreciated.
    PS I also tried the most recent Window 7 RC with exactly the same results.
    Thanks
    Bob

    Don
    I wasn't shouting - I just cut and paste the exact text and font in its original size and type as was shown in the message.  Never had a thought that someone would be offended by cutting and pasting exactly what was in a message - it would appear that John Williams saw it for what it was.
    However, sorry if I offended you.
    Bob
    Date: Mon, 1 Jun 2009 19:15:15 -0600
    From: [email protected]
    To: [email protected]
    Subject: Problem with Edit IN function between LR 2.3 and PS CS3
    There is no reason to shout. There are only other users here trying to help.
    >

  • Hello there - how can I share my iTunes library between two users on the same computer? I put the library in a shared folder between both and have selected this library on both as well, but when I update iTunes with music etc it only appears on one?

    Hello there - how can I share my iTunes library between two users on the same computer? I put the library in a shared folder between both and have selected this library on both as well, but when I update iTunes with music etc it only appears on one?

    Thank you Joe - I tried this but it's only showing a teensy amount of music - the stuff on the second users account as opposed to the giagntic library on the 'main' account. I actually went to a Genius Bar and they said that apple doesn't really want you to share music between accounts - parents don't want to hear their kids music etc. Which seemed strange, but it might be the case sadly   Thanks anyway!

  • Sharing files between users and macs

    My husband and I share an iMac. I have a MBA for traveling and my husband a PC laptop (though he rarely uses for private stuff). We both have iPhones.
    We are looking for a way to:
    - Share our photos (we don't use iPhoto) and some files. We would like to have this in one shared folder, that we can access from both accounts in the iMac, the MBA and ideally (though not a must) the PC and iPhones. We would both need to have admin rights to edit documents, etc.
    - Have access to all the information in my account on the iMac from the MBA. Ideally, same thing for his and the PC.
    - Have access to all the data remotely when traveling.
    - Have all the data backed up locally (we already have a cloud backup, but we'd like to have a local backup too as it's easier and quicker to access)
    We have read a lot about configuration, NAS, time capsule... but we get more and more confused, as we are obviously no tech experts.
    Dropbox is not our preferred choice. We already have a cloud backup system. We'd rather have the files stored and accessed locally for everyday use.
    Using a NAS to store shared folders and backup the rest sounds good, but they either seem very complicated to set up, or they have mixed reviews in terms of stability, especially to access files remotely.
    Timecapsule seems easier and more straightforward, but I'm not sure it would solve the "sharing files between users and macs with admin rights"? It seems to be more focused on backing up the main drive and then providing access to the backed up files. (Though I might be completely mistaken!)
    We just can't manage to have one shared folder between both accounts in the iMac. We need to grant admin rights document by document. We don't manage to make it work automatically so we both have one folder to access with full rights for all the contents inside it. And this seems to me like something that should easily be done...?
    Any help, advice, proposals... would be greatly appreciated!!!

    Move any file you want to the other user to access to the Shared Folder. Anything you put in that folder is available to all users.
    The shared folder is here:
    Macintosh HD > Users > Shared

Maybe you are looking for

  • Yoga 13 Network Adaptor has disappeare​d...???

    Hi all, I've had my Yoga 13 for about two months (and have loved it), until this morning, when the network adapter disappeared. I was working upstairs, shut the laptop, brought it downstairs, opened it and was greeted with no wireless networks. Troub

  • Why does my iPad2 suddenly keep losing connection on facetime?

    Why does my iPad2 suddenly keep losing connection on FaceTime and tries to constantly reconnect?

  • Regarding translation hub in oracle 10g

    Hi, I have developed a report in Oracle10G now i want to translate this report from english to spanish can any body help me with this How to open that report in Translation Hub available in Oracle 10g

  • Big File vs Small file Tablespace

    Hi All, I have a doubt and just want to confirm that which is better if i am using Big file instead of many small datafile for a tablespace or big datafiles for a tablespace. I think better to use Bigfile tablespace. Kindly help me out wheather i am

  • Lightroom Color Profiles

    My studio uses ColorMatch RGB as our standard profile. After installing LR, I noticed that there are only 3 profiles installed by default. Where does LR pull these profiles from? Can I add ColorMatch RGB to the list like you can do in Photoshop? How