global or local variables for speed?

Hi, someone at - it an idea?

is it faster to the use of global variables or properties (sprite) or the properties of the object?
In other words is it smart to use as less globals possible or not (in terms of speed)? Or is not a difference.

Thank you!

www.SeriousGames.startpagina.nl

In general, use the globals less possible, for various reasons (lighter &)
more secure code, ability to reuse the names etc.).
In terms of speed, local variables are faster in most of the languages
(definition hierarchy, local verified first + entered less to research)
(for). In Director however, no difference will be hardly noticeable, since
the charge of executing line jargon leaves no room for sub or nearby to
considerations of optimization nanoseconds.

"www.gamesmaken.pagina.nl" wrote in message
News:e8brrf$833$1@forums. Macromedia.com...
> Hey, someone at - it an idea?
>
> it is faster to use global variables or properties (sprite) or an object
> Properties?
> In other words is smart to use as less globals possible or not (
> terms
(> speed)? Or is not a difference.
>
> Thank you!
>
> www.seriousgames.startpagina.nl
>

Tags: Director

Similar Questions

  • Use of global variable from local variables for business rules

    Someone at - it guidelines on the use of overall compared to the local variables for the business rules? I really don't like the world no matter what, so if someone has a compelling reason to use overall.

    If I use a local variable in the world, is there a single character required for the local variable or no problem with the help of the same name local var in all of business rules.

    Thank you

    Hello

    I bet you have a background in programming. Don't let the 'global' nomenclature lure you into thinking that "bad design - not encapsulated, etc" with regard to business rules. According to John, this area, variable overall are a vehicle to reduce maintenance.

    For example if you have a variable in which all its used BR called CurrMonth and its always the current month, it create once, maintain his assignment in one place and use it anywhere. In this case 'global' is in fact less.

    Kind regards
    Robb Salzmann

  • Global and Local variable... why it doesn't work?

    I'm confused.  .__.

    haha

    in any case, I wrote a class for my AS3 flash game.  It's that everything works well until what I called a method and got an error message.  After a bit of debugging, I was able to determine that my problem is when I try to assign a global variable (and the class property) to a local value, within the service itself, where the local variable.

    Here is part of my class:

    Sheet/public class extends Sprite {}

    private var number: int;

    private var sourceBitmap:Bitmap;

    private var sourceBitmapData:BitmapData;

    private var tileWidth:int;

    private var tileHeight:int;

    public void {sheet (number: int, tileWidth:int, tileHeight:int)}

    This.Number = number;

    this.tileWidth = tileWidth;

    this.tileHeight = tileWidth;

    displayImage();

    init();

    }

    public void displayImage() {}

    var imgLoader:Loader = new Loader();

    imgLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, done);

    If (number > = 100) {}

    imgLoader.load (new URLRequest("CharSprites/Female/"+number+".png"));

    }

    else {}

    imgLoader.load (new URLRequest("CharSprites/Male/"+number+".png"));

    }

    function done(evt:Event):void {}

    var myBit:Bitmap = Bitmap (imgLoader.content);

    addChild (myBit);

    this.sourceBitmapData = myBit.bitmapData;

    trace (this.sourceBitmapData);                                              ... sourceBitmapData are here

    }

    }

    private void init() {}

    trace (sourceBitmapData);                                                       sourceBitmapData is null here

    }

    }

    }

    I thought that I was able to assign the value of hard bitmapData to a property class (global variable) inside a function and have it exists outside.  I was wrong?

    How do I get around that?

    I know that I can write a function to return the Bitmap image, but as the function is called after the EventListener and depends on my charger, I don't know how to get around this problem.

    Thank you very much!

    Ya. My recommendation is to delay your init() function call until your image will load. So just move the call to init() in your service done or what needs the bitmapData to your function made move.

  • How to create a nested local variable control custom?

    I inherited code which has a cluster of CTL control nested inside another group of control CTL.  If I drag the control nested outside the border of the other, I can right-click to create a local variable, I need to connect to the bundle name.  However, as soon as I drag the inside the limits of external control, it breaks the local variable.

    How can I create a local variable in a cluster THAT CTL nested in a second group CTL?

    Is there some kind of reference OuterCluster.InnerCluster, that I can use if I do a local variable of the external group?

    It turns that I need a local variable for the cluster internal.

    JPG attached shows that I created a local variable for the external cluster (ParametersCluster), used a Unbundle based on the name to access cluster internal (EmptyParmeters) and can access one of the elements through an another Unbundle by name.

  • How to set multiple values clustered with local variable?

    Hi all

    Okay, I made my way through Labview for everyone and have some basic concepts down. I can see with a cluster, if acting directly on it, you can ungroup, change values, rebundle, etc..

    I try something a little more complex... and just do not know how to start on this.

    I have a menu menu ring set. I created this with a typedef, with 4 values.  I used this typedef 7 times, more a few LED bool, in a cluster. I made this cluster a typedef.

    Therefore, in my main vi, I started designing, I put an example posted here... and inside, I have two instantiations of the typedef cluster commands selection of left and right.

    I dropped in this vi, a copy of the menu ring typedef (same typedef as in clusters, values) called reset all tubes.

    Now, I am trying to understand how, with an event to change the value to 'reset all the tubes'... that I can start with the left switch and change all tubes (here is the menu ring selector) to the same value as what has been selected with the ring of menu 'Reset all the tubes'.

    I created a local variable for the selector on the left. It is configured to read values. (I'll be doing the same thing with the right too, but just to start with the left).

    In the examples I've seen where access to a cluster, you could ungroup the cluster... browse and change the values... maybe pull out all the "hits" in a table and go through to update the values.  And when you group or ungroup the bunch... you can see the values, etc., when you stretch on the block diagram.

    With the local variable... I do not see to 'stretch' it as I expected... so I can access the values "tubes"... and all at the value of the 'reset all the tubes' ring menu value.

    Someone can put me on the path on the best way to do... or is it a component structure I'm missing here?  Am that I on the right track everything first here?

    It seems pretty basic to me, but miss me just something here on the way to start...

    Thank you in advance,

    Cayenne

    You can't do this with a for loop of how the Department is structured, but why make it so complicated?  Just group the new value in the cluster, as shown below:

    If you do not want to use a loop for example, consider the restructuring of your cluster.  Group ring and a Boolean value in a cluster, and then unmold 7 of those in the cluster of selector.  Then you can use 'cluster to the table' and 'picture of cluster' for all elements of the external cluster will be of the same type.

    Also, be careful when using rings in the form of type definitions.  You probably want to use an enumeration instead.  The elements of a ring do not update the when you update the type definition because they are considered to be cosmetics. the elements of a definition of enumeration type update, because the elements of an enumeration are considered as part of the data type.

  • automatic creation of local variables

    Hello

    I have the impression that the idea I have is probably not possible, but I thought it wouldn't hurt to ask.  I connect CAN data using a cRIO and NI 9853 using the framework on the channel of convertion vi.  I have a selector of cases in which the message id dictates the case.  In each case, the raster data are converted and sent to tables for data and the name of the channel.  Then, in a separate loop, I make every tenth iteration in the name of channel and data with local variables and save it to a file of PDM.  I currently use local variables for each table in the selector of the case.  While this works well, I'm trying to simplify it and make it like if someone wanted to add several CAN signals for forest exploitation and so more cases in the selector of the case, they could do with as little work as possible.  In essence, I need to make fake evidence.  The idea that I'm trying to find a way to create a local variable and a specific reference indicator as soon as a case is created automatically.  Is it possible, or I ask much of labview?  Thank you.


  • PLSQL local variable assigned to a global package

    I have a situation I want to declare a local variable and assign it to a global package variable.

    such as:

    xyz package_a.my_type := package_a.my_var
    

    This creates a pointer to the global package or Oracle copy the global variable?  I need for oracle deal with this pointer.

    Is there something wrong with that?

    If there is no problem, I'll adopt this approach in 100s of procedures / packages.  I use oracle psp and create a large number of procedures.

    Hello

    Do you really need a separate variable xyz?  Why not just use package_a.my_var?

    What is the big picture here?  What you trying to do?  Explain your business needs, and someone will help you to find a good way to respond.

    What you've posted describes only one way that you thought to meet the requirement; We can guess the real requirement, and guess is not the best way to solve problems.

  • Using a Global Variable for the input recorder DisplayRange

    I'm assuming; Since I can't do it; that you cannot change the display range of a graphic recorder by using a variable.  If there is a way I'd love to know how.

    Thank you!

    Determine if you can use a global variable is to click right in the parameter field. If the global variable is available in the context menu, then you can use a variable y.

    You can use a variable of the y-axis from the settings.

    You cannot use a variable for the display range of the x-axis parameter. This is because DASYLab needs to know the amount of memory to be allocated at the beginning of the measure.

  • pure example to compare the performance of reading for a local variable, a declarant and a queue element (looking for)

    Dear users,

    I came across an example of the operation and the disadvantages of using a local variable, a declarant and a queue for the collection and handling of data these last time. But I can't find him.

    I try to describe what and I hope someone can give me a hint:

    A sinus values were generated periodically and were sent to an indicator, a declarant and a queue. In the other loops, the local variable (of the indicator), the authors of notifications and of the elements of the queue were plotted graphs. Time of the playback loop loops can be set separately for each of them and depends on the sync settings (time: equal to the generator, half of the generator and copy of the generator), we can observe omitted elements or duplicate. Very useful to observe the behavior of loops in a local variable, a declarant and a part of the reading queue.

    Does anyone have an idea where this VI is placed, please?

    Hello ghighuphu,

    Do you mean this example?

    With the help of local Variables, queues and notifiers to synchronize data with parallel loops.

    http://www.NI.com/example/28717/en/

    Best regards

    Maha

  • FOR loop does not update the local Variable

    I am newer to labview, and I can't wrap the head around why not a habit of local variable to update in the code if it updates on the dashboard. Anything im missing?

    Assume that you are talking about the local variable of the 'State of the cell. The terminal updates every 500ms in the small top loop, the local variable indicates simply that the indicator and thus updates also.

    The problem is "dataflow" and you need to familiarize yourself with the concept!

    Once the while loop starts, the local variable is reading and inside the loop begins. Most likely, the local variable is read before it is updated in the small loop, so most likely returns the value of a fade on the first iteration of the while loop. Now the small loop continues to go twice per second for about five seconds. Only after the loop FOR (and everything else inside the while loop) completed, the while loop will go to the next iteration, date on which the local variable is read once more, this time with the last value of the last for loop iteration of the previous iteration of the while loop.

    In summary, the local variable updates very well, it's just that the code does not read the new value around most of the time.

    Your VI is full also potential competition conditions caused by the over-use of the local variable. You need to respect the proper execution order by eliminating local variables.

    So what is the solution? Hard to say without knowing what the VI is supposed to do. Most likely, you will need to remove the inside OF the loop and use it outside while loop for everything.

  • Data is not displayed for a local variable Visual C++ 2010

    I am running Microsoft Visual C++ Express 2010 on windows 7.  Yesterday, he decided to no longer display the data for local variables (variables related to level superior OK, under block variable not). I deleted files *.pdb and *.idb and recompiled (off optimization). Microsoft argues it has a fix to https://support.microsoft.com/en-us/kb/2452649 , but looks like they're going to charge me just short of $500 to the difficulty of access. I can't afford the charge. In the past, move to a newer version of Visual C++ and brought me to hire fees to make it work because it is not backward compatible. Any other ideas?

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • Model of memory (RAM) in Flex or ActionScript for local variables in a method

    I have a method in AS3 to manage certain event generated from the components in < mx:Repeater >. Two different components can trigger the event even

    at the same time so the same method should treat the two events together. My question is if the two calls to the same event handler method will take a step from the other. The event handler method uses only local variables.

    In Java, a method for both local variables are at two different addresses of memory (RAM). So they will not strengthen each other. Not sure about the

    Flex/ActionScript.

    ActionScript runs in a single thread.  One of the events will get full

    treaties before the other.

  • How to set global variables for use by all THE #subform [0] items of form1. ?

    Hi all

    I don't know how to code javascript but am new to Adobe LiveCycle.  When I open the script editor, I have the following code (the code is in United Nations in bold):

    -form1. #subform [0]: initialize :-(FormCalc, client).

    //////////////////////////////
    TO START: SET GLOBAL PRICES.
    //////////////////////////////

    var Cityscope_Sydney_CostUser1 = 60,39;
    var Cityscope_Sydney_CostUsers2to5 = 3.02;
    var Cityscope_Sydney_CostUsers6to20 = 1.21;
    var Cityscope_Sydney_CostHardCopyWithOnline = 14.59;
    var Cityscope_Sydney_CostHardCopyWithoutOnline = 54,67;
    var Cityscope_Sydney_CostHardCopyAdditional = 14.59;

    var Cityscope_NorthSydney_CostUser1 = 48,40;
    var Cityscope_NorthSydney_CostUsers2to5 = 2.42;
    var Cityscope_NorthSydney_CostUsers6to20 = 0.97;
    var Cityscope_NorthSydney_CostHardCopyWithOnline = 14.59;
    var Cityscope_NorthSydney_CostHardCopyWithoutOnline = 43,54;
    var Cityscope_NorthSydney_CostHardCopyAdditional = 14.59;


    ////////////////////////////
    END: SET GLOBAL PRICES.
    ////////////////////////////

    -form1. #subform [0]: enter :-(FormCalc, client).

    -form1. #subform [0]: output :-(FormCalc, client).

    -form1. #subform [0]: calculate :-(FormCalc, client).

    -form1. #subform [0]: validate :-(FormCalc, client).

    -form1. #subform [0]: preSave - (FormCalc, client).

    < < = etc etc etc = > >

    -form1. #subform [0]. Item1Cost::initialize :-(JavaScript, client).

    -form1. #subform [0]. Item1Cost::enter :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::exit :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::calculate :-(JavaScript, client).

    Store the values of the form of friendly names.
    var AreaSelected = Item1Area.rawValue;
    var NumberOfUsersSelected = Item1Users.rawValue;

    Declare other variables.
    var Users1Calculation;
    var Users2to5Calculation;
    var Users6to20Calculation;


    Calculate the cost to the "components" user will depend on the number of users selected for the region.
    Switch (true)
    {
    If (NumberOfUsersSelected < 2):
    Users1Calculation = NumberOfUsersSelected * Cityscope_Sydney_CostUser1;
    Users2to5Calculation = 0.00;
    Users6to20Calculation = 0.00;
    break;
    If (NumberOfUsersSelected > 1 & & NumberOfUsersSelected < 6):
    Users1Calculation = Cityscope_Sydney_CostUser1;
    Users2to5Calculation = (NumberOfUsersSelected - 1) * Cityscope_Sydney_CostUsers2to5;
    Users6to20Calculation = 0.00;
    break;
    If (NumberOfUsersSelected > 5):
    Users1Calculation = Cityscope_Sydney_CostUser1;
    Users2to5Calculation = 4 * Cityscope_Sydney_CostUsers2to5;
    Users6to20Calculation = (NumberOfUsersSelected - 5) * Cityscope_Sydney_CostUsers6to20;
    break;
    by default:
    Alert ("BROKEN: calculate the individual components of cost of use will depend on the number of users selected for the region.");

    }

    apply the total cost for this article
    Item1Cost.RawValue = Users1Calculation + Users2to5Calculation + Users6to20Calculation;

    -form1. #subform [0]. Item1Cost::validate :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::MouseEnter :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::mouseExit :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::change :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::full :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::MouseUp :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::MouseDown :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::click :-(FormCalc, client).

    -form1. #subform [0]. Item1Cost::preSave - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::postSave - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::prePrint - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::postPrint - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::preSubmit:form - (FormCalc, client)-

    -form1. #subform [0]. Item1Cost::docReady - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::docClose - (FormCalc, client).

    -form1. #subform [0]. Item1Cost::ready:form - (FormCalc, client)-

    -form1. #subform [0]. Item1Cost::ready:layout - (FormCalc, client)-

    -form1. #subform [0]. Item1Users::initialize :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::enter :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::exit :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::calculate :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::validate :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::MouseEnter :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::mouseExit :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::change :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::full :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::MouseUp :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::MouseDown :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::click :-(FormCalc, client).

    -form1. #subform [0]. Item1Users::preSave - (FormCalc, client).

    -form1. #subform [0]. Item1Users::postSave - (FormCalc, client).

    -form1. #subform [0]. Item1Users::prePrint - (FormCalc, client).

    -form1. #subform [0]. Item1Users::postPrint - (FormCalc, client).

    -form1. #subform [0]. Item1Users::preSubmit:form - (FormCalc, client)-

    -form1. #subform [0]. Item1Users::docReady - (FormCalc, client).

    -form1. #subform [0]. Item1Users::docClose - (FormCalc, client).

    -form1. #subform [0]. Item1Users::ready:form - (FormCalc, client)-

    -form1. #subform [0]. Item1Users::ready:layout - (FormCalc, client)-

    .. and so on and so forth...

    In short, I want the code in:

    -form1. #subform [0]. Item1Cost::calculate :-(JavaScript, client).

    .. .to be able to access the variables I created in:

    -form1. #subform [0]: initialize :-(FormCalc, client).


    (I guess that's where I store global variables)

    At this point, global variables are not accessible with the above configuration.  Was the only one I can get this working is to cut and paste the Globals in each item of form1. #subform [0], which of course defeats the purpose of global variables!  I intend to have a lot more items so wouldn't duplicate global variables for each of them!

    Can someone show me how to do this?

    Any help is very appreciated!

    Thank you

    Stanbridge

    Post edited by: stanbridgej - colors and fonts or not will not save.  Are bolded my question make (non-fat) code easier to read (I hope).

    I haven't used Formccalc, but I thought it would be the same regardless. Insert a script object to the top of the hierarchy and call it, for example "sco." Paste the Globals. Then refer to variables of the extent that sco. Cityscope_Sydney_CostUser1, etc. Make one

    App.Alert (sco. Cityscope_Sydney_CostUser1);

    one of the fields. If the debugger is activated, it will tell you if it cannot resolve the reference as "sco. In this case, you may need to use the som expression to reference the script object, for example

    var scoScript = xfa.resolveNode ("topOfHierarchy.sco");

    scoScript.Cityscope_Sydney_CostUser1

    But if as close as possible to the top of the hierarchy above should work.

  • By the way the local variable to sous-suite

    I have a sequence that sets a local variable, Locals.LowPassFreqGhz = 1,800.

    Then it executes 5 subsequences.

    The Local is set to a new value and then the same 5 subsequences are re-run.

    Now I have new model numbers where the pair is different and will soon have models where there are groups of 4 frequencies instead of two. That is why I would like to put the 5 seqs in a following and pass the freq based on a select statement. In my limited understanding and knowledge of TestStand, I think that the sous-suite would have its own Local.variables. How should I move this local to a sous-suite, convert a File.global?

    Thank you

    JVH

    The subsequence could have its own inhabitants, but you must use the parameters to pass to residents for the most part in the subsequence. See Chapter 1 of the section and the reference of TestStand sequences on manual.

  • Structure of the event to local variable

    Hello

    I use a control structure and the table event to detect changes in the value of table.

    At the beginning, I have made changes in the table (for execution) and structure of the detected event.

    The next step was adding a parallel while loop in which I write for the control array (using the local variable).

    During execution the layout of the table changed indeed, but the structure of the event is a not detect it.

    I have attached 2 digits: 1) loop of the structure of the event 2) the parallel loop.

    It is possible works in such a way?

    How can I make the structure of the event to detect changes in the software in the control array?

    Thank you

    Leonid

    Changes made via a local variable are not the user events, so the structure of the event will not detect by definition. You must write to the command by using the property node "Value (follow the signs).

    That said, your small watch of your code starts to raise red flags in my mind with the use of variable and global variable local. While it's not bad, their abuse can lead to the poor programming architecture and race conditions. Perhaps you should consider downloading your VI any kind can someone take a look and offer suggestions on improving it.

Maybe you are looking for