ActionScript 2.0 :: Incrementing A Variable With Buttons?
May 20, 2005
I've followed several tutorials on how to do this, but my dynamic text box always returns a value of "Nan" when I try to increment it's value.I've been trying to use Code:_root.total = _root.total + 1;] in an on release function. Even if i managed to get this to work though, I still need to reuse the variable i'm incrementing within other calculations.
View 2 Replies
Similar Posts:
Feb 18, 2012
When the user presses the space bar, I'm trying to take one string from a series of strings labeled c1-c9, break it into an array, display that array, and then increment the linenumber variable at the end of the function so that the next time the space bar is pressed, the next string in the series is traced and so on and so forth. Here is the relevant section of script (the strings and the linenumber variable have been declared earlier)
[Code].....
Every time I press the space bar, though, I just get the traces of the initial string and linenumber value repeated without any incrementing. I think it may have something to do with the "this" before the bracket in this line var displayarray:Array = this["c" + linenumber].split(" "); which I found in a code sample on some website and do not understand at all, but I get compiler errors if I try to join the "c" and the line number without the "this" there.
View 1 Replies
Sep 28, 2009
I'm working on a flash movie that involves the use of rotating 3 objects in a matter that the first one moves 18000 degrees cw according to the value in the 'num' variable. The 2nd object rotates -1800 degrees. The third one rotates 180 degrees.
What I actually want to do is create a movie of the older analogue electric meters that had the 5 dials that represented each digit so if the far right dial moved from 0 to 5 the 2nd would move the opposite way to be between 0 and 1 and the third a hair to the right of '0' and so on in increments of 1/10.
When I run the below code the dials ( I currently useing jetplanes until I draw or locate a pointer image file as well as the circle with 0-9 marked off in it) stay on 500 and should be moving a bit since I have another variable that increments num by 1. I tried using the Timer event and would get several errors. I also know that the way it runs now doesn't work since num is going to be assign the same value of 18000 since I have it setup to gotoAndPlay(1) in frame 2. How would I be able to have it so that so it would increment without getting undefined variables. I also tried a for loop to increment the num but the stage would instantly show the end result after the loop was done.
code
--------------
var num:Number = 18000;
var i:Number= 0;
[code]...
View 0 Replies
Mar 15, 2012
I basically have a text file with a username variable that assigns usernames to username1, username2, and so on. I would like to create a loop that checks to see if that username was created and if it was a conditional statement will follow. The problem I have is I want to do a loop with a counter(var i) and increment that counter in the loop and concat that with loginName to input that into a dynamic textfield labeled loginName1. (Actionscript 2)[code]I am using loadvars to load 2 text files, one has username and ip(username1 = blahblah ipaddress1 = blahblah and so on), the second file has an array that has ipaddress and data usage passed in an array. i want to check how many usernames there are and check the ipaddress of that username against the other file containing ipaddresses and usage.) I have everything setup, but im running into issues when writing a loop to check for username1, username2, and so on.
View 2 Replies
Jun 17, 2011
i'm trying to add values to a variable.[code]a simple drag and drop on a MC.i would like to store the X displacement when i drag. let say i have 30 in a variable wich store x position of myMC, if i drag the MC 200 units the variable should read 230 and so on.
View 2 Replies
Aug 13, 2008
I have a script which places a clip on the stage (well, just off it), and rotates the clip and then tweens it to a certain x/y coordinate based on the rotation using TweenLite, and all of this on a setInterval of 2 milliseconds. That works well. Thing is, I don't seem to be able to set a unique name based on the clipname and an incrementing number. Basically (and this isn't the whole thing, this is just the general idea), it goes:
Code:
interval = setinterval("dothis", 2);
var increment=0;
function dothis(){
attachMovie(movieICall, "movieICall" + increment; 1)
movieICall._x = ;
_y= etc;
increment++;
}
So when I set the interval to 2 seconds, it moves everything well and there are no problems. When I set the interval to 2 milliseconds, the clips only get just onto the screen before disappearing. I've tried creating a function to handle the x,y, tween. So I could refer to the clip with a "this", but it doesn't change anything. The only thing I can think of is that movieICall is not incrementing, and every clip on the screen is being referred to as movieICall, in which case the next case of x, y, tweening overwrites that last one and effectively kills the last one (but then why is it not just left sitting on the screen)? I tried adding an overwrite: false to the end of the TweenLite, but that only let the tween happen once and then...nothing.
View 1 Replies
Dec 10, 2004
I have a for statement, using an incrementing variable "a." A dynamic amount of herbs are generated, so here is the for statement.
Code:
for(a=1; a<_global.herbAmount+1; a++) {
var herbMC = _root["herb"+a];
trace(herbMC);
}
When I trace "a," it traces 1, 2, 3 or however many numbers there are up to the global herbAmount number. When I trace _root["herb"], _level0.herb pops out. When I add "a" onto _root["herb"], undefined is traced....why?
View 8 Replies
Jan 5, 2009
if i wanted to modify the xy size properties of several pieces of media through a looping function and an incrementing variable how could i do it? resize multi objects through loop & incrementing variable
View 1 Replies
Oct 31, 2010
I am trying to make a simple mp3 player using flash. The songs are loaded using an XML file which contains the song list. The following code is inserted into a new keyframe.
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.*;
import flash.events.MouseEvent;
[code]...
The problem over here is in the nextSong() function. I am unable to preserve the value of currentIndex. Although I am incrementing currentIndex every time the function is called, but the value remains unchanged.
View 1 Replies
Mar 29, 2010
I try to increment each 2 hours but I don't know how to proceed.
View 2 Replies
Oct 3, 2009
Just having problems with incrementing the x property of an object by 0.01 using a timer.It works with 0.1, but does not seem to work with the value 0.01 (commented code).[code]
View 3 Replies
Nov 16, 2009
I'm trying to get a text field that behaves like a fake hit-counter. Adding random numbers and getting larger each time:
My code doesn't add up though, it just replaces the text each time!!
var incrementTimer:Timer = new Timer(1000,0);
var lastNumber:uint = 0;
incrementTimer.addEventListener(TimerEvent.TIMER, incrementNumber);
incrementTimer.start();
[Code]......
View 1 Replies
Apr 24, 2010
I've solved this problem in AS2 but I can't seem to sort it out in AS3.[code]...
View 1 Replies
Jun 13, 2005
I'm trying to create a spinner for different ads for an advertising company website. Each ad has a name, such as "out" "pie" and "bigger". All of them are turned off except "pie" to start off with:
Code:
//initialize movie
var itemArray:Array = new Array();itemArray[0] = out;
itemArray[1] = pie;
itemArray[2] = bigger;
[code]....
The thing is, I can' figure out the button script to cycle through this array. I want to click a forward and back button, lets use forward for now, and do something like (don't mind the syntax):
Code:
on (release) {
i+1, remember the spot, and make everything else invisible.
When you click again, you increment to the
next ad/instance name and so on.
}
What is the actual syntax for this?
View 3 Replies
Jan 6, 2007
I'm working with a gallery grabbing images from data extracted from an external XML file, and I'm trying to make it work in a hierarchical or folder like structure in Flash 8.For instance, thumbnails are displayed on load, and when a thumbnail is clicked, more thumbnails specific to the image clicked are displayed.As sort of a beginner to Flash and ActionScript, I've been working with this project for a couple months.There is one obstacle I'm facing within the 'for' loops I'm using.First, an example of my XML file is like this:[code]This way displays the catalog look just as I'd like, but it is only good for the first piece of art since this 'for' loop only loops through the <products> node within the first <art> node. Now, if I change 'this.childNodes[0]'to 'this.childNodes[1]',I can display the <products> for the next <art> node.The part that I have not been able to figure out is how to increment that 'this.childNodes[x]' so that I can use it in an onRelease function.
View 4 Replies
Feb 3, 2012
I have a problem creating scores in my game. how can i stop it from incrementing +1? [cod]e...
View 2 Replies
Mar 6, 2009
Just getting up to speed on looping and incrementing variables. A real time saver.I have a onRelease function that I would like to apply to several button objects:
phase1a.but1.onRelease = function() {
p=0;
thisImage();
}
I need the p variable as well as the target but1 to increment. This is my first attempt:
for (n=1; n<=23; n++) {
phase1a.but[n].onRelease = function() {
p=[n+1];[code].......
I get a good trace on n showing that the incrementing is successful but nothing on p when the button is clicked and no execution of the function thisImage(). Not getting any errors either. Can you not loop an onRelease statement?
View 13 Replies
Jun 2, 2009
the user needs to select an answer from a dropdown list. I am then creating an array that will store the answer to each question when the user clicks the submit button. Each of the drop down menus is named sequentially. So what I am trying to do is write a while loop that will increment through and read each of the values into the array so I can process the responses later. The issue that I am having is writing the syntax to recognize the Instance name of the specific drop down I am trying to reference.
Here is the basic code I am using:
var Store:Array = new Array(2);
public var Increment:Number;
Increment = 1;
[code]....
So the DropDowns instance names are DropDown1, DropDown2 etc... It works fine if I manually enter in each instance name (but there are 43 total and I don't want to do each one individually).
I am assuming that I need to setup some sort of variable to temporarily add the increment number to the "DropDown" and then use that as the reference:
Increment = 1;
while (Increment <=2){
ItemNumber = "DropDown" + Increment;
Store[Increment] = MovieClip(Scroller2.Form_Scroller.content).ItemNumber.value;
trace(Store);
Increment++;
}
But when I do that, I get the following error message:
TypeError: Error #1010: A term is undefined and has no properties.
at combotest/submitted()
I assume this is because it is looking for an instance of ItemNumber instead of the instance of the value of ItemNumber.
View 5 Replies
Aug 31, 2006
I'm working on a class which extends MC. I would like to be able to do the same as this line: movieclip._width++. I already havewritten the function which modify the status of my MC and works perfectly. But now I want link it to a property, so any variations applied to this property calls the function and modify the MC.
View 1 Replies
Jul 1, 2010
i have a set of images with incrementing names image1, image2, image3 etc and i have a series of empty movie clips on the stage also with incrementing names mc1, mc2, mc3, etc
i wanted to use this:
mc_empty.addChild(my_loader);
to display a series of images into the series of movieclips on stage my_loader is an incrementing variable, and that works fine with the .addChild however, when specifying what addChild is loading content into, it doesnt seem to favour variables as names, it only seems to like real instance names thought i could use
getChildByName("mc_empty"+num)
like this:
getChildByName("mc_empty"+num).addChild(my_loader) ;
but that doesnt seem to work with .addChild either
View 7 Replies
Jun 23, 2009
I'm adding several similar movieclips to the stage with a 'for' loop. However, I'd like to increment the position of each movieclip when added on to the stage. I know exactly where I want each movie clip positioned as well. At the moment I just have a small 'for' loop which setups the movieclip. Like so...
[Code]...
View 1 Replies
Mar 13, 2011
I am working on an app, where the server time needs to be displayed on a Flex app.
The idea is to make a BlazeDS remoting call getServerTime() once during the app intialization and then use a local Timer class to keep updating the display.( I don't want to bombard server with getServerTime() for each second). My question is, once I have a AS3 Date object. How do I increment it by seconds?
[Code]
View 1 Replies
Jun 4, 2010
I have set up a roll_over / roll_out listener that works for me, but the event only applies to "inBulb_mc". As I have it set now, a bunch of squares are blinking through random colors. I want the mouseover to pause this event no matter which mc i mouse over. Is there a way to indicate that this should work for any instancename "inBulb_mc"+number.
using a variable such as i=0; i++ ; won't work because i need it to happen wherever the mouse is.
Quote:
inBulb_mc.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
inBulb_mc.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
Is there a way to set it up so that the listener works for all instances of inBulb_mc, be it inBulb_mc0 inBulb_mc1 inBulb_mc2 etc
View 3 Replies
Feb 2, 2010
is there any way to increment a display number up or down my clicking / holding a button?
im making a project to select a fuel tank capacity and want the default to be 0.0 gallons and have the user increase the number or decrease the number by clicking and up or down arrow button... If they hold the same button that function would ideally increment faster, perhaps by multiples of ten until it reached a max / min number.
View 16 Replies
May 13, 2011
I have a list component that lists certain items..
so, if i click on a certain item..i should get the index this way : var clickedIndex:int = listID.selectedIndex; but how can i count the number of times the variable clickedIndex has been selected? so, if a user keeps clicking on the index[0], i want to know how many
View 1 Replies
Mar 26, 2012
I am looking for a quick and easy way to store variables in a text file, rather than use amfphp to connect to a database all I need to do is increment values every time a button is clicked. Would be better if all the vars were in the same text file but if I have to have one per var that would be ok.
View 3 Replies
Jun 23, 2009
I'm adding several similar movieclips to the stage with a 'for' loop. However, I'd like to increment the position of each movieclip when added on to the stage. I know exactly where I want each movie clip positioned as well. At the moment I just have a small 'for' loop which setups the movieclip. Like so...
ActionScript Code:
for (var i:uint = 0; i<=8; i++)
{
zone[i] = new Zone();
}
I then have a long list adding and setting each mc position on the stage...
ActionScript Code:
stage.addChild(zone[0]);
zone[0].x=267.6;
[code]....
Although I've just had a thought as I was typing that last bit of code. Will I need to setup a for loop for each row...so the y position remains constant and I just increment the x value for each movie clip, and then repeat this for loop for the next row with the new y coordinate?
View 1 Replies
May 7, 2009
This one is tripping me up. I'm creating a simple 10 question 'quiz' with simple "yes" or "no" radio buttons for each question. If they picked "yes" the value is 5, while "no" is 0. I want them to be able to choose all of the answers and then click submit. On submit it would add up all the answers and save that number as a variable named "score".
I know how to setup all of the radio button groups, calling each group question1, question2, question3 etc and giving the values to each yes and no radio button. I just don't know how to capture the values on submit, add them up and save to a variable.
View 1 Replies
Jun 1, 2011
I'd like to create a tab system where the tab text is populated by an external XML file, and the tab width is based on whatever the width of the text is.
I couldn't just use button symbols because when I resized them the text got squished
View 2 Replies
May 21, 2010
I'm making an infobox, and some radio buttons. When hovering over the radio buttons, text should appear in the infobox, and reset to default when mouseOut.
This is my current code:
Code:
// Infobox
var infoStart = ("Hold over et valg for - se utfyllende informasjon");
p_info_txt.text = infoStart
// Radiobuttons & Checkboxes - mouseover
[Code] .....
View 2 Replies