ActionScript 1/2 :: Update "money" Variable With A Function?

May 13, 2009

I am creating a roullete wheel type game. I am having a problem updating a total when I call a function to add the variables. I have a variable "myMoney" that is initialized at 50. After I spin the wheel, I want to add the bets to the current value of "myMoney." I have another variable, "slot1Bet" that is initialized at 0. I am trying to call the function updateMoney(myMoney) which than should take the current value of "myMoney" and set it equal to itself plus the slot1Bet. The trace statement for "money equals...." returns 500 and so does the updateMoney function.m so the correct value is returned based on the slot bet.

_global.myMoney = 50;
_global.slot1Bet = 0;
trace("updated money equals " + updateMoney(myMoney));

[code].....

View 5 Replies


Similar Posts:


ActionScript 3.0 :: Health & Money Variable In Game

Oct 28, 2010

I'm working on a game where I need to have a variable for money and a variable for Health, or in my case, I call it Energy. Most tutorials I'm finding are in AS2 and the AS3 ones are not this basic thing that I need. Basically, I have an item shop with a pizza button, and in their respective dynamic text fields, you can see the status of your Energy and your Money. So, let's say the person clicks the pizza to buy it, Flash will subtract 10 (for 10 bucks) from the person's total money value and add 15 for total Energy points.This is what I've written so far and I'm writing all the script in Flash, not outside using classes or packages. I can tell already that I'm missing something. How do I write it so that Flash knows to add 15 Energy from that Pizza button and can I update the values of the variables and kick off that mouse event in the same function?[code]

View 2 Replies

Convert Variable To Money With 2 Decimal Places?

May 6, 2010

I have a program that adds values together. I need the variable to display with 2 decimal places. Right now $1.50 would look like: 1.5

How do I make Flash display the zero automatically?

View 2 Replies

Create This : Function Money () :: Only 1 Point Added?

Oct 6, 2009

I create this : function money () {total++;income.text=total;} and a button. income.text  is added by 1 each time the button is onRelease. I need only 1 point to be added  no matter how many time the button is pressed.

View 8 Replies

ActionScript 2.0 :: Create A Dynamic Text And Set It's Variable To "money"?

Mar 25, 2011

When i try to make like a shop game, i create a dynamic text and set it's variable to "money". When i test it, everything works fine. But when i try to add a static/dynamic text close to it, the text won't be visible.It's kinda hard to explain, so here's a preview:

The "normal" version:
megaswf.com/serve/1044057
The other version:
megaswf.com/serve/1044059

View 9 Replies

Actionscript 3 :: Flash Cs5: Set A Variable Using A Function, Then Read That Variable From A Different Function

Jan 29, 2012

I have a public variable and I am trying to set it, then read it from a different function:

