i am new to Action Script and i have the following problem:
i have global variable tabName and a button, that changes its value, just like this:
on(release){
_root.tabName = this._name;
}
and now i want to use String variable tabName to address curtain instance on stage to edit its property (actually, i want to control, which tab on tabcontrol is selected).
is there something like getInstanceByName or similar function?
thnx
You can simply use:
_root[tabName]
To access the movieclip with the instance name contained in the variable tabName.
Of course this is for clips located in the root. You can also do the same for moviclips inside movieclips:
_root.knownMovieClip[stringVariable]
Related
Say I have a class with variable var1. I click on a button & it calls pageLoadMethod() which loads the page and inside it I set var1 to 10.
Now I click on another button after page is loaded ajaxMethod() & try to retrive var1 value but not getting it's value set in
pageLoadMethod() method.
Class MyClass{
def var1 = 1;
def pageLoadMethod(){
var1 = 10;
....
}
def ajaxMethod(){
println var1; // prints 1 instead of 10
}
}
The premise of this answer is that MyClass is a controller, which I assume from the context.
In Grails the controller instances are by default created for each request - that's why you don't see changed value of var1 in the ajaxMethod.
You can make a singleton from the controller by adding this line into it:
static scope = "singleton"
After this you should see the changed value in ajaxMethod.
Another question is if this is a good approach when multiple users can access your controller at the same time - if you want to use the variable to save some state between user's requests, you should rather use session for that..
I suppose MyClass is kind of controller. Whats the scope of this controller ? If You want to keep it's state between requests, you should use Session scope.
http://grails.org/doc/2.4.x/guide/single.html#controllersAndScopes
I had saved a variables name and value to a JSON file in Dart. Later I extracted the name and value from that JSON file and now am trying to create a new variable with that name. Something like this:
var variableName= "firstName";
String variableName = "Joe";
so that:
String firstName = "Joe";
Is there a way to do this?
Short answer: No.
You cannot create variables at runtime in Dart. The compiler assumes that all variables are visible when the program (or any single method) is compiled.
The way variables are looked up in Dart is that "x" refers to a local, static or top-level variable, if there is such a variable in the lexical scope, and it refers to "this.x" if there is variable in the lexical scope named "x".
If you could add a variable later, you would be able to change "x" from meaning "this.x" to meaning something else. Already compiled code would then be incorrect.
I have a JavaFX GUI in an fxml file with its controller class defined. I have two text items that I want in that GUI, one tied to a variable whose value does not change until the user reloads the screen, the other I would think needs to be a StringProperty as it shows the running total of a column in my TableView. Because of what they are, I'm trying to use Label instead of a TextField as their display control.
I liked Sebastian's answer to this problem here:
Displaying changing values in JavaFx Label
however, when I try to use it I get a compile error that says:
cannot find symbol
symbol: variable textProperty
location: variable salesNoLabel of type Label
I'm not sure what I'm doing wrong, but to start with, my label text is initially set in the fxml file, so in my controller I just have its fx:id substituted for "myLabel" listed in Sebastian's answer:
salesNoLabel.textProperty.bind(sn);
where salesNoLabel is the fx:id of the label and sn is a string variable.
Not sure if you need to see more of my code to help me with this problem, but thanks in advance for checking it out.
Sebastian's answer had a syntax error, I edited it to fix it.
You need to invoke the textProperty() method on the label:
salesNoLabel.textProperty().bind(sn);
Note the addition of parentheses after the textProperty identifier to invoke the method.
Say I have a movieclip and within this movieclip I define some Actionscript variables. e.g.
var majorValue:Number = 20;
var minorValue:Number = 10;
By default, every instance of this movieclip on the stage will have these variables, set to these values. Now, lets say I have three instances of this movieclip on the stage, which I'll call "Moe", "Larry" and "Curly". Let's say I want to leave Moe and Larry as default instances of the movieclip, but I want to tweak the "Curly" instance so that it's majorValue is 50, and it's minorValue is 15. How do I go about doing this?
I've tried doing it by specifying:
Curly.majorValue = 50;
Curly.minorValue = 15;
In the parent timeline, but this doesn't seem to work as it seems the actionscript is executed in the parent clip first and then in the child(ren) clip(s) second. So in other words, my declaration of the "Curly" instance's special values is overridden by the clip's default declarations, which are executed after the parent clip's actionscript.
Does anyone know how to override a movieclip's default variables for a specific instance?
There's an old tip about working with the timeline which says, "if in doubt, add a key-frame". Actually, even better advice would be to avoid using the timeline altogether if at all possible.
I think your summation of what is happening is probably about right. In effect, you're trying to update the properties on the instance before it has been instantiated properly. When it is instantiated, the values are reset to the defaults.
The solution is to add an additional frame and place the code which sets the properties on the instance in the second frame (along with a stop action). This will ensure that the code is executed after the instance has been instantiated.
Is there a way to either create a new Environment Variable from within a WF 4.0 workflow or update an existing one if it already exists?
You can set a enviroment variable inside an code activity.
You can use the System.Activities.Statements.InvokeMethod activity to call the System.Environment.SetEnvironmentVariable static method.
In the Parameters setting, you'll need to pass 2 'In' parameters. The first will be the name of your environment variable, the 2nd will be the value.