ActionScript 3.0 :: Dividing An Amount Evenly Within Limits

Dec 14, 2009

I often need to divide quantities in recipes. Normally, this is straightforward: I have an array of items to divide and a total, so I can do something like

[Code]...

However, this time I have been handed a curve ball: some of the items have a maximum amount they can be. For example, item A has a maximum amount of .25, item B is maximum of 1, the other items have no limits. So if the total amount is 3, and I am dividing it by 3 items I can't simply set each one's amount to 1 (as I normally would, as the code above does). I need to set the amount of A to .25 so there is still the .75 "left over" that I now need to apply evenly to the remaining items.

So that means the other 2 items B and C would be 1.375 each -- but, as I said above B also has a limit (of 1), so B would be 1 and C (no limits) would get the whole .75 remainder, and be 1.75. So A=.25, B= 1, C=1.75 for the total of 3. My question is, even conceptually, how would I approach a problem such as this in AS?

[Code]....

View 1 Replies


Similar Posts:


Arrays :: Get Evenly Spaced X / Y Cords From Given Size And Required Amount

Nov 8, 2011

I'm working in Actionscript 3, but this is pretty general.I'd like to make a simple function that I can call, e.g. GiveCords(Width, Height, Num) that will take a width and height, map that out and using the Num variable place the given amount evenly across the space.Say I give it a value of 500, 500, 1. I'd expect it to return an X, Y position of 250, 250.But I'd like it to return an array of given points with X, Y.So If I gave it 10 points, it would find the best position for them all to be of even distance apart from each other.

View 1 Replies

ActionScript 3.0 :: Video Amount Played MORE THAN Amount Loaded?

Feb 11, 2012

I have been having a serious issue with custom video where flash is saying that the amount of the video so far played is MORE than the amount that it has downloaded, which is clearly impossible. This results in various problems, such as the playhead (scrubber) moving past the end of the loader bar. I posted a simple demo that displays the amount loaded and the amount played in text fields. You can see it at: [URL][Code]...

View 5 Replies

Actionscript 2.0 :: Video Amount Played More Than Amount Loaded?

Feb 11, 2012

So I have been having a serious issue with custom video where flash is saying that the amount of the video so far played is MORE than the amount that it has downloaded, which is clearly impossible. This results in various problems, such as the playhead (scrubber) moving past the end of the loader bar.I posted a simple demo that displays the amount loaded and the amount played in text fields. You can see it at: URL...[code]I encoded the video at a high rate so that it would download slowly. It may not playback smoothly, which I am not concerned about. What I am concerned about is the numbers below the video what are derived from ns.bytesLoaded and ns.time. If you watch it for a bit, the amount played should exceed the amount loaded.

I double checked the video duration and the bytestotal that flash is reporting and they are correct. I don't know of any way to check the accuracy of bytesloaded.If your internet connection is super fast, you may not see the issue - it only occurs when it is playing back faster than it is downloading - if this is the case, you may need to throttle your speed down, or start downloading a large file while you are watching this demo in order to see the issue.But this is a serious issue and means that building custom video interfaces with loadbars and playheads is impossible!

View 1 Replies

Actionscript 3 :: Dividing Several Img Tags In String?

Jan 31, 2011

I have a string that looks like this:

"assets/images/1.jpg;assets/images/2.jpg;assets/images/3.jpg";

how can i create an array that pushes each link in it and removes the ;?

something like this:

var images:Array = {assets/images/1.jpg,assets/images/2.jpg,assets/images/3.jpg};

View 1 Replies

ActionScript 3.0 :: Dividing An Image Into Hexagonal Grid?

Sep 14, 2009

I have an image of a human body which needs to divided into Hexagonal Grid pattern and the hexagons should be highlighted on mouse rollover and also clicks. It will be time consuming if I make these hexagons manually coz they will around 1000 in numbers.

Also, I need to zoom the hexagons on clicks.

View 5 Replies

Actionscript :: Coldfusion - Rounding Bug When Dividing Then Multiplying

Oct 20, 2011

I am doing the following in actionscript in Coldfusion Flash Forms:

90 / 3.7

Gives me:

24.3243243243243

Whereas the calculator gives me:

24.32432432432432

Note the extra 2 at the end.

So my problem occurs when I am trying to get the original value of 90 by taking the 24.3243243243243 * 3.7 and then I get 89.9999999999 which is wrong.

Why is Actionscript truncating the value and how do I avoid this so I get the proper amount that the calculator gets?

View 2 Replies

ActionScript 2.0 :: Calculator - Dividing Input Data Into Half?

Mar 2, 2003

PHP Code:
half_btn.onRelease = function() {
output1 = input1/2;
};
I have that applied to a button.. but instead of dividing the input data in half.. it subtracts 2.

View 14 Replies

ActionScript 3.0 :: Adding (or Dividing, Multiplying, Etc) Values In Text Field?

Mar 29, 2010

I am trying to calculate the values on user entered text fields (which only accept numbers) along with the values of user selected combo boxes. I have a function to a button:
 
