ActionScript 1/2 :: Variable References To Objects?

Aug 30, 2010

I've got a 15x3 grid of dynamic text fields in an object called "textbox" that I want to reference through a for loop, so I don't have to have 45 lines of code for assigning stuff to those fields.I have each dynamic field named by their placement in the grid, so, c0a, c0b, c0c, c1a, c1b, c1c, etc.I can also name them c00, c01, c02, if necessary.
 
I tried:
 
for (i=0; i<15; i++) {
textbox.c[i]a.text = "Cell " + i + " A";
textbox.c[i]b.text = "Cell " + i + " B";
textbox.c[i]c.text = "Cell " + i + " C";
}
 
but that gives me a syntax error.I also tried naming them c00, c01, c02, c10, c11, c12, etc., so I could do a double nested loop:
 
for (i=0; i<15; i++) {
for (n=0; n<3; n++) {
textbox.c[i][n].text = "Cell " + i + n;
}
}
 
but that gives me a syntax error too.So, is there a way to access all of these with a for loop, or am I going to have to do it the long way?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Dynamically Detecting All References To Objects?

Feb 19, 2011

Having grown tired of dealing with uncollected objects mucking up my game level/performance management, I've decided to make a dedicated garbage class which will hold arrays populated by all the strong references I make. I can then just null out/removeChild/removeListener all the contents of these arrays whenever I need to ensure GC will pick up certain objects.What I'd like to know is the following: is there any way within AS3 (or community made AS3 libs) to detect all current references/listeners/etc. that might keep any given object from being collected? I know there are dependency-mapping utilities out there for debugging, but I'm looking for something that can be called dynamically from an object or its parent to find references to the given object and is suitable for regular runtime implementation.

View 1 Replies

Actionscript 3.0 :: Create Variable That References A MovieClip?

Aug 9, 2009

I am just starting to learn Flash. I am trying to make a "simple" Flash menubar to add to a basic html/css site I am building, as a learning project. I figured out how to make the navigation "buttons" using frame labels and event listeners. All the nav buttons will be identical, except for an image and the link destination. I know enough about ECMA based code to be dangerous to myself, so rather than make 7 individual buttons, each with there own AS and objects, I am wanting to make it more efficient by reusing the redundant information.

This is the logic than I am trying to use:

Create a generic button named "button_mc" that has a child which is a variable instead of actually pointing to a specific object. Then, create 7 different instances of that object (button1, button2, etc), and in each instance assign the proper image (contained in a mc) to the variable that is in the parent object.The problem I am having, is that I can't figure out how to make a variable that will reference a movieclip or graphic.[code]...

View 4 Replies

Flash :: Flex - If An Object Is Garbage Collected Are The Reference Counters Of Objects It References Decremented Automatically?

Jun 20, 2011

