ActionScript 3.0 :: Create An If Statement That Executes Two Different Loops?

Oct 5, 2011

Is there a way to create an if statement that executes two different loops?

For example, If I was trying to make game with a button that when clicked creates random objects falling down and when the objects are destroyed, creates random objects floating up. I haven't seen anything online, but I'm wondering if anyone know. Is it possible or should I just create two different listeners?

View 3 Replies


Similar Posts:


IDE :: Create A Timer That Executes The Following Piece Of Code After 10 Seconds?

May 3, 2010

How to i create a timer that executes the following peice of code after 10 seconds:

Code:
_visible = false;

View 3 Replies

ActionScript 3.0 :: Use A For Statement To Create An If Statement

Jul 12, 2010

what I'm trying to do is create an else if argument for each object in an array based on a user set number

Code:
for(var i:int=0; i < numberOfElseIfs; i++){
GENERATE AS3 CODE
}

to which I want it to GENERATE THE FOLLOWING CODE:

Code:
}else if(baskets[i].used == false){
baskets[i].used = true;
drawButton(i);
}

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?

View 4 Replies

AS2 :: Create Unique Variables In For Loops?

Nov 12, 2010

I'm wondering if it's possible to create variables in a for loop that uses an incrementing number in the variable name.
 
This is the code I've tried (as a long shot) but isn't working:
 
var i:Number;for(i = 1; i < 10; i++){  var ["number" + String(i)]:Number = i;}
trace(number5);

What I'm trying to create here is a series of variables called "number1", "number2", "number3", etc. Is there another way of doing it? I'd need them to be public (I think that's the term?), so they can be used elsewhere in the script.

View 3 Replies

Professional :: Create Unique Variables In For In Loops?

Sep 3, 2010

I have an onEnterFrame function controlling all the movie clips in an array. The motion of each of these movie clips is controlled by a few variables speed, acceleration, etc that are modified on each enterFrame. I can't figure out how to create unique variables for each element in the array. At the moment my variables are the same for all the elements, and so the motions for each movie clip are the same.

I have used this code to add my movie clips into the array:
 
for(i = 0; i < starNumber; i++){ duplicateMovieClip(star, "star" + i, i);  starArray.push(this["star" + String(i)]);  }

Do I need to do a similar thing to create unique variables for each? Or is there something I need to do in my for(myClip in myArray) loop that is contained in my onEnterFrame function?

View 4 Replies

ActionScript 2.0 :: Create A Grid Of Hexes Using For Loops?

Jul 11, 2004

I'm trying to create a grid of hexagons by using nested for loops. I picked up this code trawling the forums but this creates a diamond shaped pattern of hexes rather than neat rows that interlock together. I want to create one row in the first place, increment the x and y placing coords so as the next row is offset as appropriate to lock it into place under row above. Can't get my head round it. It's been a long day-too much wine-Flash newbie.[code]...

View 1 Replies

Flash :: Create Multiple Tab Loops In AS3 By Using Fl.managers.FocusManager?

Sep 7, 2010

I want to create a tab-enabled popup window in an AS3 Air project. Currently, when I press tab several times, the focus goes through all the components in my popup window and then starts focusing the buttons and TextFields from the components that are behind the popup. I have tried to solve this problem in two ways, but none of them worked. I will explain both of the methods here

[Code]....

View 2 Replies

ActionScript 2.0 ::create A Flash Movie That Loops Through 11 Dynamic Images?

Nov 19, 2003

I would like to create a flash movie that loops through 11 dynamic images continually with a fade-in, fade-out each image.

View 2 Replies

Create A Flash Application Where Users Will Have Access To 10, 5 Seconds Audio Loops

Oct 8, 2010

I want to create a flash application where users will have access to 10, 5 seconds audio loops. They can choose any 4 tracks to make a 20 second track. I then want that mp3 to be stored somewhere or flash to create to a file which can be sent to friends in facebook where they can listen to that beat. There will be a little button at the bottom saying 'click here' to make your own beat.

View 1 Replies

ActionScript 2.0 :: Create A Movie Clip That Loops And On Each Loop It Loads A Random Little .jpg Banner From A Directory?

Aug 9, 2004

I am trying to create a movie clip that loops and on each loop it loads a random little .jpg banner from a directory. The banners are named 0.jpg, 1.jpg and so on, a script on the first frame of the loop saying

Code:
_root.randomnumber = random(_root.bannernumber);
_root.bannerloop.bannerholder.loadMovie("http://www.url.com/directory/"+_root.randomnumber+".jpg");

"bannernumber" is a variable from an external text file specifying how many random numbers to cycle through (how many banners), This works just fine and loads up a new banner after each loop cycle. The problem lies in trying to make each banner go to its own url, I have another external text document with variables "click0=url, click1=url etc" where I want the number in each variable to equal the randomnumber variable in flash, then use an on(release){getURL(urlvariable)} function to have it retrieve the url that is somehow in the url variable. Basically, how would I make the urlvariable be equal to the "click0" variable to get the url of the click0 variable into the getURL function? while having the number in the "click0" variable be equal to the randomnum variable?

View 2 Replies

ActionScript 2.0 :: Create A Loop Which Generates A Single Series Of Sine Results Ranging From 0 To 1 Based On 100 Loops?

Jan 20, 2006

I'm trying to create a loop which generates a single series of sine results ranging from 0 to 1 based on 100 loops ( ie 0 ,0.011 ,0.1111........up to 1 in a single run)The results I want start at 0 and increment in a series up to 1 and then stop. I suppose this would be one half of a sine wave I have tried the following but it goes from 0 to 1 ,1 to 0 , 0 to 1 etc whereas I want a single straight run of 100 values from 0 to 1

I tried :

for(var i:Number=0;i<=100;i++){
trace((0.5*Math.sin(i)) + 0.5);
}

This does not work.

View 1 Replies

Frame One Of Linked SWF Executes Sometimes

Jun 10, 2009

I am using the loader class to load an external swf and attach it to an empty movieclip, the final step follows:
// function loadComplete(e:Event):void {
mc_launch.addChild(gLoader);
MovieClip(gLoader.content).gotoAndPlay("start");}