reviewQ.calcBtn.addEventListener(MouseEvent.CLICK, calcAns);
function calcAns(e:MouseEvent):void
{
reviewQ.calcAns_text.text = "Your calculated result is " +

[Code]....
 
Right now, all I am getting is the actual values entered in the text fields and selected in the combo boxes. How can I get the sum of this values to show on my "calcAns_text.text"?

View 6 Replies

ActionScript 3.0 :: Add MovieClips Between Others Evenly Spaced

Feb 13, 2010

I have two movieclips, I have managed to calculate the distance between them. The problem is I now need to figure out how to add movieclips between the distance of the two movieclips and if I add more than one movieclip they need to be evenly spaced and all should follow a straight path from the two original movieclips.

ActionScript Code:
var numOfItems:Number = 5;
var pnt1X:Number = pnt1.x;
var pnt1Y:Number = pnt1.y;
var pnt2X:Number = pnt2.x;
var pnt2Y:Number = pnt2.y;
[Code] .....

View 3 Replies

ActionScript 3.0 :: Evenly Spread Out 4 External .swf's?

Oct 1, 2009

I am using he uiloader component to load 4 external swf's. But I've got a problem with spreading the uiloaders evenly on the stage when it resizes (with different browser sizes). How can I solve this to put the :

1 uiloader on 0% vertical axis
2 uiloader on 25% vertical axis
3 uiloader on 50% vertical axis
4 uiloader on 75% vertical axis

how to achieve this with AS3 code.

View 2 Replies

ActionScript 3.0 :: Dynamic Space Evenly Horizontally?

Aug 25, 2009

I am trying to figure out how to space evenly horizontally object of different width.

View 1 Replies

ActionScript 3.0 :: Evenly Space Movieclips With Different Heights?

Feb 11, 2011

I have the following code, which works beautifully when all the boxes are the same height. The basic point is that I have three boxes on the stage, 10 pixels apart. If you click and drag those boxes above or below each other, they reorganize themselves.

// based off Dynamic Stacking AS3 @ http://blog.soulwire.co.uk/code/open-source/dynamic-stacking
var mcArray:Array = [mcA, mcB, mcC];
var mcSpacing:int = 10;

[Code]....

View 4 Replies

ActionScript 3.0 :: Evenly Spaced Dynamic TextFields?

Feb 5, 2009

I have a few textField objects that are created dynamically with XML. I want to space them evenly horizontally, how would I do that? So far this is all I have, but it does not account for different character lengths per textField.

Code:
for (var i:int = 0; i < xmlList.length(); i++) {
var tf:TextField = new TextField();

[code]........

View 5 Replies

ActionScript 2.0 :: Space Evenly MovieClips In Runtime?

Aug 16, 2009

How to "space evenly" movieclips in runtime usin actionscript?

View 2 Replies

ActionScript 3.0 :: Distributing Objects Across Stage Evenly?

Jan 14, 2010

In need of a function to match the functionality of Flash's Align tool to "space evenly horizontally" between either two objects or to the stage.

here is a template of a function that I have been playing with:

ActionScript Code:
public function spaceEvenlyHorizontally(objects:Array,toStage:Boolean=false,obj1:DisplayObject=null,obj2:DisplayObject=null):void{

[Code].....

View 1 Replies

ActionScript 3.0 :: Placing Items Evenly Spread In A Circle?

Jun 9, 2009

I have a round workfield and want to place 10 items evenly divided around the border. So basically I want to spread 10 items over a circle (not a line).

View 12 Replies

Duplicate A Movie On The Stage 4 Times Evenly Spaced Out?

Apr 16, 2010

I am trying to duplicate a movie on the stage 4 times evenly spaced out

Actionscript Code:[code]..............

View 4 Replies

Php :: Distribute The Chance To Display Each SWF Evenly Among Banner Collection?

May 26, 2010

I am working on The ausdcf.org to try adding several banner ads in swf format to the top. The client chose not to go with Google AdManager, but prefer a "minimal approach" to do this task. What I am trying to do is sort of "mimicking" the way Google AdManager does for banners, that is, to split the chance of each particular swf to be shown to the visitor evenly among the banner collection.

Definitely I can add some jQuery code to do this from client-side, a random number generator and if-else statement would work - just $.load() it However, what if I'd like to make sure those disabled Javascript (is there any now btw?) still be able to see different swfs in each visit.

View 1 Replies

Flex :: View - Evenly Distribute Columns In A DataGrid?

Jul 14, 2010

I have 16 columns in a DataGrid in my Flex app. The first 15 look fine, with the column, simply containing the text, but the last one has a lot of extra space. Essentially, the columns are just big enough to fit the first 15 and all that extra space is tacked onto the 16th column.

How can I evenly distribute the space over each column?

<mx:DataGrid x="127" y="9" id="view"
dataProvider = "{currentBuffer}" width="497" height="480">
<mx:columns>

[Code].....

View 2 Replies

ActionScript 1/2 :: Evenly Spacing Dynamic Text Fields Defined By Variables?

Aug 4, 2010

What im going to be doing is replacing the bottom info with just a link-strip, unfortunatly I didn't want to have to sift through ten dynamic text fields re-animating every one with tweens to the way I wanted them so I set them all to a parent variable defined as "mt", such variables being as follows:HomePortfolioDocumentationDev BlogCase StudiesSupport For

View 4 Replies

Actionscript 3 :: Algorithm To Solve The Points Of A Evenly-distributed / Even-gaps Spiral?

Dec 3, 2010

First, just to give a visual idea of what I'm after, here's the closest result (yet not exactly what I'm after) image that I've found:[URL] BUT, it doesn't exactly solve the problem I'm after. I would like to store an array of points of a very specific spiral algorithm. The points are evenly distributed The 360 degree cycles have an even gap If I'm not mistaken, I think it's obvious that the two first points would be:

[Code]...

View 2 Replies

Pasteboard Expansion Has Limits In CS3?

May 28, 2007

I'm using a very wide object in Flash CS3, and I didn't have a problem with the pasteboard automatically expanding to contain it in Flash 8 Pro, but apparently CS3 has limits as to how far it'll let the pasteboard expand, -2880 px to 3620 px or thereabouts. This means I have to move my object off of x:0 y:0 to work with it. This won't kill me, but it does seem to be a step down from Flash 8. Anyone have any news on why this change was made, and if there's any way to correct it?

View 4 Replies

Mc Following Mouse But Within Limits And Smoothly

Nov 30, 2009

I am doing an animation with a movie clip that needs to follow the mouse on the Y axis only smoothly and needs to stay inside a fixed dimension. (e.g. the mc could moves 200px left or 200px right maximum) And I want it to stop smoothly too when it reach the limits.

View 1 Replies

ActionScript 3.0 :: How To Make Limits

Jul 21, 2010

1)i dont know how to make limits! ... and what i mean by that ... for example ... how to make a car unable to move on the buildings ?or how to make the a car dont fall out of the screen ?

2) i also need something ? .. what is the function that could make the screen Zoom In , or Zoom out ??

3) also i wants to know ... how to make the screen Move like to make a car in the middle of the screen and moves as it moves ?

View 5 Replies

ActionScript 2.0 :: Stretching Outside The Limits

Sep 30, 2004

ive seen in a few places were pressing a button drops down a menu, which extends outside the size of the flash movie. So that it goes over whatever text is actually underneath the movie. Ive tried to do the same by just making the menu go below the movie, but that just gets cut off

View 8 Replies

ActionScript 2.0 :: Center A Mc With Limits?

Jun 18, 2007

I created a hit test for stop a mc on the top of the stage.

It 's blocking all right, but i need that when is blocked then align on the center again.[code]...

View 2 Replies

ActionScript 2.0 :: Stretching Outside The Limits?

Sep 30, 2004

ive seen in a few places were pressing a button drops down a menu, which extends outside the size of the flash movie. So that it goes over whatever text is actually underneath the movie. Ive tried to do the same by just making the menu go below the movie, but that just gets cut off

View 7 Replies

ActionScript 3.0 :: Mc Following Mouse But Within Limits And Smoothly?

Nov 30, 2009

I am doing an animation with a movie clip that needs to follow the mouse on the Y axis only smoothly and needs to stay inside a fixed dimension. (e.g. the mc could moves 200px left or 200px right maximum) And I want it to stop smoothly too when it reach the limits.

View 2 Replies

ActionScript 3.0 :: Bitmap Limits With ScrollRect In 3D?

Oct 19, 2009

If we have a Bitamp with more than 16777216 pixels (or one side larger than 8191 px) Flash 10 doesn't show it (Flash 9 and earlier has smaller limits even).One solution to this is to use scrollRect to limit the size displayed.OK, that works.

But Flash 10 has another problem, if we use any 3D property (rotationX, z, etc), flash transforms your MC in bitmap, so we can reach the above limit even when we are not working with bitmaps...A bigger problem is that although our MC could be really small (at least less than 16777216 pixels), when we apply a 3D transform like rotationX, the displayed MC can grows enough to reach the limit. And... we can't use scrollRect with 3D MC. But we have a trick here too, there are two ways to use scrollRect with 3D:

1. Create a 2D parent, then create the 3D displayObject inside of that parent.
2. Set cacheAsBitmap to true for the 2D parent.
3. Create a grandparent container to hold the first two items.
4. Set cacheAsBitmap to true for the grandparent container.
5. Apply scrollRect to the grandparent container.

These methods are really differents, with the second I couldn't use scrollRect to avoid reaching the bitmap limit. I think that's because in the second we apply scrollRect to the parent and 3D to the child, so nothing breakes our child from growing.With the firs method we apply scrollRect to the child, and the 3D property to the parent.

Code:
var p: Sprite = new Sprite();
var c: Sprite = new Sprite();
p.addChild(c);

[code]....

View 0 Replies







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