ActionScript 2.0 :: Unable To Use The If Statement
May 5, 2011
i'm trying to use if statements but can't get this thing to work i want to check if another button is visible on release of a button to determine what action to be taken. the 'gotoAndPlay("firstscene",1)' is just there as an outcome, will be changed later.
anyway this is the code i've got on the button i'm pressing. blobyellow2 is an instance of a button blobyellow is it because it's an instance that it's not working?
on (release) {
if (blobyellow2._visible = true) {
gotoAndPlay("firstscene", 1);
}
}
I'm creating a draggable movie clip (an arrow symbol) that drags along a rectangular track. Works fine but my issue is when the arrow's y axis is at a certain position, it needs to remove a movie clip instance and also run a trace statement. Right now, it's not doing that (if I change the == in the if statement to += it works but then it just works as soon as you mouse down on the arrow) and I'm wondering where I'm goofing up. Here's my code:
Having a few problems with what I thought was a simple if statement. Here is the code:
[Code]...
I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.
The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.The purpose of the application is to load an XML file(works)Populate 2 text fields with information from the XML file(works)Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);
The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.CheckBoxes are mandatory.But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.
I need to write an if statement inside an if-else statement. But no matter how I write it it keeps giving me a syntax error.The syntax error is "1083: syntax error: else is unexpected".[code]No matter how or where I place the braces, it keeps giving me errors.
the problem is obviously that the compiler reads this code rather than understanding I'm trying to regenerate the code within the for loop...does that make sense :S? So basically I need as3 to read the code between the for statement as if it is going to echo that out later. Is this even possible?
I work with Flash Pro allmost 11 hours per day and every while i get a error which messes up everything. Approximetly i get this after about 2-3 hours withevery project.After i get this error there is no chance to test movies afterwards.I see a fast flash of the loader window but it dissapears so fast i cant even really see if it is loader.
I have a script which is giving me a lot of trouble since I have no idea how to write another "if statement" inside another if-else statement. I keep getting errors, I guess I don't know where to put the braces exactly...
example: if(bla == bla) { <------------how would I write another if statement here? }else if (bla == bla){ }
I have a site that plays either .mp3 or .flv files depending on what is selected from the menu. Menu loads in from xml. I get "unable to make connection with server or unable to find flv on server" when I try to play the video. But the video and audio files are all in the same directory and the mp3 files play fine. I think I'm having a problem with the setMedia command. Here's the code that loads the video and audio files.
I have a movieclip on the screen called "mc_bg". Within this movieclip are 7 movieclips called "barrier1" through "barrier7".From main.as I want to be able to do this call:
for (var i: int = 1; i < 3; i++ ){ trace("got here") trace(mc_bg["mc_barrier" + String(i)])
So I've been reading a lot today about the with statement performance, readability and stuff like that but i'm still not sure whether i should or should not use the with statement in AS3.
Using the with statement seems the same as creating local var which would carry the reference.
I am sending my header location to some variables in flash from my php page.For example when i am in the homepage then the header is:
&from=sitemap&product_id=1
What i want to do is tell the flash to go to one frame if it is the homepage and to another for any other value of products_id.What i have in my actionscript is this:
ive got an array of cards 2-10 plus jack, queen, king, ace and i'm pulling members from the array at random--in order to score it, i decided to check the first character of the string and see if it returns a number or not.if it's a number, add the number to the score, but if it returns 'NaN' (not a number) then it will just add 10 to the score--so even tho NaN is defined as a variable in flash, somehow my if statement 'char==NaN' isn't working...
Inside the movieclips I have some code. In this code I need the index-number of the movieclip. I'm staring the code off with: var indexr:Number = _root.i; The for-statement is so fast that all the movieclips get number 9 in the index-variable! Is there any trick to manage this, like can I get the index from the name in some way? Or do I have to work around it in some more or less complicated way?
Is it possible to have more than one condition on an if statement?eg. if something is black and if it is 40cm then do the following..both conditions must be fulfilled before the action can occur.
I'm about to start a game/quiz project where the user must click several buttons, one after another (though not in any special order) to answer a question:[code]Is this the right approach and way to add variables in an if statement?
I have been asked by a local web development company to code some flash banners for use with there banner ad site they are doing. I have been sent a banner to add the actionscript and also the actionscript as well. What I have is a fla doc with a button that covers the whole banner. Then on the banner I have this actionscript:-
on my main timeline i have a movie clip called "screen" within that i have a dynamic text box for inputing a number. var for text box is txt_1
on the same timeline i have another mc called "animation" withing that i have a mc called "prizes" there are 2 animations in the prizes movie clip that are supposed to run based on the if statement...i have an action assigned to the prizes as below:
//this.onEnterFrame = function () { if (_root.screen.txt_1 == "11111") { prizes.gotoAndPlay('prizes1');[code]........
but this is not working...basically i want to say that is the text that was inputed was "11111" play the first prize animation inside the "prizes" mc, and if its "22222" play the second prize animation in the "prizes" mc.what am i doing wrong?
Now i need to hide the sample_mc that is already on stage only if a clip is loaded... on the else statement sample_mc should be visible again..So...i dont know how to say that in AS2 language...
Actionscript Code: If clip is loaded , sample_mc._visible = false; else sample_mc._visible = true;
Does it exist in actionscript a between statement? If I would search for a value that is more than 2 but less than 4. Is there like a >2<4 statement I could do?
I have FLV files that continue playing when I leave the frame that they are on. I can stop the playing FLV by putting this code on the following frame:
if (demo.playing) { demo.stop();}
Where .demo is the name of the instance of the .flv component.
Here is the problem - I have many frames with many flvs, and when I tell flash to stop multiple FLVs, for instance:
if (demo.playing) { demo.stop();} if (demo2.playing) { demo2.stop();}
I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference
As far as I know, flash is telling me that since the instance of "demo2" has not started playing yet (ex. the user only went to the page with the "demo" flv, but not the "demo2" flv yet) that flash has no idea what demo2 is yet. I thought using a conditional statement would remedy this, but I suppose the .swf can't stop playing something it does not yet know exists.
Is there any way I can introduce all of the flv's at the beginning of the file, yet not have them play and not have flash "forget" about them so that I can stop them using the code above? Or is there a way to have the conditional statement not error in the event that the referenced instance has not yet been "introduced"?
I really wish they would have added an "exit frame" command in AS 3.0...
I'm sure I have the conditions and statements typed in wrong. Here is the original code:[code]only now I want to add an if/else statement so that if none of the mouseDown conditions are met, it then goes the the Timeout variable:[code]
What i am trying to attempt here is to make the variable equal to the name of an item in my library. (Im using this to use different ships in an old arcade-style vertical shooter). This is meant to make a ship appear on stage.
When <variable> is replaced with a library item (eg. mvcShip), it works fine, but if the variable is in place, i get a trace value of ship1 as "undefined", and the ship doesnt show up on the stage.
have a very common function i use in educational quizes that self rate the user depending on their score (resulting from answering multiple choice questions). So I have set up a variable called score no trouble...but when i implement my trust "if else" heuristic from AS2...i get all these errors and my flash file does not work.
stop(); if (score <= 5){ endMsg.gotoAndStop("score1");} else if (score > 6 and score <= 11){ endMsg.gotoAndStop("score2");} else { endMsg.gotoAndStop("score3");}