ActionScript 2.0 :: Sorting User-defined Numbers Largest To Smallest?
Jan 30, 2004
I am looking for a way to sort numbers enterred by a user, prefferably in order smallest to largest or vice verser - but at very least to find the smallest & largest numbers of the ones enterred.There are approximately going to be 15 numbers or so.
So for example:
Enterred A = 56
Enterred B = 7
[code]...
when sorted or the other way round (largest to smallest).this could be done with comparrisons but for 15 numbers it would be A LOT of comparisons.
How would I do to sort this array by the largest sum and not just the first number? var myArray:Array = new Array(100, 200, 9); myArray.sort(Array.DESCENDING) //puts out (9, 200, 100) How would I do to get it (200, 100, 9)?
I'm trying to get the 255 smallest numbers from an array made up of all the alpha values in a given BitmapData, and storing these numbers in the Alpha array for paletteMap().We all know how to get the smallest/highest number from an array, or to delete repeating numbers or even to average numbers inside an array. I've been tweaking for 2 days with these possibilities but unfortunately I can't find anything satisfactory.
Is it possible to have a movieclip in FlashCS4 that can be scaled by the user once the file has been posted on the web? Scaled by dragging the corner of a loader or something?
I don't understand why within my function, initially the status of stage.scaleMode via a trace() is NO_SCALE, then it becomes SHOW_ALL. The code below is found at three different location in my overall code.
wrote the code for motion straight into the action panel of the bubble symbol and simply duplicated the symbol alot to add more bubbles. What I wanted to do is change all that code into global functions that can simply be called by each movie clip thereby cleaning it up alot and making it more modifyable. The problem is that I can't figure out how to write and call the functions properly. Here is what I have:
Layers: Actions: where the functions are defined Bubble: contains symbols (clip calling the functions)
I am trying to load external swf's into my main swf through nested movieclips.Its like this: STAGE > contents_mc > loader_mc Also most of the code is from tutorial's out on the net.Content_mc I have the following MC's in content_mc (on 2 separate layers, if you want to know):
- Preloader_text (PText) - loader_mc (LoaderExt)
[code]...
Problem: I am having a problem in calling the function ClipLoader and loading a clip through the loader_mc MovieClip (the text in Purple). The reason I am using this is eventually I will put in code in contents_mc to load various external swf per conditions i give.
I'm creating a product page for a client. The flash portion of it is generated dynamically using an xml document. The issue I'm having is with the features portion of the programming. During the generation of each page a list of features is brought in. Those features all have an associated hotspot that is displayed on the product image. What's supposed to happen is when someone rolls over the feature list item, the list item is highlighted, a description box is displayed and the hotspot glows. Vice versa, when someone rolls over the hotspot the hotspot glows, the list item is highlighted and a description box is displayed.
My issue comes with the communication between the two. Here's what I'm doing so far:XmlLoader is a class I created to deal with getting the nodes. getXMLNode takes two parameters - the parent node and the name of the node we're looking for)
Code: var featureNumber:Number = 1; for( var feature:XMLNode = featuresNode.firstChild; feature != null; feature =
i am quite newbie towards to actionscript 2.0 cos i am now learning on actionscript 2.0 here is the file attachment for you to check.Greetings.zipOutput cannot be worked.I am hoping to see the exact output:Greeting = Hello!Salutation = undefinedSubject: Brick Oven
I tried stage.width, but it doesn't work because in my flash I have graphics that goes out of document bounds and stage.width calculate it with them.I need a method that only restrict the user defined document width/height.
i have been trying to write a multi player bingo game, i have got passed all problems, except 1, the random function, the random function works fine with 1 player but when i play the game with more than one user each user will get different numbers and not the same numbers. how would i do it so all users get the same number is there a way where i can shuffle 90 numbers then load them into a movie clip then all users play the movie clip then all users get the same number is this possible or is there a simple way. I have also tried getting random numbers from php mysql but get the same problem,
as always, I only drop by when *I* have a problem... I'm such a selfish bastard (is it allowed to even say "bastard" on here?) Anyways. I know that (in PHP) there's a way to use user-created functions to sort an Array (usort & uksort) by custom comparisons- you pass the Array and the name of your function and it uses your own function to "re-organize" the array.
Is something like that also available / possible in Actionscript? Or do I have to write my own function where it loops through the array entries and writes them into a new array? I need it relatively quick so setting up my own might take too long. The setup is pretty much this (just in case you're interested):
I've written a function that restricts user input to just numbers (0-9,.) and stores the input in the associative array, userInput[]. It works but seems inefficient looping through the entire input text string to scrub out invalid characters. Anyone have suggestions for a more efficient approach? Note that a working solution must correctly process mouse or cursor key movements/edits within the input box.
Also, you can see I'm using the KeyboardEvent.KEY_UP event to trigger the processing. The docs seem to indicate TextEvent.TEXT_INPUT is really the proper event for this purpose. I started with TextEvent.TEXT_INPUT but found the event is triggered before the last key pressed is actually added to the instance. The result is that the function was always one characterbehind. Is there an easy way to get the current text in the input box, including the last key pressed, when processing TextEvent.TEXT_INPUT?
I would like to restrict user input to numbers only between letters. for example: the user is allowed to input "a2b", but "2ab" or "ab2" isn't allowed.
I need to create a text field where the user can only write numbers from 3.0 up to 12.0 with any decimal. With any number he imputs i need another text field to store the number lowered to its nearest .5 number.
for example
input 3.1 result 3.0 input 3.4 result 3.0 input 3.6 result 3.5 input 4.6 result 4.5
I am using flex builder 3.2, Action Script 3 and develop for Flash Player 10 and am quite new to it. when I call a method of a self defined class, I get the 1061 error (not defined). But the class and the method exist and are public, so what the hell am I doing wrong? Flash Builder is even offering me this method in the auto-completion, so at least the builder knows it... I have already tried cleaning the project (as this is the common source of strange errors when working with java/eclipse),
edit: solved... The problem was that a package had the same name as the variable I used for the class. Very strange error message, thumbs down for this .
I am trying to automate the input process so that when a user inputs 3 numbers into the first field, it automatically jumps to the next one. I have the code to do it and it seems as though it should work but, for some reason, when I move focus from one field to the next the data in the previous field is re-arranged so that the last character input becomes the first (610 becomes 061 - for example).Here is my code:
Context: Making a guessing game where up to 20 users guess times. A countdown timer script runs at the game start. As time goes by, flash compares the guess with the real time, moves a movieclip (horse1, horse2 etc) along the x axis and displays an integer (time between the guess and ever changing clock [horse1.displaybox1, horse2.displaybox2, horse3.displaybox3, etc]). This is all working.
How to I display the current closest guesser?
I TRIED to avoid arrays, but doubt I can. JUST learning about arrays and for loops, but found this elegant code to find the max number in an array (or with modification could get the min):
maxValue = function (array) { mxm = array[0]; for (i=0; i<array.length; i++) { if (array[i]>mxm) {
What is the largest XML file that can be loaded into flash? I have a 14MB XML file that I'm trying to load into flash. It gets to the listener function that listens for the Event.COMPLETE event fine, but in there when I try to set e.target.data to an XML variable I get an error that says one of the tags doesnt have an ending. I know for a fact that it is a well-formed document. So I'm assuming it's cutting some of it off. Is there a size limit for xml files?
So, after just being dumped on from a great height by our development company I need to create an entire site in flash with login and dynamic addition of content etc etc.. What would be the recommended maximum size (pixel wise) for a flash site... what I have here is 1600px sq? It's mostly database driven so shouldn't lag too much from a point of view of file size, I'm just concerned because of the short deadline and I find this kind of large size wise to do 100% in flash..
i have 2 arrays, a and b... in array a i have a bunch of random numbers.... now i want to loop through array a find which of the elements is the largest. for example if a[4] is the largest number in the a[] then i want b[1] = 4 and so on....
//array a full of random numbers: a[1] = 4 a[2] = 3 a[3] = 1
[code]....
so if a[4] is the bigest, b[1] will have 4 and if a[1] is second biggest, b[2] will have 1 and so on... is there an algorithm that can do this for me with an array length of X?
I am making some flash banners for a college website and the CBS guidelines require all file size be less than 40k.How the hell can you do anything with that?!
A) Do unused library items effect file .swf size? B) I'm using a lower res .jpg for a background which is about 10k, and each line of text i use for only 40 frames is like 20k! (3 sets of text=60k) Why is simple text so large? C) Creating movie clips and tweens doesn't really seem to affect file size, is that mostly accurate? D) Everything considered, is the main thing that affects final .swf size the size of each file used on the timeline? Is there a best practice for converting graphics to graphic clips, movie clips, symbols, etc.?
I want to make a box just like the one on *this* picture. That's a screen shot from an app made with Flex, which proves it's possible to do. I've been drawing boxes using the sizes I get from calling functions like getLineMetrics and textHeight, but the box is always to big (vertically).
I want to make a box just like the one on *this* picture. That's a screen shot from an app made with Flex, which proves it's possible to do. I've been drawing boxes using the sizes I get from calling functions like getLineMetrics and textHeight, but the box is always to big (vertically).
have a series of ad banners which must fall within a 35kb size allowance. The banners aren't huge and the main image file is 12kb (JPEG) at the smallest, any smaller and there's anoticeable degrade in image quality. The swf's are coming out at 40kb, is there anything ican do to shave off a few kb's? I've tried everything i can think of (lowering the JPEG quality in Flash).Another hurdle is that i need to supply a GIF alternative, again under the 35kb this seems to be the hardest task! at the moment they're coming out at 220k