ActionScript 3.0 :: Using One Series Of Conditional Statements For Several Different Objects?

Mar 13, 2012

-Let's say you have several doors on stage for a game.
 
-Each door has the ability to change color.
 
-When any two doors are the same color, a player can move between those two doors.
 
To do this, I use code similar to the following:
   
doorThree.addEventListener(MouseEvent.CLICK,dooraction);
function dooraction(event:MouseEvent){
if ("Blue") {

[Code]....
 
Is there a way to use this one series of If statements for all doors, or must I copy and paste the same instructions for each door instance? In the game I'm planning, each door actually has more than two dozen states, so if I can use just one series of if statements, I'd like to do that.

View 3 Replies


Similar Posts:


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

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

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

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 :: Conditional Statements For Arrays?

May 22, 2007

I'm trying to call movieclips depending on the data in the array, but I can't seem to get the conditional statements right, so that it works

var outfitArray:Array = new Array;
//Set function parameters
function createArray():Void {

[code]......

View 1 Replies

Professional :: If Else Conditional Statements For Dynamic TextFields

Nov 29, 2010

This is about a self assessment quiz.There will be four options and each one has a scale from1-5 i.e., "option a" has 1mark, "option b" has 2marks,"option c" has 3 marks, "option d" has 4marks and "option e" has 5 marks and we count the answered and we display the score for example if there are 20 question in it if they answered "option e" 5 times the score will be 25 and option d 5 times the score will be 20, and if "option c" for 5 times the score will be 15,and "option b" for 3 times the score will be 6 and "option a" two times the score will be 2, and we add up all the score and display in a dynamic text field called "score" and the total score is 68.

And I have another dynamic text field called "tsc" where I have to display the tags like excellent , good, better ......etc. Till now every thing is fine but I am unable to compare them it is displaying excellent even if i get 10 marks. If the score is greater than 55 "tsc" should display Excellent, if the score is greater than 41 or less than 55 "tsc" should display Best, if the score is greater than 26 or less than 40 "tsc" should display Better,if the score is none of the above "tsc" should display Poor.

This is my code on the submit button:
on (release) {
gotoAndStop("sQ");
if (scor>=55) {
tsc = "Excellent";
} else if (scor == 41 && scor<=55) {
[Code] .....
Where:"sQ" is the frame name where i am displaying the score details"scor" is the var name for the dynamic text field for displaying total score"tsc" is the var name for the dynamic text field for displaying the tags llike good, Excellent, better, poor.....etc.

View 4 Replies

ActionScript 3.0 :: Use Input Text With Conditional Statements?

Jul 9, 2009

I'm extremely new to AS3, and programming in general, and so hopefully this will be a simple problem someone can help me solve. I'm trying to have a user input a number in a text box, and then depending on what they input, take them to a different frame. (it's a math quiz, and the users are answering an addition problem). I think I need to define the variable type of the text box somehow before the code will work, but I'm not exactly sure what to do or how to do it.[code]...

View 3 Replies

ActionScript 2.0 :: Conditional Statements With Keyboard Events?

Jul 14, 2009

I'm trying to load and unload UI Component based on the using pressing UP. When they press the UP key i want the UI component to load a specific image. When they press it again I want the image to be unloaded. And if they press it again I want it to be loaded again, etc...Currently when I press the UP key it loads the image but it never unloads.Here's my current code:

Code:
var count:Number = 4;
var evenOrOdd:String;

[code]....

View 2 Replies

Flex :: Charts - Color Fill In Column Series In Conditional

Jul 8, 2011

I want to create a daily build chart with 1 column as 1 build, 1 build will have 3 series for eg feature 1, feature 2, feature 3. Now i need to fill the color of the series dynamically based on the feature is pass or fail. for eg if in a particular build feature 1: Pass, feature 2: Fail, feature 3:Fail then the color sequence of the column will be green, red, red. how to implement this logic and where? (if in fillfunction)

View 1 Replies

ActionScript 3.0 :: Conditional Statements For Click Referring To Loaded Swf

Jun 10, 2009

The last big hurdle I have, is the following, and I hope someone can just throw me a bit of guidance on this.I am looking for a way to write a function, that on click of my "next" button in the main timeline, will refer to my loaded swf MovieClip(imageLoader.content) telling it to go to the next frame label, so really a compound if/then situation - just referring to the loaded file throws me.So, my next button is "pNext," and what I am looking for is something along the lines of:[code]

-if (loaded movie) is on frames 12-144, then go here (on click),

-if (loaded movie) is on frames 144-155, then go here (on click)

View 8 Replies

ActionScript 3.0 :: Forcing Code Execution Order In Conditional Statements?

Feb 17, 2010

I have created an image gallery where each "slide" is an image loaded by one UILoader component. Everything works, except I noticed that as a user it is annoying to wait for each new slide to load.So, even with my limited knowledge of AS3, I decided to figure out a way to load the next upcoming image before the user requests itone for odd numbered slides, one for even numbered slides. That way, when the user is viewing a slide with an odd number in the first loader, the next image can be loaded into the second (currently invisible) loader and ready to go when requested button would simply toggle the visibility of these two loaders.

function nextButton(event:MouseEvent):void
{
imageNumber++;

[code].....

View 11 Replies

ActionScript 3.0 :: Using Mouse Events (mouse Leave) For Conditional Statements?

Dec 14, 2010

I have a menu drawer at the edge of the screen that shows when the user rolls the mouse over it, but if the user overshoots it an moves the cursor slightly outside the browser window this is unfortunenatly registered as a mouse out.

I want to stop this by using event.MOUSE_LEAVE, but i need to use it as a condition not to triger a "leaveHandler".

View 3 Replies

ActionScript 3.0 :: Color Manipulation Class Of A Series Of Objects

May 1, 2009

I am trying to make a class that will allow me to manipulate the color of a series of objects and I�ve gotten this far with ColorMod.as which does this manually. I would like to be able to somehow generate a series of ColorTransform objects such that I can manipulate their parameters (particularly redOffset, greenOffset and blueOffset) while I am generating them, and then push them into an array that can be accessed by another class. I can do this manually as per the code below, but I would like to be able to do it using a for loop as per the pseudocode I put in the constructor below.

[Code]...

View 2 Replies

ActionScript 2.0 :: If Statements Within If Statements?

Oct 7, 2004

If they get a question wrong in my quiz ( weakest link) the money clip goes to zero and it goes onto the next question. If they get it right the money clip advances and they go onto the next question. I want to include each time that it should only go onto the next question if all questions have been asked. SO i want an extra if clause in both sections, saying if current question is more than 11 go to '#game over"The questions are saved in the frame of the quiz

_root.qArray = new Array("question: A;B;C;D")
_root.qArray.push("Question?:A;B; C; D")

There are 11 questions.At the moment at the section with choosing answers I have

function selectAnswer(n) {
// correct
if (answers[n] == correctAnswer) {
_root.money.nextFrame();

[code].....

View 1 Replies

ActionScript 3.0 :: Run On A Series Of Frames?

Apr 23, 2010

I have a series of a few frames, but the AS only runs on the first of the series for some reason. How do I get it to run on every single one of them? Image: [URL]

View 1 Replies

Uses Buttons To Play A Series Of Videos

Nov 24, 2009

I have a file that uses buttons to play a series of videos. I want to have the button for the currently playing video to stay in the 'down' state while it plays but I don't know how to do it.

View 4 Replies

ActionScript 3.0 :: How To Load Series Of Images

Feb 15, 2010

I am trying to load a sereies of pictures moving accross the top from right to left.How do I load all of these photos in such a way that they seem to be stitched together like a piece of film strip at certain rate going accross?

View 5 Replies

ActionScript 1/2 :: Fill Series In Flash?

Feb 21, 2011

I need to know how to have fill series in flash.Ex:

If User gives 1 then it has to fill like 1,2,3,4,....

if User gives i then it has to fill like i,ii,iii,iv,v,.....

if user gives a then it has to fill like a,b,c,d,e,....

like this i want. Please tell me how to perform this.

View 3 Replies

Flex :: How To Exclude Series In Legend

Mar 22, 2010

In flex charting, I want to draw something like "reference lines" which are related to specific series, therefore these lines are not independent series and should not be shown in legend. Is it possible to exclude some series from chart legend?

View 3 Replies

Flash - Finding All Series Within An Array?

Jan 2, 2011

How do I find number of all the series (combinations of an array that have at least 3 consecutive values, like [7,8,9]) and have the longest number of values?

from [3,4,1,2,2] it would be 2 - ([1,2,3,4] twice, but ignore [1,2,3]*2 and [2,3,4]*2)
from [9,6,7,5,8] it would be 1 - ([5,6,7,8,9])

[Code]....

this will create an array ($ranks) that will have these values [2:2, 3:1, 4:1, 9:1]

from this I will be able to multiply the values under 2,3 ad4 4 and multiply them by 3, so I would get 2*1*1 * 3

how to find the consecutive values, and ignore ones that aren't (like the 9)

View 2 Replies

ActionScript 2.0 :: Any Way To Navigate Through Series Of Slides?

Jan 12, 2011

I have a flash player I've created as a way to navigate through a series of powerpoint slides. I've created a slide count at the top to show the "current slide number / Total Slides" the trouble i've got is that the total slide number is dictated by actionscript (nSlid) I want to retrieve the total slide count by loading the data from an xml file?

var i:Number = 0;
var nSlid:Number = 30;
cur_slide.text = i+"/"+nSlid;
btn_next.onRelease = function() {
if (i<nSlid) {
[Code] .....

View 5 Replies

ActionScript 2.0 :: Fade A Series Of Pictures One After The Other?

Oct 27, 2007

I want to fade a series of pictures one after the other, such that they'll loop around. I'm calling this a cascade. So to do this, i've placed all of the image names into an array and I set all of their alpha properties to 100 to begin with. I think I then need a for loop that will iterate through the images, fading the image down to 0, waiting for a set period of time and then moving on.

Unfortunately, mcTween will fade all of the images at once in the for loop, so I need to prevent a tween from starting until the one before it has finished. I thought I could achieve this using a while loop and the isTweening property, but when I try and preview the flash movie it just gets into a recurring loop and the program hangs, and has to be exited.

[Code]...

View 4 Replies

ActionScript 2.0 :: Load A Series Of JPEG's?

Apr 17, 2008

I have a series of JPEG's labeled frame1.jpeg, frame2.jpeg, and so on... I want to play them sequentially as a movie. Earlier, I had success loading a single frame, but now I have trouble loading all the frames one by one.[code]...

View 5 Replies

ActionScript 2.0 :: Fading In A Series Of Jpegs?

Mar 25, 2009

I have a series of jpegs that I would like to download dynamically and have them fade in like a slide show. I'm using loadClip so I can use forceSmoothing so they look nice.

But I'm unsure how to have them fade in one after the other. Trying an array and for loop but I don't know quite how to structure it.

View 2 Replies

ActionScript 3.0 :: Accessing Mc On Stage In Series

Oct 4, 2009

im trying to do a small card trick on flash cs4 using as3.i have 56 diff mcs on stage with instance names like c1,c2,c3,c4....c56.. and i need to acces nly 10 of at a time in a random order..i ran the random no. generating codes and got 10 diff random numbers (from 1 to 56) and stored it in an array as array[0],array[1] all this works fine.now how do i access the individual movie clips???[code]

View 1 Replies

ActionScript 3.0 :: Loading Series Of Images Using XML?

Mar 11, 2010

I am trying to load a series of images into a MC using XML to provide URLs and other image data. The ultimate goal is to place each image (as a sprite?) in it's correct position in a MC, assign it an instance name and make it into a simple button. This button would then be used to load a large version of the image.I can make the images appear on the stage I expect they are only being put into the Display List, but cannot seem to be able to position them at a specific point taken from the 'xpos' and 'ypos' XML data, assign an instance name or make them a button.The code I have so far is:

Code:
//Variables Set
var sect1loaded:Number = 0;
var sectionNum:Number = 1;
var imageNum:String = sectionNum + "_";

[code]....

what I believe I need to do is create a separate class for the image load which can then be used over and over again when needed... I will crack this when I have the core principles hacked.

View 2 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

IDE :: Use If And Else Statements And Failing?

Apr 15, 2009

I am trying to use if and else statements and failing. I am either completely missing their purpose, or just not writing the correct code. Scenario: I have designed a gallery that consists of animation in movie clips that are placed on the time line. With the if/else statements I need Flash to know what movie clip the user is on, so that the users next action loads the correct movie clip.

[Code]...

View 4 Replies

Double Up If Else Statements?

Apr 18, 2009

Is it possible to double up If Else statements? [code]...

View 2 Replies







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