the scope, myClass and contextMenu

I have a class where I define a context menu. The strange thing is, when I call the function, I can't call all the variables from outside the function. The context menu calls the function correctly, but the scope is wonkey all. Is there a way to get around this?

function checkIt() {}
TEST = 'test '.
trace (test);
}
traces undefined

function checkIt() {}
var TEST = 'test '.
trace (test);
}
traces "test."

I tried referencing all the variables available, but because of the way its formatted - I must use of _root variables? Or is there a better way that I don't see?

Help,

> Hey David, thank you for taking the time.

Sure thing! :)

> I think I cleaned up the code to display only whats important. I have
> 200-1000 + of these objects instantiated 'check' (check boxes)
> Depending on what the user is looking.

Very well.

> class check extends MovieClip {}
> / / snip...
> test = new ContextMenuItem ("THIS IS a TEST", checkIt);

It's here. The question is, all variables or 'this' made reference to the
the checkIt() function are limited to checkIt(), then your TEST variable... Well,.
That's the weird part. If it does not already exist (in this scope, anyway).
It should be created just here, even without the var statement. I am
in fact do not know why the TEST is not defined by the point, he gets the record, but the
This is fixed with the delegate class.

Import mx.utils.Delegate;
class mark extends MovieClip {}
public var CM:ContextMenu;
etc.
test = new ContextMenuItem ("THIS IS A TEST", Delegate.create (this,
checkIt));
etc.

... that scopes checkIt() to the class itself, and you will see TEST properly
put the string 'test' in the Panel out. This seems a bit wonky (I really
can't think of a better word - you nailed!), but at least you can spend
along the desired data.

To smile, you can also send the two settings of
your checkIt() function:

function checkIt (obj:MovieClip, point: Object) {}
trace ("obj:" + obj);
trace ("point:" + item);
for (var prop: String in point) {}
trace ("" + prop + ":" + item [prop]);
}
TEST = "test";
trace (test);
}

To me, that the production of the following:

obj: _level0.instance1
Article: [object Object]
visible: true
enabled: true
separatorBefore: false
onSelect: [type function]
Caption: THIS IS A TEST
test

... where obj is clearly the video clip itself, and the point is ContextMenuItem
object.

David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Tags: Adobe Animate