I was thinking about Flash GC the other day and came up with a question about how reference counting would work in the following 4 class scenario (assume GuiMain is the movie's document class):

[Code]...

View 4 Replies

ActionScript 2.0 :: Aligning Variable Sized Objects And Objects Inside Them

Jun 29, 2006

How do I align a movieclip, which width and height is user-defined, inside another object (this one is static, though). Top-left alignment is easy, x=0 and y=0, but what about center, center left, bottom left, etc? Math(.round) i suppose, but how?I want an object (static) inside the movieclip (user-defined) to stay aligned to, for instance, the top right corner, similiar to the minimize, maximize and close buttons at the top right of your browser.. The height and width data is pre-defined by the user in another file.But that does probably not make any difference...

View 3 Replies

ActionScript 2.0 :: Referencing Objects By Variable Name

Jan 11, 2007

I have a simple function that dynamically creates text fields. My text field name is referenced by var thisTextField. Problem is, when I try to do things with my text field, actionscript shoots back an error as such: There is no property with the name 'text'. How am I supposed to apply properties to my object if my objects name is a variable?

Code:
function showProducts() {
var products:Number = 0;
var thisTextField:String = "product" + products + "_txt";
for (var itemID in _global.rtsData[_global.rtsPos]["products"]) {
[Code] .....

View 2 Replies

ActionScript 3.0 :: Adding Multiple Objects To A Variable?

Dec 6, 2009

I'm trying to apply a tween fade in effect to 3 objects, it's hard to explain but here's what i have
 
function goDown2(e:MouseEvent):void {
var tweenfadeIn:Tween = new Tween(graphic_btn, "alpha", None.easeOut, 0, 1, .1, true);

[Code]....
 
I wanna apply this tween to illustration_btn, and resume_btn

View 3 Replies

AS3 :: Removal Of Two Objects Added To Stage With The Same Variable Name?

Jun 15, 2011

I'm going to start by saying that i am very new to flash and the concept of Stage is still very new to me.

I have the following problem: at a given time i have:

var foo:MyClass() = new Class();
stage.addChild(foo);
...
foo = new myClass();
stage.addChild(object);

so now i have two or more foo objects on stage. my variable is for one foo, and i need to remove them all from the stage.

View 4 Replies

ActionScript 3.0 :: Sorting An Array Of Objects And Returning Another Variable

Aug 29, 2011

I have an object array into which I've pushed a number of objects with different variables :- myArray.push({myRef: 1, myValue: "W"}); I can sort the array in numerical order using :-myArray.sortOn("myRef", Array.NUMERIC);but after sorting I would like to collapse the array using something along the lines of :-myArray.join("");to join the OTHER variable (myValue)...Is it possible to do this without pushing every instance of 'myValue' to another array and then joining that?

View 4 Replies

Flex :: Garbage Collect Variable In It Even There Are Other Objects Binded To It?

Jan 22, 2011

I'm wondering how to garbage collect a variable in Flex even if there are other objects binded to it.

View 1 Replies

ActionScript 2.0 :: Dynamic Variable Names When Loading Objects?

Jan 19, 2009

I am trying to create a new "BitmapData" object via a variable name. The following code is an example of what I am trying to do, but of course it doesn't work.
Code:
import flash.display.*;
this.createEmptyMovieClip("bmp1", this.getNextHighestDepth());
var BitmapNAME = "bmpData1"
var BitmapNAME:BitmapData = new BitmapData(200, 200, false, 0xaa3344);
bmp1.attachBitmap(bmpData1, 2, "auto", true);

View 4 Replies

ActionScript 2.0 :: Creating Multiple Objects Using Variable Statement

Jul 30, 2006

This shouldn't be too difficult. Heres my code:
for(i=0; i<30; i++){
var box[i]:Object = new Object()
box[i].id = [i]
box[i].name = "default"
box[i].location = "default"
box[i].type = "default"
But its not working. I keep getting error messages concerning the var box[i] statement.

View 2 Replies

ActionScript 3.0 :: Associating A Loop Variable To Objects Created In It?

Jun 3, 2009

I create some movieclips dynamically through a loop and store them into an array. I add an event listener to all those movieclips. In the function to which I direct the listener I want to be able to get the loop variable value associated with each movieclip. For example if you click the movieclip that was created the first time the loop ran then you would get the value 0.

Hope I have explained myself well enough. Is it necessary to create a custom event class for this?

[Code]....

View 3 Replies

ActionScript 2.0 :: Resize Multi Objects Through Loop & Incrementing Variable?

Jan 5, 2009

if i wanted to modify the xy size properties of several pieces of media through a looping function and an incrementing variable how could i do it? resize multi objects through loop & incrementing variable

View 1 Replies

ActionScript 3.0 :: Adding/Removing Objects To/from An Array Based On A Variable?

May 8, 2009

So a small example of my situation...On my stage I have 5 items labeled item1_mc, item2_mc, item3_mc and so forth...they all have two keyframes on their respective timelines, one labeled "active" and the other "inactive". My code contains 2 arrays, inactiveArray and activeArray and a variable known as energy that regularly goes to and from 0 - 100.

What I am looking to achieve is basically the function of...

if energy >= "insert given items 'active threshold' 20, 40, 60, etc..." then add it to the activeArray, if it is not, remove it and add it to the inactive array.

all objects in activeArray gotoAndStop("active");

all objects in inactiveArray gotoAndStop("inactive");

I have tried many different ways of achieving this effect but I always end up with duplicates and extras or something doesn't move when it's supposed to, where it's supposed to, it just ends up into a giant cluttered mess and I start from scratch.

View 8 Replies

ActionScript 2.0 :: Passing Values In A Variable In A Movieclip To Objects On Main Frame?

Jul 11, 2010

im trying this every which way.creating global variables etc.I have a movie clip with a text area (lets call it txttest)there is text inside it which i want to send from this movieclip on the main frame to a text area (lets call that one txttestB) on the main frame. Whatever i try i get undefined in the text area on the main frame.I have tried this...

_global.selectedcompany = txttest.text;
_root.txttestB.text = _global.selectedcompany;

View 1 Replies

Actionscript 3 :: Way To Map Object ID References?

Nov 4, 2010

I'm writing an application where I have many objects (data models) that are identified by a unique String ID that every such object possesses and these objects can refer to each other by their IDs.So far so good but now I need to keep track of which object keeps a reference to another object and of course there are cases where an object references (or is referenced by) more than one other object and I was wondering what would be the best method to store these references? In a simple map data structure I could just map one object's ID to another but as mentioned there are cases where an object can hold a ref to an arbitrary amount of other objects

View 1 Replies

C++ :: Why Some 'Types' Are References While Some Are 'Primitives'

Mar 19, 2012

Types like Movieclip , String, Object act as references when declared and defined, while types like int, Number are primitives. Why such difference has been made. Why not all of them can be primitives ?

View 1 Replies

ActionScript 2.0 :: Multiple CSS References In One Tag?

Aug 15, 2009

I'm using the CSS object (TextField.StyleSheet) to format my dynamic text, which is loaded from an XML doc. I tried referencing more than one class, like <span class="body bluetext">. However, it doesn't seem to work because it ignores the first syle(s) and only applies the last one in the list. I'm guessing Flash doesn't support this (since they're CSS support is already very weak). Just want to make sure I'm not doing something wrong.

View 0 Replies

ActionScript 3.0 :: References And Event Listeners?

May 17, 2010

Lately I've been twitching in the back of my head wondering just how many references to objects that I'm making, and whether or not they are getting GC'd or not.My question in this sense refers to event listeners and whether or not they are removed in certain cases where you get rid of an object. Two examples:

First, and I think this one is an easy one... when you create an object that adds an event listener to itself INSIDE it's own methods (e.g. this.addEventListener(e:Event, function)), when you REMOVE that object (this), do it's event listeners disappear too? I can only say yes, because they are referencing THAT object and are INSIDE that object.

So I think that question answers itself (but I'd love to know if the truth says otherwise).

But secondly, if you add an event listener to an object from a sibling or parent object, and then remove the object, does that event listener stick around, therefore maintaining a reference to that object and keeping it in memory? And is that the concept that people keep referring to of 'weak' event listeners? E.g. someChildObject.addEventListener(e:Event, function)Also, are event listeners by default strong or weak?

And I am assuming that 'yes', it DOES keep the reference. Which, if you are a n00b programmer like me, you probably are all like, 'aww sh*t damn, how am I supposed to make sure that my objects are getting thrown in the garbage collector's mouth of goodness every once in a while?

View 1 Replies

ActionScript 3.0 :: MovieClip References From A Class?

Jul 15, 2009

I have a files that has movie clips and nested movie clips on the stage. I am now writing a class and want to give the MCs event handlers and other properties.
 
When I do something like the following: myMC_mc.MyOtherMC_mc.mouseEnabled = false;
 
I get the error: 1120: Access of undefined property myMC_mc.
 
I added this to the top of my class and it seems to take away the error, but I thought this was not needed in AS3 anymore.

private var myMC_mc:MovieClip;
private var myMC_mc.MyOtherMC_mc:MovieClip;
 
What do I have to do to not get the error? How is this done right?

View 3 Replies

ActionScript 3.0 :: Trace References The Buttons?

Nov 10, 2009

I have this bit of code I am trying to understand how the trace references the buttons.
 
private function PX(e:Event):void {
 xd=new XML(e.target.data);
xl.removeEventListener(Event.COMPLETE,PX);[code]....

View 3 Replies

ActionScript 3.0 :: Movieclip References In An Array

Feb 27, 2011

I have a movie clip in which I have a number of sub movieclips. The number of sub movieclips can vary, so I would like to keep track of them in an array. I am doing that like so:[code]The trace seems fine, showing the names of the correct sub movieclips, but when I try to change the alpha I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 3 Replies

See All External File References In Flash?

Sep 12, 2010

I need to update the dynamic text in this flash file I have and export it to SWF. I've looked at the actionscript in all the frames and symbols but the only thing I've found so far are "stop();" 's

I tried exporting this to SWF to see if the file size was the same as the current working version on the site, and it was about 15kb smaller, and does not work at all.

How can I see all external file references in flash? I need to be able to tell my boss which files are needed or at least what is missing.

View 5 Replies

Embed Youtube Video Without Any References?

Nov 1, 2011

I need i way to embed youtube videos, without any reference. I need something like this [url]... Here the only thing is the youtube logo, no external click, and no title.

View 1 Replies

Actionscript 3 :: Listing References Of An Object?

Mar 8, 2012

Does anyone know if it's possible to list the references an object currently has in ActionScript3 (e.g. listeners, children etc)?

I'm trying to clear an object from memory ready for garbage collection but for some reason it's hanging around.

View 2 Replies

ActionScript 2.0 :: Object References In Events?

Sep 22, 2009

I am trying to create an object that is handling the events of different objects. The object is created in the 1st frame of a code layer:

ActionScript Code:
var gImageEdit:ImageEdit = new ImageEdit( imgAction, movImageFront,
 movToolbar.btnZoomInImage, movToolbar.btnZoomOutImage, gZoomSound );

[code].......

View 1 Replies

ActionScript 3.0 :: Not Use Weak References By Default?

Dec 12, 2009

The default value for weakReference in the call to addEventListener() is false. Many memory issues can be resolved by using weakReferences; in fact, some industry experts "strongly recommend always using weak references with listeners".If this is the case, can someone provide me with a good reason why weakReference defaults to true? (Note that I'm not asking why someone would ever want a listener that is not a weakReference, but rather why weakReference=false is the default)

View 2 Replies

ActionScript 3.0 :: Weak References On Loader On Mac?

Jan 12, 2010

I was having a weird problem on my Mac when creating a loader.

PHP Code:
var myUrlRequestURLRequest URLRequest(imageurl);myImageLoader Loader();myImageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageInitHandler, false, 

[code].....

View 0 Replies

ActionScript 3.0 :: Return All References To An Object?

Jun 3, 2010

I'm just getting to grips now with how the Garbage Collector works.

Is there a way (like a function or a custom class available somewhere) to check an object for all its references and return them so that you can see what it's connected to?

View 2 Replies







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