public var str:String;
public function DailyVerse()
{
function create() {

[Code]....

My trace results says null. Why does it not give me "hello"?

View 1 Replies

ActionScript 2.0 :: Update Targetpath With Variable After OnRelease?

Jan 25, 2010

I have the following script:

set ("positieMC", "homeMC");

_level0.contentMC[positieMC].homeBTN.onRelease = function() {
gotohome();[code]....

and I want these targetpath rewritten with the new variable of positieMC everytime I click the button. But somehow this doesn't work. I have the idea that theze targetpath are not rewritten when I click the button.

View 2 Replies

ActionScript 2.0 :: Check For External Variable To Show Update Notifications?

Mar 25, 2011

I was wondering if it's possible to show a notification for new updates in a swf file.

Like what if I upload a .txt file somewhere and inside it there's a variable, something like;

Code:
newupdate="Version 2.0 is ready for download at domainname.com."

And this will show up in a text field somewhere in my swf file. Is this possible? Are there any pros and cons about using this method of notification?

(Using Flash CS5, AS2)

View 3 Replies

ActionScript 3.0 :: Money Dosent Stop At 0?

May 28, 2011

var score:int = 100;var money:int = 200; btnfeed.addEventListener(MouseEvent.MOUSE_UP,feed);function feed(event:MouseEvent) { if ((score == 200)&&(money <= 0)) { score += 0; money -= 0; Cash.text = String(money)

[code].....

View 2 Replies

ActionScript 2.0 :: Add $5 To The Total Amount Of Money

Apr 10, 2005

i want it to add $5 to the total amount of money, but the problem is, is that my code doesnt work, in the frame actions i have:

[Code]...

View 4 Replies

ActionScript 2.0 :: F8 - Formatting Number To Money?

Sep 5, 2007

What is an easy way to format a number to money? I want to add commas for every thousand, and force the decimal to 2 digits.

View 4 Replies

Would It Cost Money To Have Online Flash Game?

Aug 27, 2009

If we made a game in flash that has online, would it cost money to have the online server or something?

View 3 Replies

ActionScript 3.0 :: Paypal To Take Money Within The Same SWF And Just Allow Further Functions To Run On Confirmation?

Oct 30, 2011

I am currently writing a Flash AS3 website where users upload file(s), I take payment, and when payment has been received, the files are emailed to me to be processed, all within the same SWF.

I can get the upload and email part all working nicely. My question is about the payment part. Ideally, I would like to use Paypal but the critical point is that payment and then confirmation must all be within the same SWF. If Paypal directs to another page and returns to a different URL (or the same one for that matter), the SWF would have ended which would be a problem for the emailing part.

Is there a solution for Paypal to take money within the same SWF and just allow further functions to run on confirmation?

View 5 Replies

Flash :: Make Money Selling Made Products?

Dec 23, 2011

I was wondering if anyone has attempted in profiting off of using Flash to make useful applications? I started the website [URL] which the products are both made in flash (one of the members here coded it for me). I am just interested in seeing if anyone else has tried selling flash as software? If your wondering I have sold about $450 worth of the basketball/football one and just started the first aid one

View 1 Replies

Actionscript 3 :: Return An Object With An Update Data, That Is Pass In To A Public Static Function?

Dec 23, 2011

How can I return an object with an update data, that is pass in to a public static function?

GetDate.dayName(MyDate.setDate(1984,3))
//MyDate with new info (year, month) will be pass into GetDate.dayName
package hwang.time

[code].....

View 3 Replies

ActionScript 2.0 :: HitTest For Coin - Adding More Money To Total Amount

Apr 10, 2005

I have a simple money script [for my game] and I want to say, ok when I walk over a coin, I want it to add $5 to the total amount of money, but the problem is, is that my code doesn't work, in the frame actions I have:
Code:
money = 0;
and in the hitTest for the coin I have:
Code:
if (_root.dude.hitTest(_root.coin) {
_root.money +1
}

View 4 Replies

Actionscript 2 :: Function's Local Variable Through A Concatenated Variable String?

Mar 7, 2012

how you would target a function's local variable through a concatenated variable string.For example:

var txt = "Hello World";
function testing(msg) {
var test1 = msg;[code].........

I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?

View 2 Replies

ActionScript 2.0 :: Variable In LoadMovie Function - Load A Variable That Contains An Url To An Image

Jul 28, 2007

I'm trying to combine PHP/SQL and Flash. I've got a problem now. I want to load a variable that contains an url to an image. so the variable is like this: [URL] Now I want flash to load the image, not the text. The variable is called 'img1' but the loadmovie function doesn't work when I put it in.

View 2 Replies

Flash :: Professional - Update Via SCUP - The Client Is Not Supposed To Be Interfered With The Update Progress

Nov 17, 2011

I am deploying Updates via SCUP and SCCM to hundreds of Computers. Fortunately Adobe provides an SCCM Update Catalog for both Adobe Flash ActiveX and Adobe Flash Plugin. But now my Problem: After publishing the Update via SCCM, the client is not supposed to be interfered with the Update Progress (which is working) I figured the Updater works like this: First SCCM checks if a Update needs to be deployed, if this is the case, The Flash Updater begins. First the old Flash Version is beeing uninstalled. But now: if the Client has a Browser Window (IE, or Firefox) open, the Updater is not able to install the new Flash Version and quits with an Error. This leaves the Client PC without any Flash (because its being uninstalled before) How can I prevent Flash being uninstalled due to the Update progress not working while a Browser window is open?

View 1 Replies

Actionscript 3 :: Movieclip Using A Timer To Update Dynamic Text. No Update?

Dec 12, 2011

I've got a movieclip, which has got a dynamic text element.The movieclip uses a package for its codeThe package if obviously derived from the MovieClip classI've got a timer, that updates the dynamic text field every second.When debugging the code, I see that the timer works well. Its updates the value of the dynamic text field.

View 2 Replies

ActionScript 3.0 :: Monitoring Variable - Call A Function Whenever The Variable Value Changes

Nov 24, 2010

I want to monitor a variable. Whenever the variable value changes I want to call a function. In actionscript 2 I can use "watch" but in as3 what can do ?

View 1 Replies

ActionScript 3.0 :: Declaring A Variable In A Function: Either The Function Or The EventListener - Doesn't Work

Nov 27, 2009

I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc. Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. 1120: Access of undefined property theAnswer. I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.

[Code]...

View 4 Replies

ActionScript 3.0 :: Function Returning Array And Declaring A Function With Event And Variable?

Jul 27, 2009

is it possible to declare function this way

ActionScript Code:
function startShake(e:MouseEvent, num1, num2):void

what i mean is it possible to send to the function not only en event but also a variable and a second question how can i access

ActionScript Code:
function stopShake(e:MouseEvent):Array

this array that function return.

View 1 Replies

ActionScript 3.0 :: Flex Data Grid - Update Column With Variable (not From Data Provider)?

Jul 27, 2009

I have a data grid who's data provider is set to an XML object.

Code:
<mx:DataGrid id="streamMonitorGrid" dataProvider="{_data.stream}" height="100%" width="100%">

[code].....

View 5 Replies

ActionScript 2.0 :: Passing Variable To Function Inside Function?

Sep 16, 2009

I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).

ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",

[code].....

View 1 Replies

ActionScript 3.0 :: Declaring A Variable Inside A Function To Use Outside The Function?

May 5, 2011

I want to create a vector, then call a function that populates that vector with arrays. Fine. The only catch is the function itself will declare new array variables to put into the vector, but are these new array variables private to the function only?e.g. something like this

ActionScript Code:
public var vec:Vector.<Array> = new Vector.<Array>();
private function populateVec():void {

[code]....

Is this "kosher"? a was declared in the private function but added to something outside the function..?

View 4 Replies

Actionscript 3 :: Use One Object's Method To Update A Variable In Another Object?

Feb 27, 2012

I am not sure if I worded the question correctly, however, I have code to detail it. Firstly, I have a class Class1:

[Code]...

View 1 Replies

Actionscript 3 :: Call Value Of Variable Which Is In One Function To Another Function?

Feb 18, 2010

I have taken variable in one function and want to use that value in another function.

View 2 Replies

ActionScript 3.0 :: Flash : Getting Variable Value From A Function To Outside The Function?

Jan 23, 2012

how to get variable value from a function to a text box here is the code :

import fl.controls.ComboBox;
import flash.events.Event;
import flash.events.MouseEvent;
TxtAnswer = Array();

[code]....

.. i want that variable "sk1" to next scene text box ..i putted the code like this :

q1.text = sk1;

but it is not working..

View 4 Replies

Actionscript 3 :: Function Use Variable From Another Function?

Jun 24, 2011

me how I can use the variable from one function in another function?

For example:

function init():void {
var test:Number = 1;
}

[Code].....

View 1 Replies







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