ActionScript 3.0 :: 'Break' In The Last Switch Condition?
Dec 27, 2011
Why would we use a break in the last condition? Wouldn't it already get out of the condition at the last one possible? For example:
ActionScript Code:
var n:int = 3;
switch (n) {
[Code].....
I've seen numerous examples using a break in the last condition in several languages (namely AS, JS and PHP among the ones I remember) and always thought why, but couldn't find an answer. I don't see any difference between using it and not using it, although I might be missing something.
What I'm trying to do is create a program that, depending on 2 variables, multiplies another variable by a static number. Heres the code I have so far:
Im trying to create a program that, depending on 2 variables, multiplies another variable by a static number. A friend suggested I use case/switch instead of if/else statements,which is what I was using before.
I'm working under as2 with variables in a web site navigation, i want to create a condition, a simple condition, for frame controling but i'm not sure how to code it.I have the content_fade_out variable, whenever a user clicks a navigation button, the variable should be checked to see wich movie clip to play. I know i can do it with an if but, if i do it with a "if" I would need add 5 ifs to each button, while i think somethin like this can be done:
variable value = Y y = 0 _root.home_mc.gotoandplay y = 1 _root.galery_mc.gotoandplay....
and so on, I'm just not sure how to set the variable value condition.
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 need to specify more than one condition for visibiltyvisible="{data.allow && data.open}"However, this gives the error "The entity name must immediately follow the '&' in the entity reference."I could use a function, but I'd like to know if it is possible to do this directly with different syntax.
for i know that i often fail when it comes to syntax, i thought i might ask how the syntax would be if i'd want to ask if two variables are set. say i'd want to let things happen if the variables _root.move==1 and at the same time _root.window==0.
in this piece of code:
onClipEvent (enterFrame) { if (_root.move == 1) { if (_root.mainVarX == 0) {
[Code].....
my problem is, that i let something scroll in front of a button on mouse release, and flash now thinks that i left the button and thinks it should fire up stuff that should happen on rollout, which shouldn't when i mouse release on the button.
I have 5 movie clips on stage made invisible. Each time only 1 movie clip appear randomly. The next movie clip appear on condition that the previous movie clip must disappear by pressing of a button. Example: mc - A,B,C,D,E
If B appear, a button must be pressed to make B disppear in order for the next button to appear randomly.
So, what I'm trying to do can't really be that hard, I still can't get it to work properly...
So, I have two textfields and one button. Whenever I type a set message into one of the textfields and then press the button, I want the other textfield to return another set message. Probably the trickier part: this should work both ways.
Is it possible to use a for loop within an if condtional statement? I have been trying but just get errors no matter what I do. I have a series of buttons that pop up in a window and I want to make it so a click anywhere outside of the buttons will close the pop up window. I have been doing this by running a hitTest that checks if any of the buttons are being touched one at a time. It works, but it seems overly tedious, especially since there are a lot of buttons. I do not want to put the hitTest on the background of the window because it will cause the mouse cursor to turn into a hand even when it is not over one of the actual buttons.
If the for loop can't be within an if condition, then maybe there is a better way to use the hitTest code, but I couldn't figure that out either. Here's a simplified version of what I have now (it works, but is too much code..):
It is very ridiculous that I can't remove a simple listenermethod :). I think this is a common problemWhen I am using removeEventListener manually, i.e outside thecondition its working fine, but whenever I am using it inside theif/else condition it is adding the listener in "true" mode but notremoving in the "false" mode.here is my code:
if (proAlign == true) { trace("align Option = " + proAlign + " -- " + "this is true part");
I have a movie clip which is brought on to the stage by a tween function called introTween. After the introTween has finished, it has an eventhandler inside it which calls on 2 new tween functions to start. These are tweenX function which contains the myTweenX tween and tweenY function which contains the myTweenY tween. these functions loop round to keep the movie clip floating along the bottom of the stage. The movie clip can be dragged by the user. The problem I have is that when the user drags the movie clip during the introTween the dragIt function is called (see below) and when called its looking to stop the myTweenX and myTweenY tweens. However, because the introTween function hasn't finished, and thus hasn't called the tweenX and tweenY functions...then the dragIt function can't find myTweenX and myTweenY to stop(). how I would go about solving this problem? Is there some sort of IF condition I can put in the dragIt function which looks at whether the tweenX and tweenY functions have started or even the myTweenX and myTweenY tweens have started?
I've a problem with calling the movieclip from the library with the if else case.If I take out the if else condition, the code runs normally but when I do I can't. I tried numerous attempts to fix the code but it still failed.What I wanted to do is, when I click one button out of 3 buttons at the 1st frame, it will pass the string (either red, blue or orange) to answer textbox. Then I store the string into a var called tarotno to go through a if else condition to call the MovieClip according to the string passed.[code]
package { import flash.display.Sprite; import flash.events.*; import flash.net.FileReference; import flash.net.FileReferenceList; public class FileReferenceListExample extends Sprite { [Code] .....
Code like the above will get executed as soon as loaded, how can I make it run under certain condition? Pretty much this in this answer: function keyEvent(code:String):void { // do something with the "code" parameter, that looks like "alt+ctrl+D", may use .split('+'), etc }
var a:Number = 1; var b:String = "hello"; if (a == 1 && b == "goodbye") { trace("options a and b"); }
The book I am reading says: "In this example, the test would evaluate to true, because one of the two conditions (the first) is true. As a result, "option a or b" would be traced."Isn't the above statement incorrect? this if statement to me reads as "if a is 1 and b is goodbye THEN output it"
Imagine a multiplayer whiteboard where several people can draw at the same time. To keep it simple, lets say there's a single object on the whiteboard which can be moved or deleted by any user. There is no notion of user-owned objects (i.e. it's important that any user be allowed to manipulate any object... it's a free-for-all whiteboard)My problem is this... if two users try to do a different action on the object at the same time, i.e. one deletes it the other moves it, what happens?
Right now- in just letting the messages go through, it gets all out of whack.One idea was to have a serverside control which resolves who has control of the object, and nothing is allowed to happen clientside until that conflict is resolved. Conflict resolution can be based on a first-come, first-serve basis.Even though this can happen very fast, the small delay (~50-300ms) is unacceptable since movement must be instantaneous on the client side. For example, instead of manipulating objects, think of a pen. For there to be a delay till they've already started drawing... not good!
Another idea was to have a "request control" button, which asks the serverside extension for control.... same idea as before, but now they aren't frustrated by the initial delay of pen drawing. This is also not so good though since they must hit that button till they can do anything, and this whiteboard is really meant for kids..
I want to start my for loop at a certain number, and make it loop. Like this: 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4
If the maximum number is 10 and it starts at 5. The reason is because I want to loop through every tile in my game in a certain order (top to down, then go right).
i have my hGroups as like [code]and i m trying to hide the hgroups on a condition when this bean tagInfoData have a value "notworking" otherwise it will shown..should i need to write code in the creation complete as all this is in a pop up window of the button click event.[code]
This segment creates the MCs for a preloaded slideshow. I want it to skip the creation of the MC and loader at the current index in the loop if a variable at that index is false, and then decrement the index and slideshow_length variable by one.Looking at the code now, I suspect I need to pass si to another variable at each trip through the loop, and decrement that instead. But that still doesn't seem to explain why the else condition isn't tripping. Does it?[code].....
I am developing a small game in flash and decided to use AS3 for it! Now the problem that has happened to me is that the condition within an if statement is executed!!!
Now instead of trying if the conditions (y > 850 && splodeCount == 0) are true it simply follows them as if they were orders. For example it places the object at y 850 and makes the splodeCount 0!
I want to make it so that every five seconds an enemy is in a hitTest with an object the object loses 5 points. I need to know if theres any condition so that I can do an.[code]
1. If I have a 'fish' drawing, and I want to produce bubbles at its mouth, how will I know where its mouth is through Actionscript?
In general, if I have a complex drawing and I want to identify a single part how do I do that using actionscript? This complex object could be an octopus. Then, how do I locate the arm number 3(an octopus has 8 arms?) of the octopus?
2.How do I exit from onClipEvent() when a condition is met? For eg, in VB I have the exit function but there is no EXIT function in flash 5 from which I can exit whenever a condition is met?
I have this function that has a loop in it.[code]How do i get it to hold until col_mc[name] has reached frame 80 in its timeline?So it loops then waits for the movie to get to frame 80 before carrying on.