Flex :: Flash Player: Get Reference Count For Variable
Sep 29, 2010
I'm looking to build a library that needs to be very careful about memory management. Basically, I have to create a static factory to "disperse" instances of my tool to requesting objects. (I don't have a choice in this matter, I really do have to use a singleton) We'll call that class FooFactory. FooFactory defines a single method, getFoo(key:String):Foo.
getFoo looks in a private static flash.utils.Dictionary object for the appropriate Foo instance, and either lazy-instantiates it, or simply returns it. In any case, FooFactory MUST keep a reference to each Foo instance created, so all Foo instances can be updated by FooFactory using a method called updateFoos():void.
[Code]....
View 3 Replies
Similar Posts:
Jan 11, 2011
I've created a timer to count elapsed time on a flash player of mine, I can't figure out how to control it though. For example I need the pause/ play buttons to (you guessed it) pause and continue the count.The dynamic text field that keeps count is simply called "count" and the pause button is btn_pause and play button is btn_play
Code below.
start_time = getTimer();
countdown = 7200000;[code].....
View 2 Replies
Dec 29, 2011
Is it possible to reference an object using a variable value?
For example, I have a function that is supposed to hide an image and add that image to an inventory list when the item is clicked.
All the image info is stored in an object (name, imgSource, visible, x, y);
I was thinking I could do something like this:
<fx:Script>
<![CDATA[
public var item:Object = new Object();
[Code].....
I want "item" to stand for knife so that I could change knife.visible, knife.xPos, ect.
View 2 Replies
Jan 19, 2011
I'm trying to make a volume button for my site and it looks something like this:
- ||||| +
i want the volume bar to start filled and when the user hits the minus button it lowers the volume and when it hit plus it takes the volume up well when I go down and up the volume bars start to get crazy...it just works when I go down the whole way and after it goes up the whole way, when I change direction on the midle of the path it jumps some bars...
Code:
volDown.addEventListener(MouseEvent.CLICK, menosVol);
volUp.addEventListener(MouseEvent.CLICK, maisVol);
var cliques:uint = 0
if (cliques == 7){
[code]....
View 1 Replies
Mar 21, 2009
I've searched the forums and can't seem to find an answer on this one.
How do I add a a counter on a mp3 player that counts the number of times a song is played?
Could I send this count number to a mysql database using PHP?
View 7 Replies
Mar 28, 2011
i have a variable declared in alchemy asm:
asm("var buffer:Vector.<Number> = new Vector.<Number>(100, true);");
i can populate it with data like so:
asm("buffer[%0] = %1;" : : "r"(index) : "r"(value));
what i can't figure out is how to get a reference of that asm "buffer" variable into actionscript.
(i did think of one way... what i did was to throw the "buffer" from alchemy asm, and then catch it in actionscript, but unfortunately it seems to leak a lot of memory).
is there a better alternative to doing this?
note that performance is critical, and using default alchemy marshaling is way too slow.
View 1 Replies
Mar 8, 2011
Theres any need to set to null a reference in this case?
private function initGame():void{
game= new Game()
}
[code].....
View 1 Replies
May 25, 2010
How do I reference the variable pointed to by the variable text but pointed to by more than one function?Say I have:
engine_level = 5;
tank_level = 3;
v_name = 'engine';
[code].....
View 4 Replies
Jun 12, 2006
Does anyone know, how to count the number of characters in a variable ?[code]...
View 2 Replies
Oct 24, 2011
When I am running a test on my code I am recieving the following error:
Quote:
ArgumentError: Error #1063: Argument count mismatch on Scripts::Player/playermovement(). Expected 0, got 1.
Even though I am recieving this error message, I am still able to move the player around with my keyboard inputs. How do I fix this? I far as I can tell I am not passing any variables to function call
Quote:
players.playerMovement
unless I am passing the
Quote:
Event.ENTER_FRAME
from the addEventListener command?In my Level.as file
Code:
public function Level void():void
{
...
addEventListener(Event.ENTER_FRAME, playerInputs);
[code]...
View 1 Replies
Jan 5, 2012
How do I reference the variable pointed to by the variable text?
Say I have:
engine_level = 5;
v_name = 'engine';
pb_name = v_name + '_p_button'; // so pb_name = 'engine_p_button';
level = v_name + '_level'; // so level = 'engine_level';
[Code]......
View 2 Replies
Aug 18, 2010
I am creating a 'healthy eating' resource for the local education authority where i work. What i need to do is create a game where healthy food can be dragged into a pot. The variable should increase after each item of food is added and the total added to the dynamic text box. Because the drag n drop script is one level down, i keep getting undefined in the text box on the root level. I cant seem to figure out why this is happening.
Code on draggable mc (this is one level down from root):
on (press) {
startDrag ("_root.carrot");
}
on (release) {
[Code]....
Dynamic text box var is called 'total' and this is also on the root level.
View 1 Replies
Mar 18, 2010
is it possible to create custom event with variable arguments count? I ask this because currently I use anonymous functions on events with variable parameters count to pass arguments to appropriate function, i.e:
Code:
addEventListener( MouseEvent.ROLL_OVER, function(evt:MouseEvent):void{mTBGp( pX, pY, l_w, l_h, isDone )}, false, 0, false );
addEventListener( MouseEvent.ROLL_OUT, function(evt:MouseEvent):void{mTBGe( pX, pY, l_w, l_h )}, false, 0, false );
and I don't want to do that because of weakReference.
1. From what I know if I set weakReference to true with anonymous function on in addEventListener GarbageCollector will delete them (and indeed I can see that my code stops to work on random, due to GC "kickin in")
2. When i delete my Object with addEventListener( weakReference = false ) the memory used by addEventListener is not freed ( unconfirmed, please elaborate on that subject also)That's why, from My point of view, usage of custom event is best, but unfortunately I use many addEventListeners with variable parameters count so (in above example 2 listeners. one 5 arg, second 4 arg) is there a way to do something like this? To write event that will take x parameters of any type?
View 6 Replies
May 12, 2009
I was thinking about how to streamline my code the other day and looked through my classes checking for possible memory leaks. I wonder when are variables declared inside of methods clear for garbage collection? or are they not and just hang around? For instance if I have a class like this:
[Code]...
Since the variable was declared without reference into the class how long does it stay in Flash's memory, or does it stay indefinitely because it cannot be nullified?
View 3 Replies
May 6, 2010
package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference
[code]....
In this Class, how they denote one as Weak Reference and one as Strong reference.
View 1 Replies
Mar 10, 2007
I've found a simple count up script over on Actionscript.org
var count:Number = 0;
var maxNum:Number = 1250;
var num:Number = 1;
this.createTextField("txt", this.getNextHighestDepth(), 0, 0, 100, 50);
[code]....
This works great for my use, but now I am trying to figure out how to make it count down. I've tried changing everything to opposites like count=1250 and maxNum=0 (I think this would be the minNum instead), count+=num to count-=num, and count>=maxNum to count<=maxNum.
View 3 Replies
Apr 30, 2010
Is it possible to restrict flex bar chart y-axis count?I have a very big name coming in my y-axis and i want to reduce or restrict it to 5 characters and on rollover i want to display it in full.
View 1 Replies
Dec 31, 2011
I'm trying to use google maps in my wpf c# project, I've installed Adobe Flash player but cannot for the life of me find the shockwave player object reference or when I add a new item in the toolbox find in, both in the COM lists. I had to download and install flash using internet explorer.
View 1 Replies
Oct 20, 2009
I want to be able to reference the text of a text box within an MCThe MC is called "box1", the text field is called "field1"...I have many MCs (all with field1 in them)... box1, box2, box3 etc etcObviously I can set the text to being something by saying...box1.field1.text = "set_this_text"However, I'm using a variable to come up with the "box1" bit. (Using an array and a loop to figure out which box I want to update based on where the user clicked). So, let's say I have a variable... and I want to say..boxClickedon = box1 //will be defined by userSo I don't know in advance about box1... I can only access it through "boxClickedin" variable, but
boxClickedin.field1.text = "set_this_text"
or
[boxClickedin].field1.text = "set_this_text"
[code]....
View 1 Replies
Mar 2, 2010
Is there a way to reference a function via a variable? In other words, instead of saying something like:
var theVar = someString + 'function';
if (theVar == 'functionName') functionName ();
to access it directly:
(someString + 'function') ();
using some kind of bracket notation?
View 1 Replies
Jun 9, 2009
Using AS2. I have a variable defined:
activenav = "services";
I then want to reference the variable in a MC string. I've tried many variations of this:
_root.my[activenav]Clip.gotoAndPlay("Out");
Essentially, I want Flash to see this as:
_root.myservicesClip.gotoAndPlay("Out");
Getting syntax error.
View 2 Replies
Apr 9, 2010
i have a function that read a variable from a text file, yet i can only read the variable from within the function. How could i create a global variable or such that i can then read from outside of the function.
Code:
var Make:LoadVars = new LoadVars();
Make.onLoad = function() {
VARIABLE = Make.textVariable;
[Code].....
View 1 Replies
Nov 12, 2011
The scene is a number of movie clips, all already added to the stage (i.e. not dynamically) and when one is clicked, I need to call a property of that clip. [code]...
View 3 Replies
Oct 14, 2008
How do you use a variable value as a reference to aMovieClip?I'd like to do this:
A2.visible = false;
myVar = A2;
myVar.visible = true;
[code]......
View 1 Replies
Jan 31, 2008
I am trying to write an attachMovie statement with a variable feeding the ID parameter.[code]...
View 1 Replies
Sep 25, 2009
I want to loop through an array and use the array value to reference a variable. The Setup:(For illustration only. Not actual script)
[Code]...
View 3 Replies
Aug 22, 2011
Can you have "ByRef" arguments in AS3 functions?
Primitive types in AS3 pass by value instead of reference. Is there a way to override that behavior and pass by reference for certain variables? [code]...
View 3 Replies
Feb 14, 2010
Code:
public function Text1Down(e: MouseEvent): void{
var textArea:Label=Label(e.currentTarget.id);
.......
}
I get this error:
Code:
TypeError: Error #1034: Type Coercion failed: cannot convert "text1Area" to mx.controls.Label.
I know that e.currentTarget.id is of type Label. All I want is to make a reference variable so I don't have to keep typing long names.
View 2 Replies
May 2, 2010
I'm writing a function which can take the names of different variables and use them to do some calculations. Long story short, I want to be able to call the function like this:
It probably seems like a really roundabout way to pass the variable through its name rather than just passing the variable itself. This is related to me using XML to get the variable names, so they come in as strings. Just bear with me here.
Inside the function, I want to be able to do something like this:
which should then trace the variable's value. Unfortunately, I just get an 'undefined'. How do I use 'this[]' to get the value of the variable from a string corresponding to the variable's name?
View 6 Replies
May 19, 2011
I'm not entirely sure that I've even asked the question correctly in the title but hopefully) this description will make it a little more clear.
Code:
private var mySpriteA:Sprite;
private var mySpriteB:Sprite;
[code]......
View 3 Replies