Variable Changing But Then Resetting
May 25, 2011
I'm very new to Flash, but I have been learning loads and getting some good results so far. Browsing these forums has been a massive help. However today I have hit a problem in what should be almost the simplest line of code I know how to write (variable = x), and could do with some advice. I have a simple program containing a button which will change a variable when pressed. There is also a text-box that will output that variable. However when I press the button, the variable will change, but then immediately revert to it's previous value.
[Code]...
View 3 Replies
Similar Posts:
May 2, 2010
When I set up 3 input text fields, I allow the user to change the font and size of those fields. If the user selects each one with the mouse and modifys them then no problems are seen. But if the user first changes the size and font of text field 2, then tabs to that text field and starts to change the text. The font and size properties revert back to the default.
View 1 Replies
Jun 7, 2010
When I set up 3 input text fields, I allow the user to change the font and size of those fields. If the user selects each one with the mouse and modifys them then no problems are seen. But if the user first changes the size and font of text field 2, then tabs to that text field and starts to change the text. The font and size properties revert back to the default.
I could re-apply the formating everytime the text field changes, but that seems like a bandaid to the problem.
View 1 Replies
Jan 1, 2011
I made a simple class that's keeping a history of strings, updating it with a push() method (like an array) and with a possibility to navigate with next() and previous().Therefore my class has an array and a integer indication the current position in the array. (See full code below)Now something very strange is going on. When coming into the push() method the position variable has some value, which I can change, but everytime I try to read that variable, it gives me a 0. I've never had this kind of problem before and I simply cant find out what's wrong.The push() method
ActionScript Code:
public function push(entry:String):void [code]......
View 3 Replies
Dec 9, 2009
I've got a list in a flash app that when an item is clicked it should add a number to a dynamic text field, my problem is that the variable I declare to store the number in either always resets to 0/ doesn't add the numbers or returns NaN.
The variable in question is
Code:
var totalNum:Number;
What I want it to do is add the numbers when a list item is selected, e.g. totalNum starts at 0, if item 1 is selected totalNum should now be 1, if item2 is then selected totalNum should be (1+2 = 3), instead the label just displays 1, then 2.
I've tried declaring the variable outside of the event, but that resulted in the label showing NaN, unfortunately (as far as my understanding goes) declaring it inside makes it a local variable which resets each time the event is called and I'm not sure how to get around this (I can't seem to get the syntax for global variables right)
An example of my code is:
Code:
list1.addEventListener(Event.CHANGE, ItemChange);
function ItemChange(event:Event) {
var Item = event.target.selectedItem.data;
[Code]....
View 2 Replies
Oct 12, 2006
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!
Code:
// processReplace Function
function processReplace(transferFiles) {
var processArray:Array = transferFiles.slice();
[Code]....
Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".
It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.
I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.
Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code
View 1 Replies
May 3, 2010
I have a movieclip called 'Sitecontent'. Within this movieclip I'm using a variable to determine on which page my website is. The pages are seperate movieclips which I load throug addchild.When I load (for example) page 1, it start playing a openingAnimation which stops at a specific frame. After it stopped, I want to update my variable in the SiteContent mc. How to acces the variable from a other movieclip?
View 4 Replies
Jun 16, 2010
I have used setProperty up till now, and it have met my needs needs so far.However, this one thing it cannot help with:
I have several different textfields all within different movieclips. I want to only change the content of only one of these textfields, however which textfield is changing all the time. Therefore the path of the textfield that needs changing has been put into a variable. Now I need to change the text of this textfield by using the variable(tempRevis1). i placed the path of the textfield within a variable:
_root.tempRevis1 = "_root.level1a_mc.AIRB237_mc.textMe1_txt";
Now this is what I hoped to have done:
setProperty(_root.tempRevis1, text, newTextValue);
View 0 Replies
Mar 29, 2004
I have one swf file that containes a mc using an easing function to move an arrow around.That mc has the instance named myruler. The arrow moves based on the value of a variable named "y". This swf also has a mc that I use as a container to load movies into.The movies that are loaded into the container mc have buttons that I would like to use to change the value of the variable "y" in the movie clip named myruler found in my base swf. Did that make sense? The code I'm trying to use on those buttons goes as follows:
on(release){
_root.myruler.y = 300;
}
The my ruler movie is in the swf that loads the swf with these buttons. So how do I point to that original swf.myruler.y?
View 2 Replies
Apr 29, 2003
I�m having some trouble with changing the value of my variable.I declare my variable in the first frame of the _root timeline.
currentSlide = 1;
When the _root movie plays it stops on a movie clip that contains four sub movie clips each is labelled sequentially( slide1, slide2, slide3 and slide4).I would like to know how to increase the value of my variable by 1 each time it progresses to the next slide. I can�t seem to get the variable currentSlide to change its value.
View 1 Replies
Jun 18, 2010
There is probably a better way to do what I'm trying to do, but I simply want to make a variable change its value when I press the arrows keys. For example if I wanted to cycle through weapons, if weapon=0 then the character is holding a certain weapon, then I press the down arrow key and weapon=1 and if weapon=1 the character is holding another weapon. And if I press up weapon=0 again so he's holding the first weapon again. And say there's 8 weapons, if weapon>8 then weapon=0 again so its a cycle. I tried arrow key functions and all they worked for was making a symbol move. I think I knew how to do this stuff in gamemker pretty well but Flash is very different.
View 2 Replies
Jul 10, 2010
I am making a game in flash, that uses several resources to build different buildings, that help you to gain resources, etc. I'm trying to make it so that the more "_global.food" you have, the faster your resources will go up. I have it so that the variable "_global.woodBoostMeter" goes up as fast as "_global.woodBoostSpeed" and when it reaches 500, it gives you 1 wood. I want it so that "_global.woodBoostSpeed" is modified by "_global.food" divided by whatever 200 is. (So that you will get resources faster for the more food you have)
Here's the code I'm using:
Quote:
_global.woodBoostMeter =0
_global.woodBoostSpeed = _global.food / 200
_global.woodBoostObtainRate =1
[Code]....
I think the problem seems to be with the "_global.woodBoostSpeed = _global.food / 200". it doesnt go up slow like it should, since "_global.food" starts out at like 200.
View 3 Replies
Sep 3, 2010
Below is decription of the file
1. I have a flash file which is loading php variable through flash vars.
2. The flash var variable contains the .txt filename in which data is kept.
3. When I open the php page the swf loads with variable having .txt filename and value containing swf path.
4. I have created timer in flash which check for change of value.
5. When value changes the other flash file loads.
6. All this works fine in all browsers except IE 7
View 1 Replies
Feb 16, 2009
im making a achievements page and i want flash to change a variable to 1 how do i do it
View 9 Replies
Jun 21, 2011
I'm working on code for collision. My question isn't about how to make it work. I have a bizarre problem with a variable that is NOT changing when I want it to.
ActionScript Code:
public function movement(e:KeyboardEvent){
var yesobject:Number = 0;
var thecode:Number = e.keyCode;
if(thecode == Keyboard.LEFT){
[Code] .....
I've had this problem before. the trace(); commands outputs so why does the variable not change even though it's in the same if statement?
View 1 Replies
Jan 11, 2012
trying to make my first game using flash. I have done the main thing, setup a character which can be moved by the user to catch some falling balls. Every time a ball is caught, the score goes up by 1. To count and display the score, i have used a number variable called "caught" defined in the main timeline with initial value 0. The main timeline has only 1 frame and stopped by codes in the level "action". The "caught" variable is used in many movieclips in the scene and its value changes as the character catches the ball.
Now when the score is 10, i want to go to a new scene that shows a "congratulation you win" animation. For this, I have wrote the following code in the movieclip of the main character -
onClipEvent (enterFrame) {
if (_root.caught == 10) {
gotoAndPlay ("Scene 2",1);
}
}
But this does not work. The score goes upto 10 and then beyond 10.Is there anyway I can use the value of a number variable to determine when to play a particular scene?
View 4 Replies
Jul 9, 2010
To avoid a large segment of code I've set up button names that correspond with movieclips that are located in my library and exported for use with the code. I want to replace the movieclip currently on stage with another movieclip from the library depending on which button you click on. The code works fine, I'm achieving all the values I want, except for the fact that since the variables in the function are strings it gives me a coercion error saying that they're strings and not objects.
Here's the code:
Code: Select all// Holder
var holder:MovieClip = new MovieClip();
holder.x = 122;
[Code].....
View 4 Replies
Jun 5, 2006
I would like to have a button that when clicked changes a variable for 30 seconds and then changes it back. For example:
[Code]...
View 1 Replies
Jul 7, 2004
I have the following code:
PHP Code:
on (release) {
cNum = cNum+1;
for (b=1; b<8; b++) {
trace(["box"+b]);
["btn"+b]._y = ["btn"+b]._y+25;
[code]....
on release, the objects labeled btn1, txt1, box1, btn2..... should all be shifting 25pxs. It doesnt do anything.
View 5 Replies
Sep 8, 2009
Its a simple adding "game" where 2 numbers are randomly generated and you have to input what you think the answer is (userAnswer). Then it adds the two numbers it just generated to produce correctAnswer, and checks it against userAnswer. When you hit the check answer button, it moves the the score dialog frame and says whether its correct or not. But I am having 2 problems I think - 1 - I can't get the input textfield to assign the typed-in value to userAnswer (I'm trying userAnswer = inputAnswer.text; ) and - 2 - the second frame that has the score and "Correct!" / "Incorrect!" dialog can't seem to access any variables from the first frame. I've tried using two layers and keeping the variables on the second layer that spans both frames, but then the functions in the frames that you actually see can't change the variable to update it with the user's input.
View 3 Replies
Nov 13, 2009
i have a probleme changing the value of a variable in movieclip from my scene. i explain: I have combobox on my scene containing categories,and in the scene i load an xml file containing links to php files that work with the combobox.Also on the scene i have a movieclip "filmstrip", inside this movieclip on the first frame i have a script loading the php file selected in the scene. i use a load() function with a variable "theUrl" inside like this : T.load(theUrl);.In my scene i want to change the value of "theUrl" inside the movieClip filmstrip. I tried filmstrip.theUrl = url; But it doesnt work
the xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>[code]....
View 7 Replies
Feb 13, 2009
I have a problem with setting dynamic variables. How do I retrieve a value from a variable who's name is dynamically changing?
Example:
variable1 = 1,
set variable2 = variableList(variable1);
so...
if variable1 = 5,
then variable2 = variableList5
How do I do that?
View 0 Replies
Jan 9, 2010
I have a code, it is below. And i have two vars: coordx and coordy they both are 0 but when up button is pressed, coordx should change into 1 x remain 0 just like map scrolling and if pressed down it should return to default position, but instead of that variables keeps reseting and it starts from beggining. Here is the code:
ActionScript Code:
var coordx:Number = 0;
var coordy:Number = 0;[code].......
View 3 Replies
Sep 3, 2010
I have a website that I have to alter the <title> tag that shows up in the browser as the sites name through using Flash as3 and xml. I was wondering how to access the <title> tag so that I can create a variable in flash, that retrieves whatever string is within the <title> tag of the current xml document that is being accessed? All pages need to have the same title, so it doesn't need to be too complicated, I just need to be able to alter the tag through xml and as3.
View 1 Replies
Jan 27, 2011
Beginner question here. Basically I have the following code:
if (_root.obj1 == 1) {
n = _root.invArray.length;
_root.obje1._y = _root.inve(n)._y;
[code].....
View 1 Replies
Sep 24, 2009
I want to add some input fields together and can't seem to do it..
test_btn.onRelease=function(){
total = Number(input1) + Number(input2);
}
In the total field I get 'NaN'
View 4 Replies
May 4, 2007
I need to hold a couple of variables in an outside file that can be incremented by user activity -- not just during one interaction with the swf, but with every one.I have no problems with using loadVars and I get the loadandsend process; it is just that I have
no background in cgi or asp for holding the variable and being able to update it.I know I cannot write to a txt file -- that is what I have been using thus far with loadVars for importing values, but this will not help me here. I know it should be a fairly simple script -- I also know I ought to pick up php, but for the moment -- until a greater amount of time comes my way -- I turn to you.
View 3 Replies
Jan 11, 2010
I'm trying to change the colour of a movieclip.I want to send a variable from Javascript within the html that the swf will be embeded in.I'm not quite sure where to start with this but this is my code:
[code]...
View 3 Replies
Jun 30, 2010
I set a variable var currentPage:String = "b1"; When I click a button, the click should change the variable currentPage to the event.currentTarget.name and it does
[Code]....
View 9 Replies
Jan 14, 2012
I'm trying to change a varialbe in a seperate class from inside a movieclip that I have on the stage in the timeline, but the variable I'm trying to change keeps coming up as null instead of what I am trying to change it to. How is this usually done?
View 6 Replies