Flash8 :: Variables That Can't Go Below Zero Etc
Aug 4, 2010
just getting the grip around the variables and im experimenting. This is what i have as a variable
money = 1000;
health = 100;
Then i have the dynamic textbox that shows them. works great, and i also have various effect that makes the two go up and down. Here's the problem, or more, how i would like to expand the concept but is stuck on. Right now both variables can go as high and low as possible (of course). Is there something i can add in that script that makes so the money variable can't go below 0. Also is there something i can add so that the Health can't go ABOVE say 500 and when health reaches zero (or a negative) this triggers _root.gotoAndPlay("gameover"); you get what im trying to achive here
View 15 Replies
Similar Posts:
May 31, 2009
Is it possible to put variables in an array?
For example:
Code:
var positions:Array = new Array(Stage.width / 2, Stage.height / 2);
When the above code is executed, the values "Stage.width / 2" and "Stage.height / 2" are replaced with the number values and the array becomes, for example [500, 400].And when I call the array positions[0], instead of getting the value of the Stage.width / 2 (considering the stage has been resized), I get the static value of 500.What can I do to get the value of Stage.width / 2 ?
View 1 Replies
Feb 11, 2010
My variable from the root timeline is not being sent to say a timeline inside a moveclip. This is basically my code:
On root timeline:
Code:
stop();
showred = false;
Inside movieclip instance 'infobox' on timeline:
Code:
stop();
if (showred == false){
play();
}
the showred variable inside the 'infobox' movieclip is not detecting that I set 'showred' to false on the main timeline.
View 2 Replies
Feb 28, 2010
what is wrong with this syntax
_root.range+towerID = 75;
i want flash to read the variable as _root.range2 = 75. this is for each tower so _root.range2 -= 10 reduces tower 2's range by 10 (this is done on a different frame thus the _root. is needed)(towerID is calculated above)
View 1 Replies
Mar 3, 2009
Ive got a script lined up:
Code:
onEnterFrame = function(){
if(aktiverPublisering == "true"){
function avpubliser(){
[code]....
Ive checked if "aktiverPublisering" traces "true", and it does (it declares "true" through a button)... So, here's the weird part...i cant get a trace inside the IF statement i.e. its not working...
View 2 Replies
Dec 25, 2010
Actionscript Code:
if (Key.isDown(attack2Key)&&shot2reload == 0) { for (i=1; i<2+1; i++) { shot2++; shot2reload = 30 var newname =
[code].....
View 1 Replies
Mar 12, 2009
So I have a laser game I'm working on and I have a setInterval set up for when the laser button is pressed that it shows the laser for a little bit before removing the incoming asteroid and hiding the laser. I have a four of these buttons each with different colored lasers. So I thought it would be easy to pass the movie clip in through the function, cause I've done that with regular functions. Problem is, I don't know how to do that with a setInterval function. The way I have it set up shows the lasers then crashes and just shows a blank screen. Here is a bit of my code:
Code:
function laserMultiFire(laser:MovieClip) {
if(astroid == true){
_root[laser + "L"]._visible = true;
[code]....
The btnMulti is one of the buttons, and there are three movie clips that represent the lasers, the ones I'm trying to show and hide here are mcLaserMulti, mcLaserMultiL, and mcLaserMultiR.
View 1 Replies
Jun 12, 2009
I want to reference clip with some variable name because i want to change dynamicaly target clip. Example:
myMC="testClip";
myMC.my_txt="some text";//this doesn't work
//but this works
eval(myMC).my_txt="some text";
I guess eval() is not right thing to do.
View 4 Replies
Sep 11, 2009
I've read on the net that actionscripting from the action layer will result in a more readable file once published, as apposed to attaching onClipEvent functions which slow down readability.
For this reason I am trying to add variables to a MovieClip I have on the stage with an Instance Name of Player. However I wish to assign the MovieClip variables from the actions layer using the MovieClips Instance Name.
[Code].....
View 5 Replies
Dec 4, 2009
I'm trying to import some variables set up in a .txt file. However the variables that I would like to behave like numbers are not doing so.
I have a variable in the text file called "&middleimg=1" when I pull this in and say do the following:
Code:
var numvar:Number=0;
numvar = _root.myvars.middleimg+1;
I get "11" rather then "2" as the result. I tried setting up my text file as such: "&middleimg:Number=1" but get an "undefined" result. Is there anyway to get imported variables to behave like a number instead of a string?
View 2 Replies
Jan 7, 2007
how to pass variables from a parent swf to a child swf loaded into a movieclip container within the parent swf.
View 6 Replies
Mar 31, 2009
Is there a way of tracing variables in an object without expressly listing each of them?
e.g.
Code:
so.data.thename="derek";
so.data.thenumber=1234;
so.data.sex="male";
[Code].....
View 1 Replies
Jun 26, 2009
I am making a game using AS2, in which the user controls the character with WASD. I am making a tutorial level in which the level only advances past the first frame after the user has pressed W, A, S, and D. The level is a single frame in which there is a movieclip that has all the enemies. I made an offscreen button in the movieclip which has the code
Code:
on(keyPress "w"){
var w:Boolean = true;
}
[Code].....
When I run it, nothing happens and it stays on the first frame of the movieclip. No errors are shown in the output panel.
View 2 Replies
Oct 24, 2010
I programming a calculator, I get data on Yahoo Finance ( URL... ), but sometimes I get this error "NaN".URL...[code]
View 1 Replies
Mar 21, 2012
I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.
View 2 Replies
Aug 20, 2008
How do variables true/false custom variables work in flash?
For example, what I want to do is create a simple true=false variable that I can call on an if statement later.
For example:
Code:
Var1 = true;
if (!Var1)
{
[Code]....
I noticed that neither the "Var1 = true;" part or the if(!Var1) part worked in flash.
View 4 Replies
Feb 21, 2009
How can I make a bunch of variables from a for loop. for example for (var i=0; i<total; i++) {var bunch(i);}. that i make a bunch of variables named bunch1, bunch2, bunch3. I keep getting errors. I program and use so many different languages that I dont know if that can be done with AS3. my only other alternative i can think of is to create some sort of event dispatcher object array. but I dont know how to get them all to send events to one listener with there index number.
View 5 Replies
Jul 30, 2010
I have a list of strings that I add to an array, then attempt to set those values in a for-loop using data that I read in. The array gets updated, but the values the array contains do not. I also have an array of buttons that I update this same way that works great, but strings don't seem to work the same way. I have tried moving the string array to give it full scope, and still nothing...
public class test extends Sprite
{
// Declare a list of strings
protected var title0:String = undefined;
[Code]....
View 1 Replies
Jun 15, 2010
I'm writing code that takes data from mysql that's processed by a PHP script. It's actually a bit bizarre, at least to me. Anyway, here's some basic AS3 code that's moving toward what I want to do:
var loader:URLLoader = new URLLoader();
var urlRequest:URLRequest=new URLRequest("receive.php");
urlRequest.method=URLRequestMethod.GET;[code]....
For some reason, the statement "trace(evt.target.data);" produces a whole pile of garbled text before the actual stuff that it's supposed to show Because of problem #1, I've had to include a throwaway variable at the beginning, otherwise the first variable I try to pass into AS3 comes back as undefined. This causes errors when I run my flash movie in the IDE, but when I run it from the browser it doesn't seem to have any effect.But this is the strangest thing of all whenever I make any changes to the database (and subsequently try to load data from different variables), the new variables come back as undefined. For example, let's say that I add another entry to the database, and decide to load students 2, 3, and 4 instead of 1, 2, and 3. When I do that, any new data I've added comes back as undefined, even though when I view the PHP output in my browser, it looks just fine.
And now for the REALLY bizarre part: I'll copy that output, paste it into my PHP script as an echo statement, comment everything else out, and my flash movie runs fine. Even though the output from the PHP script is exactly the same, it gives me errors.
View 9 Replies
Jul 11, 2011
There is a bird, and you control its upwards movement with a key. It has thrust, gravity, it works fine. The problem is I have a bunch of icicles that come at the bird that he is supposed to avoid. I tried this first with math random to use as an x coordinate and than move across the screen, but the icicles had the same x-coordinates sometimes. I tried does not equal(!=) but that doesn't work. I made an array and each number that came out of the array I assigned a different variable. This works fine. I put this variable into the x-coordinate such as mc.x=((n)*60)+480. I did this for five different icicles. All their differnt variables have a different value, and I put them into the same function for each individual video clip, but they still don't go to the right coordinate. Here is the test code just for the initial coordinate of each icicle before it moves...////////////////////////////Quote:
var temp:Array = new Array()
for (var i:int=0;i<8;i++) {
temp.push(i);
[code]......
View 1 Replies
Apr 9, 2011
i am trying to do a loop to create several variables to aasign each one of those variables one number.when i write
[Code]...
View 4 Replies
Aug 5, 2004
I have 2 loadVars - myVars, myPictures
basically i have defined their onLoad functions
so in myVars, i call for
Code:
myPictures.load("http://www.fakedevil.com/lurgee/pictures2.php?id="+this._parent.link2.text+"&time=" add getTimer(), "");
pictures2.php is working cos I just check so by rite the variables loaded should change.. but somehow each time I check those variables in myPictures.onLoad, the variables are always the same.
View 5 Replies
Nov 19, 2008
I am trying to load variables from a text file, and have them available from then onwards in the movie, globally so to speak.
While I can read the variable values in a loader function which executes when the text file is loaded, I don't seem to be able to keep those variables available afterwards.
View 10 Replies
Jun 20, 2009
I'm trying to figure out which is more efficient in terms of memory and speed. What I'm doing is having a series of messages loaded to the screen. Is it just faster to write them in string variable or in an XML document which is more versatile in terms of editing and adding on to the document.
View 1 Replies
Jun 8, 2006
iam trying to append 3 variables to a url that already has 2 variables appended .. iam using the LoadVars -> "send" method but it wont work. it works if i use a url like "form.aspx" but it wont work if i use "form.aspx?var=nun" which is what i need so i can append 3 more variables to that URL.
View 1 Replies
Jun 4, 2010
I have several objects that have similar names, like slot1, slot2, slot3, etc. I also have a function that is supposed to do something to the first object, then the next, then the next, etc each time a button is pressed. Is it possible to insert variables into other variables? So say I have a variable called n that is increased each time the button is pressed. The function is then applied to slot"n" each time the button is pressed.
View 5 Replies
Jun 30, 2009
I am making a simple math quiz game that generates two numbers randomly and then the user has a keypad to enter the answer. I trace not only the real answer to each question but also what the user punches in and I even have it so that it checks to make sure the user's answer is correct.
What I need now is to find a way to export that data into an html page. I think I can do so with php, but I really need it to go into javascript. Does anyone know how I can send this data, either in a string or as integers to Javascript? I believe that the integers would be best.
[Code]....
View 5 Replies
Aug 4, 2005
dynamic text box and what is loaded into it. the function for my buttons defines a new variable "newChoice" and sets its value to the "this.varTitle". It then tells the movie clip containing the text box gotoAndPlay (2). At that point the text box should update to the value of "newChoice" but it doesnt work.if i tell it to update something absolute, like a string, it works, but i think there is a problem with the layers of variables i'm using.
main function:
playDots = function () {[code]......
View 6 Replies
Feb 2, 2010
I want to my flash gallery to get the variables at the end of the url (ex: artGallery.php?page=2) How would I beable to get the 2 into a variable in as3?
View 5 Replies
Jun 23, 2010
Is it "better" to initialize AS3 class variables in the class constructor? Or can I just initialize them to their default value when I declare them at the top of my class? I ask because when there's a lot of class variables, it appears inefficient to declare them in one place and then initialize them in another when I could easily do both in the same place. It one option is better than the other,
[Code]...
View 2 Replies