ActionScript 3.0 :: Make Application Variable Or Static Variable?

Oct 16, 2010

The Idea is i want to make avariable that stores his value after i close the swf and open ti again,

an example:

i make acounter

var i:int = 0;
var timer:Timer = new Timer(1000);
timer.start();

[Code]....

the value of i will increase but after i close the application and open it again the value will return to 0 , keep the variable stores his value after closing the application ?

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Concatenate - Make The Variable Change With The Variable?

Jul 19, 2006

I'm trying to achieve something i thought would be extremely easy, but i can't get it to work!

[Code]...

View 1 Replies

ActionScript 3.0 :: What Is Static Variable

Apr 13, 2011

What is static variable. what is difference between  static variable and public variable?

View 2 Replies

ActionScript 2.0 :: Make Variable Within Variable?

Jan 10, 2008

I've searched around and wasn't able to find any solutions to my problem, which probably just means I'm going about this wrong way, but here it goes...I have a bunch of variables named like so:box0Wbox1Wbox2W

View 3 Replies

ActionScript 3.0 :: Keeping A Static Variable Within A Loop?

Feb 7, 2011

I need to keep my "grid" + [o] value from 1-9 but add to the to the gridArray number (hence currentNo) within this double loop.

[Code].....

View 10 Replies

Actionscript 3 :: Variable That Refers To A Static Class?

Nov 10, 2011

How can I replace

public function Mainclass()
{
Calculations.getDistance(5,9,4,2);
}

[Code]....

I'm not lazy (lying? :p), but I use the class more than 20 times, and it looks better if I replace al these long classnames.

View 1 Replies

Flash :: Static Variable Showing As Null

Feb 13, 2012

I have a class named Locator that I use to GeoLocate a user. There's a static method in that class called "locate()". This method then calls another method which sets a static variable called "loc" to an instance of a LngLat class.The issue I'm having is, when I call the locate method at Frame 1 on the scene, and then try to access the loc variable it shows as null... but when I trace the loc variable after it's set in the Locator class it shows as an object.[code]and then trace the variable at the end of the static method in the Locator class it shows as a object and the city is traced as expected.

View 1 Replies

ActionScript 3.0 :: Using A String To Call A STATIC Variable?

Sep 26, 2010

It is possible to call variables using this[ "stringname" ] for instance, to refer to a variable called "stringname".

However, when referencing a static variable by the name "stringname", the "this" attribute no longer works if applied.

Is it possible to use this technique with statics?

View 5 Replies

ActionScript 2.0 :: Current Time As Static Variable?

Oct 7, 2008

I've been trying to create a script that pulls the current time and turns it into a variable, the problem is the variable keeps updating as the time changes, where as I need it to remain static as the time that is was when the variable was first created...it's just a simple:

Code:

var theTime = today.getTime();

View 2 Replies

ActionScript 3.0 :: Accessing A Static XML Variable From Within A Switch Statement

Jun 1, 2009

In the following class

