ActionScript 3.0 :: Math Functions - Starting Variable Status Strength With 10

Apr 23, 2011

I am learning AS3 and I try to remake an SimDate game. I have studies the functions and the Steps of the game and now I try to make the Functions myself.

I have 5 Attributes:
Strength
Knowledge
Charm
Health
Dollars

For each of them I have defined a variable. Now I need to make an math function. If I want to raise str:
statusstrenght = statusstrenght + addstr

This code is not the original. My other code is down below. I only wanted to show the process.
addstr == Math.random() *5
I wanted that the variable statusstrenght starts with 10. If I press the train Strenghtbutton the action addstr will be started and updates the statusstr with the new value. That's what I had in mind but I cant define the new value off statusstrenght + addstr. Do I have to add a new variable with newstatusstrenght or can I just overwrite the value of statusstrenght if I press the train strength button ?

Here is the code. The math functions aren't working. It is AS3.
import flash.events.*;
var statusstrenght:Number = 10;
var statusknowledge:Number = 10;
var statuscharme:Number = 10;
var statushealth:uint = 100;
var statusdollar:uint = 100;
[Code] .....

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Keep Package Functions From Starting Automatically

Jan 13, 2011

I've got a movie clip which i "exported for actionscript" inside of the properties dialog.this is the code inside of the package that was created to go along with it (MovieClipName.as)[code]...

View 6 Replies

Actionscript 3.0 :: Distance Between 2 Objects : Math. Functions?

Feb 18, 2010

often seen in simple flash games. So you can look at an example. http:[url]....Green object shots a bullet and what i want to acheive is to run bullet toward black bar even if bullet is shot to the left side of the screen. Bullet should make a circle, slow down and change direction to the bar and finally proceed faster and faster to the bar. Simply it should behave like remote control rocket chasing enemy. Right now i am with this: Code: Select all

function movingBull(e:Event):void [code].........

//of course i dont know what should be inside if statement

//to make the code work.

View 2 Replies

ActionScript 2.0 :: [FMX] Array Math, Graphing Functions

Dec 2, 2003