Similar Questions

  • Component in the scope and cflock

    Hello

    I have a CFC that I put in the scope in the SystemFramework method that contains some system settings, which is an indicator to tell if the site is currently 'online '. I call a method on this CFC in the 'onRequest' Application.cfc method to see if the value of the indicator has changed.

    This method throws a parameter defined in the database that indicates whether the site is "online" or "offline". If the site is currently online, I want to just redo the query every 5 minutes. However, if the site is unavailable, I want to check more frequently (every 5 seconds) as to if the flag changed back.

    I don't know, what if I need to use < cflock > when I change from 'online' to 'offline '? There is only one instance of this object, but what happens if several applications are calling the 'isSiteOnline' method at the same time? It is "safe"?

    Some code snippets are attached to illustrate.

    Any advice would be greatly appreciated.

    Kind regards
    Andrew.

    >

    No, in every situation.

    Ask yourself... The consequences of two queries hit
    This line of code "simultaneously"? The final result is that both of them
    are setting the variable to the same static value... it's what's happening
    eventually occur: variables.instance.cacheInterval will be the value
    300 (or 5) in each situation.

    You may with to lock a block of code which - if called
    at the same time through several applications - could act on shared storage
    space (server, application or session data) differently and incorrectly
    What is planned.

    for example:


    application.isInitialised >






    So a sequence of events might be (for example, the user is hitting the site with two
    different browsers):

    REQUEST1: application.isInitialised does not exist
    REQUEST1: starts the init process
    REQUEST2: application.isInitialised STILL does not exist
    REQUEST2: starts the init process * new *.
    REQUEST1: sets the value of application.isInitialised
    REQUEST2: sets the value of application.isInitialised

    Of course, we don't want two ask the running initialization code.

    Note This is an example a bit far-fetched, as if we have a
    OnApplicationStart() method, then it runs only once, and that's where
    Should the init code, but it illustrates the problem.

    Google "race condition". These are the situations in which there
    the code lock blocks.

    --
    Adam

  • TypeError: try to run the script compilation and go on a 'mistake' in scope cleared when message returns the transfer through images for each image. Does not affect viewing.

    TypeError: try to run the script compilation and go on a contour

    Above the error message appears when moving between images - back and forth. By clicking on the OK button removes the error message and there is no apparent problem. The window that appears refers to a JAVA Script Application (I guess that FIREFOX is the application?)

    -> Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems

    Check and tell if its working.

  • 2 TB LUN and Clarification of the scope

    I have a need to assign several VM in my environment of clients with 2 TB vmdk files, but I also want to be able to take snapshots of these servers.

    Because of this I would expect the community could clarrify a few points for me by correcting one of my points/assumptions;

    (1) VMFS data warehouses can be a maximum of 64 to in size.

    (2) VMDK can include up to 2 TB in size.

    (3) develop a VMFS datastore and LUN requires that he space / free vacuum at the end of the disc.

    (4) creation of a store of data VMFS higher then 2 TB requires the creation and presentation for ESX (i) multiple LUNS and then link them together using extensions.

    (5) to extend a LUN/VMFS beyond 2048 GB is bad news and can cause data corruption.

    So in my situation it seems to me that I need to create a 2 TB LUN and a second unit logic to say 300 GB number, then link them together using a measure to create a store of VMFS data that spans the two LUNS and has a total of 2.3 TB of space. So I can create my 2 TB VMDK and still be able to take pictures.

    Is there one way other or better to get my result?

    Are there concerns with the help of extensions, it's what trade off?

    Any other comments would be welcome.

    See you soon,.

    Paul

    What is your process to separate the configuration of virtual disk file in the files of virtual disk storage?

    Nothing special. When you create her select VM first data store. Then, when you create the virtual disk in the wizard, just select the second data store

    What the penalty or drawback to the use of extensions?

    They're just not necessary anymore. Extents should be used prior to ESX (i) 4.0 to resize a data store. With ESX(I) 4.0, it is now possible to resize/grow the store of data on the fly after resizing the underlying LUN without needing extensions. With extents, you lose that option. Basically, a data store extended is as a RAID 0 array.

    You can also read http://www.yellow-bricks.com/2009/03/26/resizing-your-vmfs-the-right-way-exploring-the-next-version-of-esxvcenter/

    André

  • Question on the scope and the framework / time line

    Hello!

    I write a little app and have the buttons and sliders on a field 1 of the scene and then a help screen on frame 2 of the scene.

    I have event listeners attached to the objects of the first image.  When I go to the second image and then return to the first image, all event listeners are passed away and no longer work.  (at least that is what I think is happening).

    My question is what is the best way to deal with this.  I think the best way would be to add something like adding Event listeners. ADDED_TO_STAGE for each object and have the listener function add event listeners I want for each item.

    So I will:

    public function Document()

    {

    Super ();

    iSlider.addEventListener (Event.ADDED_TO_STAGE, added);

    iSlider.removeEventListener (Event.REMOVED_FROM_STAGE, withdrawn);

    myButton.addEventListener (Event.ADDED_TO_STAGE, buttonAdded);

    myButton.addEventListener (Event.REMOVED_FROM_STAGE, buttonRemoved);

    }

    In each of the listeners, I would add / remove listeners that respond effectively to the key / slider.

    Is the best way to do it, or I missed something.  Sorry about the silent nature of this question, but I'm gay.  I hope someone less gay can help out me.

    -Thank you

    you are probably missing when you move to the structure 2.  It is a problem when using as3.

    an appeal is to remove your objects in the scene (using code - NOT the timeline) in box 2.  (re) you can add them to the stage in frame 1.

  • question about the scope of variables and memory

    I searched the Adobe documentation for an overview, but apparently, I'm not in the right place.

    Here is an example of simplified code:

    < AS >

    loadedImages:Array = new Array();

    function createImageData(imageNumber:Number):void
    {
    var imageData:BitmapData = new BitmapData (width, height);

    Switch (imageNumber)
    {
    case 1:
    imageData.draw (loader1.content);
    loadedImages [imageNumber] = imageData;
    break;

    case 2:
    imageData.draw (loader2.content);
    loadedImages [imageNumber] = imageData;
    break;
    }
    }

    < virtue >

    ImageData defined inside the function createImageData(), I know that I can not access any outside level of the function block.  But what about memory?  ImageData still exist once the code has "left" the createImageData() function?

    For example, if the function above is called twice (once with imageNumber = 1, once with imageNumber = 2), what I remember?

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and 1 BitmapData object named imageData

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and 2 BitmapData named imageData objects

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and nothing else

    Is there a way to see the 'elements' in memory, not just the quantity?

    If you call twice createImageData, for imageNumber = 1 and imageNumber = 2, there will be only 2 persistent objects to the Bitmap in memory, and they will be made by the loadedImages table. The imageData variable is just the first to receive the pointer to the allocated memory and past him on the elements of the array until it's life is over. Only when you delete the table, you will release the objects for the GC.

  • To access the items in the menu screen and/or onSave()

    Nice day

    I'm having a problem. I try to access the data of my screen of a menuitem and onSave() method, but cannot get the variable. That is on my screen, I have an objectlist and I want to be able to record the choice that has been made. ObjectList is out of reach in the menuitem and onSave methods. I tried the objectlist initialization, after that I started my class, but before the constructor, but that only throws an exception.

    Pls help.

    Thank you

    Mike

    I probably have something like the following code and have the screen controls in the scope

    public class myClass extends MainScreen
    {
        private String _myList[] = {"test1", "test2", "test3"};
        private ObjectChoiceField obj = new ObjectChoiceField("Pick: ", _myList);
    
      myClass()
      {
        super();
        //add to screen, etc.
      }
    
    protected void makeMenu(Menu menu, int instance)
        {
            menu.add(_save);
        }
    private MenuItem _save = new MenuItem("Save Details", 110, 10)
         {
            public void run()
            {
                //Save info
                obj.getSelectedIndex(); //out of scope
    
            } 
    
    }
    
  • Dual boot between the preinstalled Vista and Linux

    I think installing dual-boot between Linux systems, for this I need to repartition the hard drive and reinstall vista and vista pre-installed that I na? t have the disc so that I only have recovery.

    Assuming that the operating system is on the machine in a hidden partition is it possible to make as if I change the custom of available to partition I lose the data recovery. Also, if it's possible here is a recommended distribution to use.

    As far as I know the recovery system resides in a hidden partition.
    On my machine, it is/dev/sda1

    After this partition (the remaining rest) there is a large partition with Vista on it.
    On my machine, it is/dev/sda2

    You can resize (i.e. minimize) / dev/sda2 partition of your distribution tool.
    Then, create a scope/dev/sda3 partition

    In/dev/sda3, you can create partitions for your Linux system

    On my machine, there is no need to reinstall Vista; Dual boot works fine.
    After the Vista partition with partition tool of opensuse 10.2 resizing Vista has conducted an audit of file system

  • In Labview 8.5, what happens if the input signal exceeds the scope of the signal defined by the DAQ Assistant?

    Hi all

    This should be a pretty simple question, but I can't seem to find the answer online and currently do not have the functionality to test this:

    I'm using LabVIEW 8.5 and have a VI that imports data from sensor through the DAQ Assistant. In the configuration tab, there is a range of signal input. What happens if my sensor exceeds this range? I get a warning? The default value is the maximum (or minimum)? I was interested in writing a code to display an error that I approach the limits of this range, but did not know if I also need to include code to display an error if the scope is exceeded as well.

    Thanks for the help,

    Tristan

    Hello, Tristan,.

    The behavior depends on the selected range and the device you are using.

    If you are using a device with a single input range is valid, we will use this range, even if you set a smaller minimum and maximum in the DAQ Assistant.  So, if your device only supports ±10V and you set the range to ±8V, you will still continue to get valid data after your top sensor 8V until what you approach 10V.  When you reach the limit of the extent of your device, the output will be 'rail', and simply return the maximum value until the signal is less than the maximum value again.

    Note: A device that is nominally ±10V usually has a go-around (such as ±10.2V) which are usually specced in the manual.

    However, if you use a device with several ranges of entry then things become more complex.

    NOR-DAQmx player will choose the smallest range that entirely covers the interval you choose.  For example, suppose that your device supports the following input range: ±0.2V, ±1, ±5V, ±10V and you choose 0V - 3V as the range in the DAQ assistant.  The NOR-DAQmx driver will focus on the input range and the list of the entry lines that your hardware supports and choose the smallest encompassing the entire range that you set.  This would be the ±5V, because this is the only beach that contains up to 3V.  Thus, all between ±5V input signal is returned and none outside this range will be 'rail' to the maximum or minimum value.

    We do this because using small beaches make more efficient use of the resolution of the ADC.  So, we try to use the most effective range based on what you ask without picking up a range that will make you miss data.

    Let me know if I can clarify it more.

  • Set access script of the scope

    I find it odd that this is not obvious so I have to do something wrong.  With LabVIEW Scripting and VI how can server, I define a VI that are already in a library, to have a Scope access of Private?  I open the library and can browse to get my ProjectItem, but I don't see a way to scope.  A quick search only find ways to read the scope of access, but I could not find a way to put it.  Thank you.

    Have you ever seen this method?

    http://zone.NI.com/reference/en-XX/help/371361L-01/lvprop/library_setsourcescope/

    Edit: Here's an excerpt from VI

  • font sizes changed on the scope

    When I copied my code, written in LV2011, on my scope, Tek DSA8300, all of a sudden all the fonts passed under 15 pt to pt 23. This makes just enough bad sound.

    I understand why a scope uses large fonts, because the screen is small. However, I use an external monitor, so I really need the 'help '.

    Is there something in my code (which I inherited) that requests from the computer it runs of a default font size? Can I turn that off?

    Thank you.

    I had to load LV2011 on the scope. It runs from Win7.

    It turns out that I can change the fonts in LV by > tools > Options > environment and deselecting the default fonts. But it's weird that the default fonts changed.

  • Read the channel 1 and channel 2

    Hello

    I went through the basic course Lab View 1 and I'm starting to understand some of them. I struggle to write the next request in Lab View 8.5 and version 2011.

    I need to write a VI for the Tektronix TDS 210 2 channel oscilloscope to be able read channel 1 and channel 2 (x and y). Also, I have to run this scope as scope of digital storage (remember the waveform in the memory and be able to remember specific time range) I downloaded the driver for the scope and I am able to run the only form of wave or multiple wave VI, but I do not know how to change these VI in order to function as I mentioned above.

    I need to know how I can lock this VI as the instrument always follows the same GPIB address.

    Could someone help me with this project please?

    Thank you

    Joe

    Make a constant on the block diagram. It is an option to click right when you are on the block diagram. I also recommend the creation of an alias for it to the MAX (i.e. "extended"). In this way, if the address changes, you don't have to change the program.

  • I forgot the email address and password account XBox

    * Original title: help

    Ive had xbox one for a year now and I had. Make two accounts and ive been ing the child one and I forgot my email and password for the adult count do - what I do

    Hello

    Your Question is beyond the scope of this community...

    I suggest that repost you in the Xbox Forums.

    "Xbox a Preview program FAQ.

    http://support.Xbox.com/en-us/Xbox-one/system/Xbox-update-preview-FAQ

    'Home'

    http://forums.Xbox.com/

    "Xbox forums.

    http://forums.Xbox.com/xbox_forums/general_discussion/f/3817.aspx

    _________________________________________________

    "Xbox Forums directory.

    http://www.Xbox.com/en-us/forums

    General

    Material & Discussion Services

    Xbox support
    Agent hours: M - F 09:00-17:00 PT

    Law enforcement forums

    Technical support of Xbox Live rewards
    Xbox Live rewards Squad hours: M - F 09:00-17: 00 PST

    See you soon.

  • Every Pc has yellow ball on the NIC (LAN and WIFI)

    All client computers obtained yellow ball in the NIC (LAN and Wifi) after running GPUPDATE/force on domain controller.

    I've run the gpupdate and all afftected users once again, also
    account has been removed from the ACL of the directory.

    I am the admin of our small network and have never needed to play with the
    GPO before. This problem just happened 'out of the blue"and I would like to
    to resolve what caused it.

    This issue is beyond the scope of this site and must be placed on Technet or MSDN
  • Is there a function to have a chart at the same time the full signal and a zoom in display signal?

    See the attached Jpeg format. Ive created this using 2 separate charts. Ideally I'd like make using one graph. Is this possible?

    If you plot the same data as two separate parcels

    AND

    You create two separate x and there throw

    AND

    You associate a plot with each pair of XY scales scale.

    You will then be able to change the scope of a set of scales to get an effect similar to the zoom on one.

    Ben

Maybe you are looking for

  • Had to give up using Firefox due to the fault of all videos

    No video will not play. Not any Youtube or those of KimKomando or other sources. Tried to replace Adobe Flash as well as clear cache etc. - even replace Firefox to previous levels. Nothing helps. Firefox has been my mainstay years so I'm sad that I h

  • Need a recovery CD German for Portege M400

    Hello!I bought the laptop in America and just realized that it would be better to have a German version of Windows on it :-) Unfortunately, it is impossible to purchase a fully licensed version of Windows XP Tablet Edition in Germany... (amazing, by

  • Normal startup?

    Just got a new (refurbed) iMac last week.  I love. I have a few questions. Startup is very fast with the Fusion drive.  But in the middle of the progress bar, the screen briefly flashes to black, then continues on.  It is also a light 'grinding' or h

  • I'm unable to load windows xp professional 32-bit.

    Error Msg: Windows XP could not start because the following file is missing or corrupt: \WINDOWS\SYSTEM32\CONFIG\SYSTEM

  • My tags and labels will remain with the images when I move them to a new computer?

    I want to assure you that if I take the time to enter the tags and labels for my images, these data will move with the images of my next computer.