When navigating away from the movie clip, it's dumped as follows:
MovieClip(gLoader.content).closeAllStreams();gLoader.unload();

The linked swf has two important frames in the beginning. The first frame is labeled "hold" and has the following:
var gSC:SoundChannel = new SoundChannel();
var gSCBusy:Boolean = false;var gSlideIndex:Number = 0;
var gAudioPosition:Number = 0;
var gPlayList:Array = ["start","slide01","slide02"]
var gAudioList:Array = ["intro.mp3","",""]
var gRunMode:String = Capabilities.playerType;stop();

The fifth frame is labled "start" and the singing and dancing begins from there. The stop(); function in the first frame is used to prevent the loading swf from executing before its 100% downloaded (I had some early trouble where the music would start before the screen assets were in place). My problem: This works perfectly the first time the linked swf is downloaded and attached, however, if you navigate away and then back I get the error "gSlideIndex NAN" which indicates to me that the first frame in the linked swf is not executed on subsequent attachments, the playhead jumps straight to "start" and my globals are never declared. Why would a linked swf execute frame 1 the first time it's attached to mc_launch but not the second?

View 9 Replies

ActionScript 3.0 :: Create An If Statement For Even.label?

Dec 10, 2011

I can create an if statement for # of selected items. However, how can I create an if statement for even.label? I have various labels and would like to create if statements based on if the text in my "labels" match up.

ActionScript Code:
function handle_checkbox_change(event:KcheckboxEvent):void {
trace("value before change : " + event.from);
trace("new value : " + event.to);

[Code].....

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 2.0 :: Script Executes In Flash But Not As Projector?

Feb 28, 2010

I'm using the script below for a Flash (CS3 and AS2) presentation so the client can play/stop and rewind/forward the movie with the keyboard.

It works perfectly when I go "Control >>> Test Movie" but when I publish the movie as a Projector file nothing happens when I hit the relevant keys.

Also, the same thing happens if I open the SWF outside of Flash from it's local folder.

Code:

import mx.utils.Delegate;
var nCheckPoint:Number = 0;
var aCheckPoints:Array = new Array();
aCheckPoints.push( { sScene:"Scene 1", nFrame:10 } );

[Code]....

View 10 Replies

Professional :: Script Executes In Flash But Not As Projector?

Feb 28, 2010

I'm using the syntax below for a Flash (CS3 and AS2) presentation so the client can play/stop and rewind/forward the movie with the keyboard.It works perfectly when I go "Control >>> Test Movie" but when I publish the movie as a Projector file nothing happens when I hit the relevant keys.Also, the same thing happens if I open the SWF outside of Flash from it's local folder.

import mx.utils.Delegate;
var nCheckPoint:Number = 0;
var aCheckPoints:Array = new Array();[code]..........

View 1 Replies

ActionScript 2.0 :: Event Handler That Executes On Load?

Feb 16, 2006

I need an event handler that executes only once when the root movie has loaded. If I later on return to the first frame that holds the script it should not execute again.

something like "when_root_has_loaded = function(){ some code};

View 1 Replies

ActionScript 2.0 :: Function Executes Premature With EaseX?

Jul 26, 2007

Code:
////////////
//proto.as//
////////////
MovieClip.prototype.easeX = function( to:Number , speed:Number , endF:Function ,

[Code]....

otherFunction() runs as soon as the mouse over happens and not after the ease finishes as I would like it to.

View 4 Replies

ActionScript 3.0 :: Create IF Statement That When The LoadSWF Reach To Last SWF File?

Feb 23, 2011

I have an arrays of swf files that are going to be loaded.I want to create IF statement that when the loadSWF reach to last SWF file (question7.swf) it tweens the alpha of hidden btn.

something like this.

ActionScript Code:
if (e.target.content == qArray[6]+".swf" )
{
TweenLite.to(end_btn,0.5, {alpha:1});
}

This is to give a general idea of the full code

ActionScript Code:
var questionbox:MovieClip = new MovieClip();
questionbox.x=0;
questionbox.y=10;

[code]....

View 0 Replies

ActionScript 2.0 :: Create An If Statement That Would Load A Movie Clip?

Apr 19, 2004

is there a way to create an if statement that would load a movie clip after a different movieclip is loaded.

i have text_mc and scroll_mc. I dont want scroll_mc to load unless the content is loaded into the text_mc.

I tryed to make an if statement sort of like a something used for a preloader but I must have been off just a bit because it was not working. I dont even know if it possible.

View 7 Replies

ActionScript 3.0 :: Delay Play Only Once - Code Executes Each Loop

May 5, 2010

I am new to flash. I can't seem to decifer the script examples in the help files. After a lot of trial and error the following codes works great. It delays playback on the video for the proper amount of time. The only problem is when the playback loops (like it should) the codes executes again. I only want to execute the code the first time thru.

[Code]...

View 6 Replies

ActionScript 3.0 :: Function Executes When An Instance In The Movieclip Is Clicked?

Aug 16, 2010

I'm so getting confused with this,So i'm making a card game, and i'm just on the beginning of it. I've already added the objects on the stage and stored them on an array.now i made a function that when it executes the .x and .y properties of these cards would change. this is what i did, but nothing seems to happen.the array MyCards contain movieclip objects not strings and also, the function executes when an instance in the movieclip is clicked

ActionScript Code:
distCards(MyCards);
function distCards(cards:Array):void {
for (var i:int=0;i<cards.length ;i++) {

[Code]...

View 1 Replies

ActionScript 2.0 :: Changing An On(press) Command - Automatically Executes Every 10 Seconds

Mar 20, 2008

I have an on(press) command that refreshes advertisements on an HTML page that my .swf is embedded in. When a user clicks on buttons that have the script, the advertisements refresh. I have a page that features a Slideshow Pro slideshow. Because this is a component, I am unable to put this script on the buttons in the slideshow. I am hoping instead, to have the script automatically run every 10-20 seconds. I am using actionscript 2.0 in a Flash CS3 file. Here is the code on the button:

[Code]....

View 1 Replies

ActionScript 3.0 :: Executes In Another Class That's Called From A Dispatched Event Elsewhere Still Run Procedurally?

May 29, 2009

If I change the value of a variable that two different classes can see (in a custom global class, for instance), and then immediately dispatch an event that the other class is listening for, will tracing that variable in the listening class reflect the variable's new value? In other words, does code that executes in another class that's called from a dispatched event elsewhere still run procedurally, or is there some sort of asynchronous thing going on, where the class that dispatched continues on to the next line of code in its own class without regard for what may or may not happen in the other class?

View 2 Replies

ActionScript 2.0 :: Create If Statement That Would Load Movie Clip After Different Movieclip Is Loaded

Apr 19, 2004

is there a way to create an if statement that would load a movie clip after a different movieclip is loaded.i have text_mc and scroll_mc. I dont want scroll_mc to load unless the content is loaded into the text_mc.I tryed to make an if statement sort of like a something used for a preloader but I must have been off just a bit because it was not working. I dont even know if it possible.

View 7 Replies

ActionScript 2.0 :: Create A Flash Movie That Loops Through 11 Dynamic Images Continually With A Fade-in, Fade-out Each Image?

Nov 19, 2003

I would like to create a flash movie that loops through 11 dynamic images continually with a fade-in, fade-out each image.

View 2 Replies

ActionScript 2.0 :: First Requirement Of The If Statement When Type In The Proper Input And Go Straight To The Else Statement

May 14, 2009

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.

View 7 Replies

ActionScript 1/2 :: Execute Code In Previous If Statement If Second If Statement Is Executed?

Aug 31, 2011

if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code

[Code]...
 
I dont want to copy the code from the first into the second and the first and second into the third.
 
My mind isn't working and there is probably an extremelly simple way to get this working.
 
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.

View 7 Replies

ActionScript 2.0 :: Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails?

Oct 10, 2008

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);

Heres the code:

Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {

[code]....

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.

View 1 Replies

ActionScript 2.0 :: If Statement Inside If Statement Won't Work

Mar 30, 2011

why this code won't work

[Code]...

I'm sure you can put if statements inside other if statements, seriously I can't figure it out

View 4 Replies







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