I want to make a graph. Specifically, a graph of a normal population distribution.I think (please correct me if I'm wrong) that the best way for me to do this is to use two arrays for coordinates and use the lineTo function to connect the dots:

- An Index array up to about 300 as the "x-axis"

- A Second array to represent the "y-axis" created using the formula for normal population applied to each entry of the index array

So I need to create these two arrays in FMX. the first array i think should be created with a For loop: for(i=0;i<a.length;i++){} The second array somehow applying my formula to each entry in array 1.I believe my methods are correct, but I am having a great deal of trouble getting the AS down properly and I can't find many good sources on it.

View 4 Replies

ActionScript 2.0 :: Math With Prototypes And Functions - Find The Distance Between Two Points

May 19, 2003

So, right now when I want to find the distance between two points, I go: dist = Math.sqrt((this_x-that_x)*(this_x-that_x)+(this_y-that_y)*(this_y-that_y)) BLECH! I don't want to do that every time. So I want to make a nice little function that I can apply to an object. Problem is, I don't know how to do this. Is it possible to end up with something as easy as: Math.dist(thisclipname, thatclipname)? How do you guys set up functions that do bulky math and return nice clean numbers?

View 4 Replies

Actionscript 3 :: Javascript Implement Math Functions Using Its Own Algorithms Or Outsource To Cpu/processor?

Nov 20, 2011

ActionScript3 states the following:

Note: The Math functions acos, asin, atan, atan2, cos, exp, log, pow, sin, and sqrt may result in slightly different values depending on the algorithms used by the CPU or operating system. Flash runtimes call on the CPU (or operating system if the CPU doesn't support floating point calculations) when performing the calculations for the listed functions, and results have shown slight variations depending upon the CPU or operating system in use.

My web application works with very large and small numbers that I suspect may see a difference depending on which machine is running it (especially with mobile devices whose processors aren't as powerful as desktop machines'). My question is, is this behavior a function of the language?

That is, I assume some languages implement their own algorithms for the above functions, and so may be more consistent (except for differences in round-off errors introduced by the choice of processor/CPU that would exist for all languages).

Anyone know if Javascript has it's own algorithms, or does it outsource them to the CPU/processor like ActionScript?

View 1 Replies

ActionScript 2.0 :: Articles That Explains The Overhead Added To A Flash Program When Using The Math Functions

Feb 18, 2009

I would like to ask if there are any articles that explains the overhead added to a flash program when using the Math functions in AS2.0?

View 0 Replies

ActionScript 2.0 :: Audio's Playing Status As Variable?

Dec 27, 2009

I have two audio files. I want one to play (inter) when a button is pressed but only if another audio file (magnificent) is currently playing. I have tried using the following...

ActionScript Code:
yellow.onPress = function() {
if (_root.magnificent.playing!=1){

[Code]....

...but it doesnt seem to differeniate whether it is playing or not. The "inter" audio still plays even if the "magnificent" audio isnt.

View 3 Replies

ActionScript 1/2 :: CS3 - Industrial Strength Autorun?

May 5, 2010

how to put together a bullet proof Autorun that will work on any Windows system. I've been playing around with "[autorun] OPEN=OpenMe.exe" and with "Bin" folders and "Shell" scripts for days.  Why doesn't anything work?  All I want to do it to open "START.exe". If I double-click on START.exe in the list of disc files - it works completely.  How do I get Windows to do the double clicking for me?Do I have to re-write or re-structure my project?  (I don't believe I should.)Does it matter what burning software I use?  (I don't believe it does.)Is DVD different from CD as far as autorun is concerned?  (I don't believe it does.  As long as the player exists on the system.) 

View 3 Replies

ActionScript 3.0 :: GlowFilter Strength Translation To Flash CS5 ?

Feb 16, 2011

I've noticed a bit of discrepancy of using the public AS3 API for the GlowFilter strength property. All the others seem to make sense when comparing the visual effect using the Flash CS5 tool on a MovieClip. However the strength seems to baffle me. The API lists strength being a number from 0 to 255:

http:[url]..........How does a number between 0 and 255 translate to a number between 0 and 100% as listed in Flash CS5. In other words what would be the parameters I should use to repeat the same effect as this:

If I try to apply this using code this is what comes to mind for each of the properties:

blurX = 5blurY = 5color = 0xFF0000quality = BitmapFilterQuality.LOWstrength = 255 

So does strength of 100% act the same as the max value of strength allowed by the API, which is 255? Here's what happens when you do this with this code:

clip_mc.filters = [ new GlowFilter(0xFF0000,
1,5,5,255,
BitmapFilterQuality.LOW,[code]............

When I test this I get different results. Here's the filter effect as applied at design time:And here's the filter effect applied dynamically using the GlowFilter class (see code above):

Notice the slight difference in the strength? How can we accurately replicate filters given these two strength scales? I need to apply a class to a load of MovieClip objects at run-time and don't want to have to go into the library and paste the filter preset 100+ times.

View 7 Replies

ActionScript 2.0 :: CS3 Variable String Is Wiped When Starting A New Function

Apr 2, 2009

I have 5 links that exist as one large font and four small fonts. The large one dictates the current page and the smaller ones are links to other pages, which become the large font if they are clicked to dictate they are now the new page. When a link is small font link is clicked, it activates 3 tween animations for presentations sake, all dont in actionscript 2. The small font ._y is placed at the bottom of the page and swoops back up. The current large font ._y swoops down and, over this, the newly selected page large font swoops up to replace the previous large font.

I have tried specifying what the current page is in a new object variable so that is is remembered for when a new link (small font) is clicked. However, whenever a new function is started it seems to wipe out the current value of the object, so it cannot pass on what the current page is. Here is the code (I posted this earlier in the newbies section but think it's more suited to this forum, please delete the earlier post if necessary, sorry):

[Code]....

View 6 Replies

ActionScript 2.0 :: Math Function - Set Variable To Random Position

Sep 2, 2011

I cant get this to work. I think its pretty self explanatory what I want to do, set _x to a random position (b1 - b6)

Code:
onClipEvent (load) {
stop();
b1 = 462;
b2 = -462;
b3 = -1388;
b4 = -2314;
b5 = -3240;
b6 = -4166;
} onClipEvent (load) {
RanNum = Math.ceil(Math.random() * 6);
_x = ["b" + RanNum];
}

View 2 Replies

ActionScript 3 :: Flash - Math.floor Acting Like Math.round?

Mar 7, 2011

Here is the problem:

var p:int = 0;
var n:Number = 0;
n = 32.999999999999999;
p = Math.floor(n);
trace(p); // returns 33
n = 32.11111111111111;
p = Math.floor(n);
trace(p); // returns 32

I would expect both of these to return 32. I have searched, and it seems this is an unreported bug in AS3. Or ... am I doing something wrong?

View 4 Replies

ActionScript 2.0 :: What Is The Diffrence Between Math.floor And Math.round

Sep 26, 2005

Wat is the diffrence between these two?

View 2 Replies

Flash - Calling The Function Within That Function And Later Stopping The Loop - Starting And Stopping Functions?

Jan 7, 2012

I am making a character walk. This code will make him wobble to the right and when thats done it will trigger him to wobble to the left and then call the function again to continue the loop.I can get the loop to work fine by calling the function but how do I STOP the function? Also I want to call it later on. Is there a way to start and stop a function?

function wobble()
{
var ws = .1;
var dis = 1;

[code]....

View 2 Replies

ActionScript 2.0 :: [F8] Math.round And Math.ceil?

Feb 16, 2009

I have a code in which I have to use Math.round if a certain value is for example 3.67 (67 is higher than 50) and Math.ceil if a value is for example 3.23 (23 is lower than 50). What can I do to make flash calculate if what after the dot �.� in 3.23 (for example) is higher than 50?

View 2 Replies

ActionScript 3.0 :: Use Same Variable In Different Functions?

Feb 23, 2010

I have a function that includes a variable which I need to use in a different function after some effects occur.

View 6 Replies

ActionScript 3.0 :: Variable Timer Functions

Mar 2, 2009

I am trying get a timer function that I can change the interval on? IE. I invoke the function for 5 frames and the last one I want to have a different delay time. It seems that for each action I have to create multiple listeners and multiple functions for? Surely there is a way, without producing a class, that I can just chaneg the timedelay? But, AS3 wants to declare the time before the function.

View 2 Replies

ActionScript 3.0 :: Variable Tweens In Functions?

Nov 10, 2010

I want to be able to set variable tween parameters, but I know its not always good to set variables within functions. For example:

function clickHandler(MouseEvent){
var myTween:Tween = new Tween(object, "width", Strong.EaseOut, 1, variableWidth, 1, true);
myTween.start();
}

Is this the only way to do it, or can I change myTween parameters within the function without declaring a new tween each time?

View 6 Replies

ActionScript 2.0 :: FMX-variable Accessible Outside Of Functions?

Aug 6, 2003

I don't know why the value of my variable my_str is undefined outside of this function:

loadText = new loadVars();
loadText.load("data.txt");
loadText.onLoad = function(success) {

[Code]....

ps: I tried making my_str a global function or even defining it as _root.my_str but I always get the same result..it's undefined outside the function...I need that value for something else so...

View 1 Replies

ActionScript 2.0 :: CS3 Flash Variable Within Javascript Functions?

Sep 21, 2010

just a quickie - im sure this is possible but for some reason its not working, - can you put variables within javascript calls, ie

getURL("javascript:swffit.fit('my_flash',1024,(700 +_root.imageHeight));");

where _root.imageHeight is a variable within flash

anyone know where i may be going wrong?

View 2 Replies

ActionScript 1/2 :: Use String Variable In Movie Functions?

Apr 1, 2009

I want to know how to use a string variable as the URL in a Movie Clip event.

sample code:
var numCount:Number = 1;
var strMov:String = "rock" + numCount;
bob.removeMovieClip(strMov);

View 5 Replies

ActionScript 1/2 :: Repeating Functions - Variable Won't Change

Oct 21, 2009

I'm trying to repeat a function that basically will attachmovie on a "tileset", an image depending on the parameter. It's called AddID(i), and currently there's only 2 valid options, 0 and 1, images showing, X and O. There's a Button, and theres an array and a function that shows an image of the tile depending on its ID value loaded from the array.

My problem is: Everything works just great as if you repeat the function by clicking again, but... When repeating the function by code, all the tiles will have the Image of the last tile added.

[Code]...

View 4 Replies

ActionScript 3.0 :: Losing Variable Values Between Functions?

Nov 9, 2009

I'm trying to do something simple in actionscript as simple as this:- Create a variable: var urlVideo:String;- Use that variable inside a function and give it a value: urlVideo = ideoElemento.url.text();- Then create a new variable and give it the urlVideo value: var url:String = urlVideo;

Here's my code:
var idVideo:String = "12";
var urlVideo:String;

[code]....

View 14 Replies

ActionScript 3.0 :: Defining Variable Types In Functions?

May 2, 2010

if defining variable types in function parameters gives any speed boost.

e.g

ActionScript Code:
function DoIt(param1,param2,param3):void
{

[Code]....

is there any performance difference between above functions. in theory compiler should be able to manage memory more efficiently when knowing what data to expect, but is it so in flash

View 3 Replies

ActionScript 3.0 :: Pass Variable Values Between Functions?

Oct 16, 2009

How do you pass variable values between functions where the addEventListener is in the first function? I am trying to get the color value passed into my event handler. [code]...

View 6 Replies

ActionScript 3.0 :: Create A Variable That Can Be Used Or Changed By Multiple Functions?

Nov 14, 2011

how do i create a variable that can be used or changed by multiple functions?

View 5 Replies

ActionScript 2.0 :: Passing Variable Names As Arguments For Functions?

Sep 24, 2008

Is it possible to pass variable as arguments for a function? I wish to update a boolean variable via a function, by passing the name of the variable to the function, like so:

Code:
function ENVSegment(curSegment:Boolean, nextSegment:Boolean) {
curSegment = false;
nextSegment = true;
} var attackSegmentIsRunning:Boolean = false;
var releaseSegmentIsRunning:Boolean = false;
[Code] .....

Much shorter, and easier to understand. Also, less repetition of the same blocks of code over and over...

View 1 Replies

ActionScript 2.0 :: Define And Call Functions - Won't Trace The Variable

Jan 8, 2009

I'm just getting into this and can't seem to make the simplest thing work! I'm trying to learn to define and call functions. I get no errors but it won't trace the variable:

[Code]...

View 3 Replies

Actionscript 3 :: Functions That Can Receive Unknown / Variable Amount Of Parameters?

Nov 28, 2010

How can I define functions that can receive unknown/variable amount of parameters?

View 2 Replies







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