Code:
package
{
public class Factory
{

[Code]]....

A break point on the "Okay" line shows that x1 is null but x2 is equal to "<entity id="DRONE" points="100"/>".

If I take the whole block out of the switch statement, both x1 and x2 are equal to the expected xml.

View 6 Replies

Flash :: Access Of Undefined Property (Static Variable)?

Jul 12, 2011

I'm trying to change a static variable in the class's constructor. At the start I have:

public static var mainReference:Main;
public static var timerReference:Timer;
public var timer:Timer = new Timer(1000);

This is so my static functions can access main and timer. At Main's constructor I have:

mainReference = this;
timerReference = timer;

The problem is, the first gives no error when I compile it, but the second tells me Access of undefined property (timerReference).

View 1 Replies

Flash :: Dynamic Variable Names In Static Function?

Dec 14, 2011

Is there any way that you can have dynamic variables inside of a static function considering that you can't use "this" inside a dynamic function.

What I am trying to do:

public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";

[Code]....

View 3 Replies

ActionScript 3.0 :: Using Static Variable To Create External Classes?

Feb 25, 2011

I've rarely used static variables or methods when creating external classes, but I have on occasion, and it's very useful when I need global access to a value. I've seen negative criticism on the use of the "static" keyword, but never understood why. Is there a right and wrong way of using it, or is this not true? I'd like to use it in a context similar to classes such as MouseEvent or TextFieldAutoSize, where there is a list of values globally accessible for identification purposes.

It allows better code readability, and also allows for easy customization in the future. The value of TextFieldAutoSize.NONE is "none", but as long as a programmer used the reference TextFieldAutoSize.NONE and not the string literal "none", Adobe could change the value of TextFieldAutoSize.NONE to be "hahahahaha" and everything would still work just dandy because (TextFieldAutoSize.NONE == TextFieldAutoSize.NONE) is still true even though ("none" == "hahahahaha") is not.

Is there any kind of negative impact on using static variables this way? Or even functions for that matter? I'd just like to clarify this before I go and build a large project around the idea this is perfectly okay.

View 0 Replies

ActionScript 2.0 :: Create A String Variable...and Then Use The Value Of That Variable To Declare Another Variable?

Jan 3, 2006

f you know PHP...then you know that you can create a string variable...and then use the value of that variable to declare another variable. like this:

PHP Code:

<?php$foo = "haha";$i{$foo} = "success";print $i{haha};?>

and it would display "success"...or like this:

PHP Code:

<?php$foo = "haha";$$foo = "success";print $haha;?>

and it would also display "success".

View 6 Replies

Professional :: Access Timeline Variable From Static Class / Singleton?

Nov 3, 2010

How can I access a timeline variable from a static class / singleton?

View 14 Replies

Actionscript 3 :: Why Is Static Class Member Variable Not The Same When Accessed From Different Parts Of App

Apr 5, 2010

I have an actionscript class with a static member variable defined.

public class A
{
public static var x:int;
}

When I try to access it from different parts in my code I don't get the same value in each spot.

A.x

I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file.

View 1 Replies

ActionScript 3 :: Cashier Game - Matching Updated Variable With Static One

Oct 28, 2011

I am attempting to create cash register simulation game and am running into a problem with a conditional statement that I am using to check whether the correct change is being provided to the customer and if a button is being pressed or not. In this game, the user can see the amount of the sale as well as the amount the customer pays. With this information they have to click on the cash drawer slots which will increase a variable called changeCount by the value of the monetary unit they have selected.

I am using an if statement to take them to the next frame if the changeCount = payment-sale and the confirm button has been pressed. To check for the button I am using a boolean to see if it is being pressed or not. For some reason, it is not registering the updated value of the changeCount for the if statement to work. If I trace the value with trace(changeCount); it will return the value I want.

The source code is pasted below:
package {
public class CashierMain extends MovieClip {
private var confirmBtn:ConfirmButton;
private var pennyBtn:PennyButton;
private var dimeBtn:DimeButton;
[Code] .....

View 1 Replies

ActionScript 3.0 :: Error - Null Object Reference When Creating A Static Variable

Feb 5, 2010

Basically I have 2 classes, A and B. B derives from A. Inside A, I declare a static variable/constant to the class of B. When I run the program, I get a null object reference error, with the line pointing to the class declaration of B, i.e.

Code:
public class B extends A

For reference, these are the 2 classes:

Code:
package
{
public class A
{

[code]...

Also, this error only occurs when the variable is static. If it's just a normal variable it works fine, i.e.

Code:
private var OTHER:Class = B;

If I change the static variable to point to a different class, it's also fine, i.e.

Code:
private static var OTHER:Class = Main;

I can probably work around this, but it's a bit of a pain in the ass. Anybody know what's causing it, or is this a Flash bug?

View 5 Replies

Actionscript 3 :: Unexpected Variable Assignment Inside Static Class Method

Feb 23, 2012

In the following code (thoroughly debugged) the first case (1) in the switch is met and a new instance of BannerSingle is assigned to retVal (the return value). Unfortunately, while the second case (2) is never met, the assignment therein to retVal takes place and I can't compile. When I comment out the assignment to retVal for "case 2:" everything works fine.

I've tried using an if/else instead and I still get the same odd behavior. Also tried a number of solutions involving separate variables, etc.

package fl {
import fl.IBanner;
import fl.Banner;

[Code].....

View 1 Replies

ActionScript 3.0 :: Static Variable Of Class Gets Reset When Depth Of Caller Is Increased

Jul 22, 2010

I have 3 swfs, and let's label them MovieA, MovieB, and MovieC. MovieB is a child of MovieA, and MovieC is a child of MovieB. So the hierarchy goes like this: MovieA -> MovieB -> MovieC. Each of these movies have their own document class, so they are each essentially a class extending MovieClip.

Now I have this other external class which contains only static variables. Let's call this class "TestClass" and let's say one of its static variables is called "testVar". So in MovieB's document class, I imported TestClass and set testVar = "hello world". In MovieC's document class, I imported TestClass and traced TestClass.testVar. When I publish and run MovieB, testVar is successfully traced as "hello world". Now when I publish and run MovieA, testVar is traced as undefined.

View 10 Replies

ActionScript 3.0 :: Static Variable - Access Buffer Array From The Particlecontainer Class

Dec 19, 2010

I'm currently working on a particle system for a game that I recently started development on, but I've hit a snag: I have a class particlecontainer that tells each particle what to do on enterframe, and which contains each particle as a child. I also have a class (mischandler) which has a static array that contains all current particles, as well as another static array that is a buffer to remove particles from the particlecontainer. Whenever a particle "dies", it calls a function which adds it to the buffer array in mischandler. However, when I try to access this buffer array from the particlecontainer class it does not recognize it as having any elements. If this is unclear here's a simpler explanation:

particlecontainer tells a particle to do it's enterframe function particle calls die() and adds itself to the removebuffer inside mischandler particle container tries to access mischandler.removebuffer but removebuffer has no elements Strangely, the particle can access the removebuffer perfectly fine and sees all the elements in it.

View 1 Replies

ActionScript 3.0 :: Variable Take Away Another Variable Which Makes Answer1 Variable

May 15, 2011

i have a variable take away another variable which makes answer1 variable i then want answer1 to be to the power of another variable how can i do this in flash

View 5 Replies

Flex :: Get Variable From ItemRenderer To Main Application?

Jun 22, 2011

I have a List with TextInput as item renderer. I want to get the value entered in the TextInput (form the TextInputItemRenderer) and pass it the main application to do some checks(upon tapping enter on the textInput -- see code below).

I know that we can do it thru dispatching event but I still don't understand how to pass a variable from the ItemRenderer to the main app.

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"

[Code]....

View 1 Replies

ActionScript 2.0 :: Variable + Variable = Variable. Sort Of?

Aug 29, 2007

Code:
var fruit1:String = "apples";
var fruit2:String = "oranges";
var fruit3:String = "grapes";[code]....

I need the variable fruit1, but for reasons I don't have time to get into, I don't know how to parse these two variables to make a parseable variable.

View 1 Replies

Flex :: Event Metadata: Using Static Variable For "name" Attribute?

Jun 24, 2011

I want to use the Event metadata tags to show what types of event my control will dispatch. The syntax looks like:

<fx:Metadata>
[Event(name="eventName", type="MyEvent")]
</fx:Metadata>

It seems like a best practice in Flex/Actionscript to define static variables that define event names like so:

public class MyEvent extends Event
{
public static const EVENT_NAME:String = "eventName";
// Other stuff..
}

It's a great practice since the event name can change easily and not have to be modified throughout the code. So my question is: Is there any way to use this static const in my metadata event tag? I can't seem to do something like this:

<fx:Metadata>
[Event(name="{MyEvent.EVENT_NAME}", type="MyEvent")]
</fx:Metadata>

Am I just ignorant of the proper syntax to do this, or is it impossible? Seems like it's just asking for hard to find bugs if someone decides to change the const since it is not strongly typed here.

View 2 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it

Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function

[code].....

View 6 Replies

Media Server :: Accessing A Variable From Different Application Instance In Fmis?

Mar 1, 2011

i like to know how to declare a global variable in FMS, so that i can access it from different application instance of a same application.

View 4 Replies

Flex :: Search - Application For PlayBook Text Input Variable

Jan 8, 2011

how to take what a user inputs into a s:TextInput and use that as a variable in a JSON data request? Basically, I want to have a user enter a search term, like "math" and then have that placed into a variable so I can use it in a JSON request. Something like public var q:String, except that my search box (and hence user input) is on another "view" of the application. I've just started with Flex Mobile applications and I might be way out of my league.

View 1 Replies

ActionScript 2.0 :: Flash8 - Call "them" By A Variable Rather Than Static?

Jul 14, 2009

Trying to replace the number on the following call with a variable... How could i do it? Have to remove 144 of them... rather do a loop for it...

Code:
_root.mc_movies_area.mc_area_54.mc_54.removeMovieClip();

View 1 Replies

AS3 :: Accessing Attributes Of A Static Variable Of An Object From Another Object

Nov 7, 2009

I have 2 classes, Display holds the currently selected Component:

public class Display
{
public static var selectedComponent:Component;
}

Component has an ID string and the selectedComponent variable is set on click:

public class Component extends MovieClip
{
public var id:String;
addEventListener(MouseEvent.CLICK, function() {

[Code]...

Removing the selectedComponent variable type so it reads public static var selectedComponent; removes the conversion error and seems to change the ID variable but it appears to only be a copy of the object.

View 2 Replies







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