ActionScript 3.0 :: Simple 'for Loop' To Simplify?
Apr 3, 2011
im a complete noob. how would i get this code into a simple 'for loop' to add 3 sprites named heart1, heart 2 and heart3. basically to simplify this mess
ActionScript Code:
var heart1:Sprite = new Sprite();
with (heart1.graphics) {
beginFill(0xFF0000);
drawRect(0,0,20,10);
I have this switch and I know there must be an easier way to accomplish this. For example if the user selects something it sets that button to a certain frame in this case nSelected, and sets all other buttons to a frame labeled nDefault.[code]...
For each product a label is created determing its category unless a label of that category has already been created before. My while loop is supposed to stop the same label being created twice but apparently it doesnt! My function consists of an array of categories (kategorie[]) and an array of labels that were previously created (previousLabels).
I'm an AS2 convert and struggling. I can't figure out how to get my function to see my array. I keep getting an error that "i" is an undefined property.
var thingsToShrink:Array = new Array( b1, b2, b3, b4, b5 );
function shrinkBars(myArray:Array){ for (i=0; i < (myArray.length); i++){ myArray[i]._yscale = 0; }}; shrinkBars(thingsToShrink);
I'm trying to make a simple for loop that makes a line move. But it won't work, and when i search for "for loop" it gives me all these dynamic things that are WAY over my head.[code]The way i see it, the i should increase by 1 each time the loop is run, and then the line will move up by 1 until it is at x = 0 (it starts at x = -77). But when i preview it in flash and html, nothing happens at all.
I have looked everywhere for an example or tutorial on a delta time game loop in AS3. I found many fixed time step examples but very little helpful information on delta time game loops and how it works. I have seen examples that do the calculations in a timer and also seen examples that do the calculations inside the enter_frame event. All the examples I have seen are also incomplete and only provided me with bits and pieces.
I have an animation that has roll overs controlled by AS (see code below). It works the way I have the code, but it's really messy code. And I hate that I'm have the functions rewritten for each event.How can I simplify this code?
//On the main timeline var gearsEnabled:Boolean = true; var gears2Enabled:Boolean = true;
I have a test here which is for a more complex interaction, but the principle is the same. What I would like to know is how to make the code more efficient, possibly through array loops?
Been reading up on the flash transition object. I came up with this way of fading out one clip and fading in another and having them loop forever using the transition objects but it's very dirty coding and not very flexible.
Is there a way to clean it up so that I can add as many clips as I want without having to write more code, just by adding more movie clips to the stage?
I've set up a simple enter frame loop to adjust the alpha on a grid of movie clips ("bubbles") using a distance formula from the mouse pointer.I've got a hunch that while this works fine, there's a more efficient or processor friendly way to do it.
grid of mc's created here....and pushed into an array stage.addEventListener(Event.ENTER_FRAME, loop); function loop(e:Event):void{ for each (var j in bubbArray)[code].....
I have this code that's repeating for 40 different instance names that play 40 different movieclip names.
Is it possible not to repeat all this code for every instance name? For example creating a function that catch the instance name that is pressed and plays the correct moviclip name?
I have this code that's repeating for 40 different instance names that play 40 different movieclip names.Is it possible not to repeat all this code for every instance name?For example creating a function that catch the instance name that is pressed and plays the correct moviclip name?
Last week I made a class to simplify rollOver and rollOut event of a button based on MovieClip with ENTER_FRAME event. It works well but I'm not quite sure this is the best class, since I'm new in AS3 Classes. Now, if you don't mind to take a glimpse of my class.
Here is the class
Code: /** * VERSION: Early * DATE: 2011-11-15 * AS3
simplifying this piece of code right here using "for (i=0,i<numberOfArtists,i++) ;in order to make it dynamic by passing a variable for the amount of artists via XML.
Flash is not in my toolset, but I am an old Director jock and have spent some hours dipping my head into the Flash manual. I suppose that makes me a promising beginner-level poster. I'm working in CS5.
I need to make a simple Flash-based sound player for a website for a newly-released novel (http://www.bearriverbooks.com/index.html). I want the user to click on what appears to be an icon (or image), which kicks open a simple controller and starts playing a sound file (a radio interview, which I will probably export using Flash's voice compression). Nothing fancy. Just want the visitor to hear the sound and be able to apply simple controls (stop/start/rewind/volume).
I can learn ActionScript, I suppose, since I used to dream in Lingo, but my life would be a lot simpler if I could just publish a controller without having to roll my own. I'd like to think there's a magic button somewhere that can do this, but I haven't found it yet.
Are there any programs or features in flash that can simplify flash vector art?
I just realized that one of the reasons why my program might be running so slow is that I made the images out of lots and lots of circles. When things didn't look right I often just put larger circles over smaller ones. I didn't think that flash might still be drawing the invisible circles underneath-
i'm trying to do an infinate loop for my m.clip.the looping part does not want to loop...it loops back to my firrst frame even though there are two same picture in the movie clip.....here's a sample of what i use for the infinate loop script..
I have need of loops / nested loops that pick different figures depending on where you are in the loop. The whole function needs to run through 'ml' times. 'ml' is a dynamic figure. Loop 1 = While the loop is within the first 12 iterations, 'exconemp' must equal 100. For iterations 13 - 24, 'exconemp' must equal 102.5, for 25 - 36 it will be 105.06, for 37 - 48 it will be 107.69. This needs to change every 12th iteration until it has reached 'ml'. The calculation takes the value of the previous 'exconemp' and then multiplies that by 0.025.
Loop 2 = While the loop is within the first 120 iterations, 'abc' must equal 0.015 and any further iterations must use 0.01. This must also work in a way to figure out whether 'ml' is higher or lower than 120 and work accordingly. My main issue is this - how do I get the loops to run through as this: While the iteration is < 12, do this, THEN take the final figure (12th iteration) and start on 13 - 24, do this THEN etc etc. How do I produce a THEN statement? I can get the code to pick up the final values, but not change along the way.
basically I need a loop within a loop to compare two different arrays in my actionscript3 lottery game. I have attempted the loop but I cannot seem to get it to work ...
[Code]....
So basically within this code check_win is a button. Once the button is clicked it runs the loop. It is meant to take an instance of matches which contains 6 properties and loop until index is greater than matches. According to my output this is happening but the second loop doesn't appear to do anything.
How do i word a for loop to make it loop through multiple arrays?I want 1 for loop to loop through multiple arrays in order to move/alter objects.I want to keep the arrays separate.
ActionScript Code: characters = new Array(); characters[0] = male;