ActionScript 3.0 :: Using Variable In More Than One Conditional

Apr 14, 2012

It's a little more complex than that, actually. Inside a function, which is called by a Timer Event, I have many conditional statements based on CurrentCount of my Timer. Nested within these conditionals are more conditionals.
<<<I know it's amateur programming, and I'm sure there are much more elegant ways, but I'm just learning (via attempting a difficult challenge).>>>
One way I'm trying to control all these conditionals is via a random number, from 1 to 3. My problem is that after generating the number within one "if (currentCount == )" statement, the variable is no longer available to be used by the next "if (currentCount ==)" statement. Is this some terrible side effect of using the Timer class??

Code:
var timerMain:Timer = new Timer(900, 25)
timerMain.addEventListener(TimerEvent.TIMER, takeTurn);
timerMain.start();
function takeTurn(e:TimerEvent):int {
if (timerMain.currentCount == 4) {
[Code] .....

View 6 Replies


Similar Posts:


ActionScript 2.0 :: Conditional Is Not Recognizing The NextClicked Variable

Dec 22, 2009

Why is this not working? Seems like my conditional is not recognizing the NextClicked variable. Why? What am I doing wrong here?

[Code]....

View 1 Replies

IDE :: How To Conditional Statment

Oct 26, 2009

So I'm not that familiar with using conditional statements yet, and I'm trying to get my head around it. I know what I need it to do, I'm just not sure of the correct syntax.I basically want a statement that says:

if( movieClip1 == frame 10)
{
then play movieClip2

[code].....

View 8 Replies

Stopping A Flv Using A Conditional Statement?

May 26, 2009

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...

View 1 Replies

ActionScript 3.0 :: Conditional In A Function?

Oct 18, 2009

I'm trying to make a gallery loaded from external files, and I try to not use ready packages or swfs, so I wrote a code. I have many images in a folder and a xmlListfile of this images, and I accomplished to load them one by one, but when the list reach to end in both ways (start or end), Button function for the next images continue to work, I treid to solve to problem with a conditional in function but it didn't help.

The code is:

ActionScript Code:
var i:uint = 0
var imageLoader:Loader;
var xml:XML;

[code]....

View 4 Replies

ActionScript 3.0 :: Create A Conditional Button?

Feb 15, 2009

I want one button to do two things.

1) play a movie clip from frame 1-40

2) and then... play it from frame 40 until the end [code]...

View 1 Replies

ActionScript 3.0 :: Movieclip In Conditional Statement Of If?

Nov 28, 2009

In the code below how can I use the movieclip in the conditional statement? This is simplified, there is lots more going on but the basic issue is shown. I want to say if currently dragged mc is dot1_mc do the copyDragTo35 function

PHP Code: var item:MovieClip;
//add event listeners to all dots
kite_mc.dot1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
kite_mc.dot2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
function onItemDragStart( e:MouseEvent ):void {

[Code]...

View 2 Replies

ActionScript 2.0 :: Flash 8 - Using This With Conditional Statements

Sep 28, 2010

When use the full path name and the identifier of a movie clip, my conditional statement works fine. However, when I swap the identifier out with "this", it no longer works. This script is contained within the movie clip I am trying to reference. I have found that, "this" works fine by itself on the timeline. It just stops working when I place it within a conditional statement.

Here is my script:
function functionOne() {
randomX = 550*Math.random();
randomY = 400*Math.random();
} functionOneInterval = setInterval(functionOne, 1000);
function functionTwo() {
[Code] .....

The reason I am trying to use "this" instead of the identifier name is because the movie clip it is referencing will be duplicated. This script here generates a random destination point for an enemy spaceship and tells it to constantly move to the changing points. This script is contained within the enemy spaceship movieclip, and I am planning on duplicating several of them at once.

View 1 Replies

Stopping A Flv Using A Conditional Statement If The FLV Is Playing?

May 25, 2009

How would you stop an FLV using a conditional statement where the condition is if the FLV is playing?

I'm using AS 3.0. My best shot was this:
 
if (demo.flv == play){ demo.flv.stop();  }
 
I'm sure the "== play" part is wrong, but I cannot find the correct code that checks to see if the video is currently playing.
 
My flv component does have an instance name of "demo". The command "demo.flv.stop(); works fine as a non-conditional, but the flv is not always playing with my navigation set-up when you land on the frame with the code, so I need a conditional.

View 3 Replies

ActionScript 3.0 :: Conditional Statement And A Counter?

Sep 1, 2009

I'm trying to make a button that if you hit it 4 times it plays a movie clip. On the 5th hit- I want it to play a different movie clip. After the 5th hit- it resets itself and the process would start all over again. The script is all in one keyframe and the movie clips are being played with functions.

playButton_btn.addEventListener(MouseEvent.CLICK, goButton1);
function goButton1(evt:MouseEvent):void{  runningMan_mc.gotoAndPlay(2);}

View 6 Replies

ActionScript 3.0 :: Conditional Statements With Numbers?

Jan 25, 2010

I want to write AS3 code that has 2 variables;  one that acts on odd numbers and the other that acts on even numbers entered into a text field ?(sorry I'm not making much sense here! Will explain the context further)I'd like to use an XML calendar in my Flash project that shows the odd or even dates in the calendar depending on what number you enter in a field being either an odd or even number. (This is based on ACT Water Restrictions odd and even watering restrictions)It means that if your street number is an odd number you can use water as per restrictions when the date also is an odd number. Similarly, if your street number is an even number you can water as per restrictions when the date also is an even number. You're probably familiar with this system.
  
The context is for my Adult Migrant students to understand the concept of our water restrictions here which is governed by this odd and even system.So what I'm doing to do next is buy a cheap XML calendar online which I can adapt for my project but I'm not sure whether I should be approching this code problem with an  if/else statement to get the results or something else?how to write the code!!
 
if my number I enter is an even number then display (in an XML calendar) even days
else
if my number I enter is odd then display (tin an XML calendar) odd days

View 5 Replies

ActionScript 3.0 :: Conditional Statement For Loaded Swf?

May 14, 2010

I am initiating loading a swf file, "bg1.swf". I have a button that, when clicked, is suppose to check to see if "bg1.swf" is loaded.I cant figure out how to write the conditional "if" part.  Currently, instead of checking to see if my statement is actually true, it executes loading bg1Req?  Here is the code .

var bgLoader:Loader = new Loader();
var bg1Req = new URLRequest("bg1.swf");
var bg2Req = new URLRequest("bg2.swf");

[code].....

View 7 Replies

ActionScript 1/2 :: Syntax For A Conditional Statement?

Dec 1, 2010

My son is doing a self-study course and is currently haviong a problem with the syntax of a condtional statement in Actionscript 2The folllowing code,

if (colour="red") {gotoAndPlay("BadEnd_red")}
else if (colour="blue")  { gotoAndPlay("BadEnd_blue")}
else  //colour ="green"  { gotoAndPlay("BadEnd_green")}

[code]....

View 3 Replies

ActionScript 3.0 :: Conditional Statement From XML To File?

Dec 16, 2011

I'm trying to pull in a conditional statement from an XML file to an actionscript file. Basically, the idea is that I have an activity called "keyPress.as" that is included on a Flash page. Directions, success and failure text are pulled in dynamically from XML as well as the resulting screen shot on success. Success is defined as the correct key stroke from a user when the corresponding page's .swf file is run. Could be a single key or key combination.
 
Here's the basic AS code that I'm using (please assume that 'pageData' is the loaded XML - that is done in another file - and it works for pageData.directions, which pulls in the directions text from the XML <directions>text</directions>):

[Code]...

View 3 Replies

Flex :: Conditional Data Binding?

Oct 8, 2009

first one shows playheadtime of videodisplay and another is also used for same purpose. the difference is that when we are in add mode(decided from a flag variable) both should show current playheadtime using binding. but when we are in edit mode(again decided from flag) the latter label should remain static, to be more specific, the value retrived from database.how can I do that using actionscript. I tried ChangeWathcer but I found it a bit tricky. Is there any other simpler way or am I missing something. following is my code.

private function init():void
{
if (queFlag == 'a')

[code].....

View 2 Replies

Flex :: Use Conditional Operator In Checkbox Using It?

Oct 21, 2009

I want to fill color based on condition so I used conditional operator for the checkbox. But it's shows the error Implicit coercion of a value of type String to an unrelated type Array. What did I do wrong ? How can I dynamically change the color of a checkbox ?[code]...

View 2 Replies

Actionscript 3 :: Conditional Statement Not Working?

Jan 23, 2010

In my code here:

var manTimer:Timer = new Timer(1700,5);
manTimer.addEventListener(TimerEvent.TIMER, moveMan);
function moveMan(e:TimerEvent):void {[code].....

I am trying to get it so that when btnElScorcho or btnTheGoodLife is clicked it'll move my "man" mc out onto the stage. It starts at 590px and ends at -10px. That part is working.What is not working is my conditional statement that tells it to only move the "man" if he is at the x position of 590 or greater, because, when one of the 2 buttons is clicked again, I don't want to move him out if he is already there or if he is already moving out.So for some reason, "man" will still move when the buttons are clicked a second time and oddly enough, "man" will only move twice as opposed to the normal 5 times set in the function.Maybe I can change the if statement to check if the button has already been clicked as opposed to where "man" is?

View 1 Replies

Flex :: Can Do Conditional GET Requests From Flash / AS?

Feb 19, 2010

I have a Flex client that loads data from a server to display a chart. This data may change, so the client regularly repeats the request. Since the result may require some work to retrieve, I'm going to have the server detect if the result has changed, and issue a 304 status if it hasn't.I haven't seen any headers in the Flash Player's requests which would indicate that it's already handling conditional GETs. Also, the HTTPService API doesn't seem to provide anything, either. Does that mean, Flash can't do this, or how can I implement this myself?

With regards to cookies, which aren't supported in Flash, I have heard the suggestion to build my own HTTP client on top of the Socket class. This might solve this issue, too, but frankly, I'm really not keen on doing that.As an alternative, I could just cache the result page and send it again, but so far, the API tries to utilize semantics that are already built into HTTP, and I'd like to keep it that way.

View 2 Replies

Actionscript 3 :: Keep Element Grayed Out Unless A Conditional Is Met?

Apr 3, 2011

I'm in the process of designing a Flash application, and it requires either two or three pieces of data from the user.The third data element is only relevant if one of the other elements has changed from the default value.In order to prevent the user from inputting information that would skew the calculations based on the input, how can I gray out the text input box if the default conditional is unchanged? I could embed a conditional to ignore the input from that particular box, but I know that some users will fill in all data fields regardless of on-screen instructions.

View 1 Replies

Flex :: Conditional Embedding Of Images?

Apr 26, 2011

We are working on a flex project where we want to balance two challengesa) want to ensure that there is minimal need to be connected to internet- so it can be used offline. This will be used in rural locations with flaky connectionsb) Reduce file size by only embedding those assets in compile mode as is requiredBroadly, the project will go down one of three flows in the module called, based on user choice- Path A, Path B and Path C, which will require image set-A, set-B & set-C respectively (based on settings in the module)We want to send over all images in Set-A or set-B or set-C right upfront in the module called, based on choice made in primary project, to minimize need for connectivity once accessed. At the same time I want to avoid sending all three sets and bloating up download size three times.

View 2 Replies

AS2 :: Terminate A Conditional Test Only One Level?

Jun 19, 2011

The break statement terminates the whole loop or test, but I want to terminate it only one level. How would you do that?

View 1 Replies

Flex 3 - Conditional Statements For A Repeater

Jul 12, 2011

I have an xml file that has a start date and length of a project... I use a repeater to load each project. The users' screen only shows 2 weeks at a time. I would like to make it so that if a project doesn't fall within the two weeks on screen, that the project isn't loaded. I could do this by sorting through the XML and finding the correct projects to load, and putting them into an array collection, but there's a "move date" button which allows the user to change the two weeks that are showed. Once the two weeks are changed, I would need the projects that fit into that new 2 week window to show.

[Code]...

View 1 Replies

Flex :: Set Conditional Locale Strings

Oct 21, 2011

I'm trying to localize my Flex app, I have been able to setup the locale specifics and all the stuff inside MXML tags, that works pretty well, my question is, what about if I have for example:

[Code]....

How can I change with ActionScript those two strings to an other locale?

View 1 Replies

ActionScript 3.0 :: Conditional Within Loading Progress?

May 31, 2006

I'm trying to make it so that the first 99 frames of a 198 frame preloader run even when the swf is loaded into the cache. I have the script looping the second 99 frames of the preloader while the movie is loading, but when it's already loaded, I only want the first 99. Right now, when the movie is already loaded, I'm only able to skip over the preloader altogether and go right to the movie OR I can see a loop that starts at the beginning of the preloader and then cycles through the second 99 frames indefinitely and never goes on to the movie that's loaded. At first I was using two separate movie clips, one for the first 99 frames and another for the second 99, but since that didn't work, I combined the files to see if that would work, but it didn't. I've tried so many adjustments, I've run out of ideas. Is it even possible to use a conditional with the onComplete function that's supposed to run when the loading is done, so that onComplete only happens if the current frame of the preloader is greater than 99?
 
Here's my script for frame 1 of my movie. The movie proper starts on frame 2, and preloader is the 198 frame movie clip in the library. The result of this script is an endless cycling of the preloader even when the movie's loaded.
 
stop();
preloader.play();
function everyFrame(event:Event):void
{

[code]....

View 9 Replies

ActionScript 2.0 :: Conditional With HitTest Not Working?

Feb 10, 2010

I am calling this function via onEnterFrame from another function.

ActionScript Code:
function hitCheck():Void{
or(i= 0; i < numTools; i++){

[code]....

View 4 Replies

ActionScript 3.0 :: Adding A Child Using Conditional?

Sep 10, 2010

I am trying to add a Child to the stage depending on what xml string is loaded based on a button click. I created a function for buttonFeedback but it breaks my code

ActionScript Code:
/*import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;

[Code].....

View 7 Replies

ActionScript 3.0 :: Play/stop In A Conditional?

Sep 29, 2010

how can I use the play/stop-state of an audio-track as a boolean in a conditional? Something like ,if (trk1.play = 1) must be wrong, because "play" is a function and not a property, or not?

View 2 Replies

ActionScript 3.0 :: How To Create Conditional Statement

Dec 12, 2011

create conditional statement that will tell, that if time is 0 and enterframe event didn't played, we will trace in output window ("event didnt started")

View 1 Replies

Actionscript 3.0 :: Color Conditional Statements?

Aug 8, 2010

I'm having difficulty getting a conditional statements to recognize a statements equality even if the condition exists

Even if movieClip_mc is 0xA6A6A6 then the function will not execute:
Code: Select allvar myColorTransform = new ColorTransform();
myColorTransform.color = 0xFF0000;

[code].....

View 2 Replies

ActionScript 2.0 :: Some Conditional Code Not Firing

Dec 20, 2005

I have some code that is supposed to detect if a movie subsection is currently "active" or "destroyed", and respond to these conditions. When a subsection first loads it sets _root variable "state" to "active". When a new menu item is rolled over, it triggers several events. It tells current movie to destroy itself. On the final frame of the movie subsections they change the _root variable "state" to "destroyed". After the button tells the current movie to play destroy, it begins an on enter frame function that looks for state to be != to "active" (I've tried == "destroyed" here as well). [code]...

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved