Actionscript 3 :: Flex - Use Variables For Object Attribute Names?

Mar 19, 2010

How do you use variables to access Object attributes? Suppose I have an Object declared as follows,

var obj:Object = new Object;
obj.Name = "MyName";
obj.Age = "10";

[code].....

View 1 Replies


Similar Posts:


Flex :: Get Hyphens In Attribute Names?

Mar 23, 2010

Flex has an issue with hyphens in xml. I need to generate an xml object with hyphens in the attribute for a Google Checkout implementation.

I can get away with:

var xml:XML = <item-description/>;

and

var xml:XML = <item-description the-name="foo"/>;

but what I need to do is set the value of an attribute like this:

var timestamp:String = methodToGetMyTimestampString();
var xml:XML = <item-desc/>;
xml@start-date = timestamp;

but I can't do that. Since flex doesn't like the hyphens, I don't know how to get or set attributes with hyphens in the name.

View 1 Replies

Flex :: Getting A XML Attribute Using Variables?

Oct 21, 2011

I wish to extract an attribute from an XMLList and assign it to a string. Here is the snippet of the XML

<node>
<sport GAME="Squash" TIME1="2" TIME2="3" TIME3="8"/>
<sport GAME="Table Tennis" TIME1="4" TIME2="6" TIME3="7"/>
</node>

I have two variables. One variable will contain the game type, either Squash or Table Tennis. The other will contain one of the following strings "TIME1", "TIME2" or "TIME3". The variables are called game and time. I have tried many variations on the code below to get the needed attribute but with no joy.

var result:String = node.sport.(@GAME == game).(attribute(time));

View 2 Replies

ActionScript 3.0 :: Getting Xml Attribute NAMES

Jun 19, 2009

i have some xml that is full of attributes. Without much detail, i would like to translate the xml into objects. However , i need a method that can get the attribute values AND names. Getting the value is a no brainer, but the names are not coming so easy. For example, the following will translate and xml node into an object with a prop and value of the same:[code]in trying this with attributes, i need to first find a way to get the attribute name.

View 6 Replies

Flex :: Interface - Getting Value Of The Object Attribute

Dec 1, 2009

i have an xml which contains 'interface' sub tag, iam converting xml to object using SampleXmlDecoder. compiler did not allow me to access the value of the 'inteface' attrible of the resultobject.

[Code]....

its treating interface as keyword. the solution for this.

View 1 Replies

Flex :: Make Objects With Key Names From Variables?

Dec 26, 2009

I would like to make an Object that has key names taken from a variable. Probably this is not clear enough, so let me make an example.

I have two variables var str1:String = 'firstKey'; and str2:String = 'secondKey';

How can I make an object that would look like:

var obj:Object = {firstKey: 'some value', secondKey: 'some other value'}, note that firstKey and secondKey are values of variables str1 and str2.

Doing obj = {str1: 'some value', str2: 'some other value'} does not yield a result that I would like

View 3 Replies

AS3 :: Flex - Object List Search With Attribute Value Only?

Oct 16, 2010

Suppose I have a list of objects of a certain custom type and I need to find an object given only the value of one of its attributes, how do I do it?

Eg.

// Where user1 ... usern are objects of some class User
users = [ user1, user2, user3 ... usern ]
// How do I find out the objects that have the "foo" attribute set to "bar"

View 1 Replies

Search Flex XML Object To Find Attribute When Given Element Name?

Oct 13, 2010

I have a Flex XML object as follows:

private var _xmlCountries:XML =
<Countries>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AO">Angola</option>

[Code]...

This object is ok, and shows up correctly in debug mode. The problem is I have a country name i.e. private var _country:String = "Angola";, and I want to get the corresponding value 'AO' from the XML object. Do you know how to do this?

I have tried loads of Livedocs examples, but cant get it to work. P.S. I am working on a HtpService & WebService driven app to display global weather conditions overlayed on a Google Maps interface. Going to make it available to the Flex community when finished.

View 2 Replies

Actionscript 3 :: Flex - Object Attribute / Variable Null

Jan 6, 2011

If I execute the code below in FlashBuilder, I get the following error (I translate it) TypeError: Error #1009: Access to an Attribute or Method of an null-Object is not possible. at components::NumDisplay()[srccomponentsNumDisplay.mxml:39] This line in NumDisplay.mxml is the problem:

[Code]....

View 3 Replies

Flex :: Get All Attributes Names Of An Object

Jan 17, 2012

Let's say I have a class which looks like this :

public class MyClass
{
public var attribute1;
public var attribute2;
}

and I'd like to get attribute1 and attribute2 as strings. I tried this :

var test:MyClass = new MyClass();
for (var key:String in test)
{
trace(test[key]);
}

but it does not work, it never goes in the loop. How can I do what I want to do ?

View 2 Replies

Flex :: Looping Through Object Property Names In Actionscript?

Apr 22, 2010

I have a dynamic class that I have created

public dynamic class SiteZoneFileUploadVO
{
public var destination:String = "sitezone";[code]...........

when I try to iterate over this object's property names it only iterates the dynamically added properties.

parameters.dynVar= "value";
for(var name:String in parameters)
{

Even though the object has all the properties equal to a value (ive checked this in the debugger) the only property name that will be traced is dynVar.How can I iterate over all the property names and not just the dynamically added ones?

View 3 Replies

Flash :: Variable Object Property Names Flex?

Dec 3, 2010

I need to create variable object property names for use with the data grid component.

This works: data = new Object(); data.some_name = "the data";

But this does not: data = new Object(); colName = "some_name"; data[colName] = "the data";

View 3 Replies

ActionScript 3.0 :: Getting Variables By Their Names?

May 20, 2010

The thing is, I create a grid on the screen, and each of its element is given a name. The question is, how can I access those specific grid's fields by their names? Here's the code:

ActionScript Code:
private function drawGrid():void
{
var startX:uint = 0;

[Code]....

Now, If I wanted to remove, for instance, the box of the 13th row and the 25th column, how can I do that?

View 7 Replies

Javascript :: Get The Names Of Variables From A Web-page?

Aug 15, 2011

Is there a way to get the names of variables from a flash game? I have been playing with my players health with the code;

javascript:document.embeds[0].SetVariable("_root.player.intHP", 0)

I am looking for a way to find out the rest of the variables, like damage and such.

View 1 Replies

ActionScript 3.0 :: Variables Inside Names Again?

Dec 9, 2010

If I have a MovieClip called parent_mc and inside it I have another called child1_mc, I can use a variable for the "1" part of child1_mc and change the alpha for example like this:

ActionScript Code:
var myVar:Number = 1;
parent_mc['child'+myVar+'_mc'].alpha = 0.5;

What is the right syntax to use if child1_mc is not actually a child of anything and just sits on the stage? I have tried the following and it didn't work:

ActionScript Code:
['child'+myVar+'_mc'].alpha = 0.5;

and I tried:

ActionScript Code:
stage['child'+myVar+'_mc'].alpha = 0.5;

That didn't work either.

View 9 Replies

ActionScript 2.0 :: Putting Variables Instead Of Names

Jul 26, 2004

if i have mc duplicated or an object instance name thats stored inside a variable how can i call it? for ex: _root.mov1._x = 53; What if i want instead of mov1 a variable name. lets say randomname is a var and it holds the name of a duplicated object with a name i dont know since its random. now how can i call it just like the example above cause i tried
_root.varname._x=33; but it thought varname was an instance name instead of var.

View 5 Replies

ActionScript 2.0 :: Get Instance Names For Variables

Jul 13, 2007

There's a way to get the instance name of objects/symbols for variables and use this in actions and/or functions?

View 4 Replies

ActionScript 2.0 :: Using Variables As Instance Names

Nov 11, 2010

So, I have something like..

Code:
select = ("block" + number);
trace(select._currentframe);
number++;

This is because I have 5 movieclips named block1, block2, etc. However, it returns undefined. When I directly state the instance name, like:

Code:
trace(block1._currentframe);

It works. How do I use variables as instance names?

View 2 Replies

ActionScript 2.0 :: Putting Variables Instead Of Names?

Jul 26, 2004

if i have mc duplicated or an object instance name thats stored inside a variable how can i call it?for ex:

_root.mov1._x = 53;

What if i want instead of mov1 a variable name. lets say randomname is a var and it holds the name of a duplicated object with a name i dont know since its random.

now how can i call it just like the example above cause i tried

_root.varname._x=33;

but it thought varname was an instance name instead of var.

View 5 Replies

ActionScript 2.0 :: Replace MC Instane Names From Variables?

Aug 7, 2009

I am using AS 2.0 and Flash Player 9.I want to change MC Instance names and target paths, by using variables.As an example, this is the traditional working code.

enter_btn.onPress = function () {
clip1_mc.gotoAndPlay("label1");
};

[code].....

View 2 Replies

ActionScript 3.0 :: Variables' Names Inside A Loop?

Jul 19, 2009

i want to query about a point here,

Now, When i make a loop for example a "for" loop

ActionScript Code:
var i:int;
for (i=0;i<4;i++){
// Looping Code For 4 Times
}

in the looping code, when i use a variable, for example "myVar"

Can i make the variable name be "myVar0" in the first time looping, and the name be "myVar1" in the second time looping, and so on ..

View 6 Replies

ActionScript 3.0 :: Making New Variables With New Names In A For Loop?

Jan 24, 2010

I can't create new variables within a for loop:

ActionScript Code:
for(var i:int = 0; i<numBtn; i++) {
var this['menuBtn'+i] = new Sprite();
}

This doesn't work, saying I need an identifier before 'this'.

What I am trying to do is to make a dynamic menu, and the number of buttons depend on how many files there are in a directory, as each button links to each file;I get this value (numBtn in my example) from a php script, and I need to make a menu depending on it, but I can't seem to make it so that when I add a new file into that directory, a new button comes up on the menu and I don't have to change my flash file.

View 9 Replies

Actionscript 2.0 :: For Loop That Dynamically Names Variables?

Dec 19, 2008

Still learning how to use for loops, I want to set a huge range of Boolean Variable to false. like:

var met0:Boolean = false;
var met1:Boolean = false;
var met2:Boolean = false;
etc... etc...

how can I dynamically name variables inside a for loop and set its data type? I know how to with movieclips but can't get it to work with variables

View 4 Replies

ActionScript 2.0 :: Make Variables As Instance Names?

Jun 20, 2006

I have created movie clips using loops that names them box1, box2, box3.... via = i + 1;duplicateMovieClip (_root.box, "box" + i, i);but i then want to edit a textbox which is rooted inside each movie but related to the movieclip just produced. so if box1 had just been produced then:box1.textbox.text = " E cell = +j+"V";is done so effectively i am looking to do: box+i.textbox.text = " E cell = "+j+"V";

View 2 Replies

ActionScript 2.0 :: How The Level Names Could Replace With Variables

Oct 7, 2006

I've a problem with accessing different levels..

actually i'm in the 6th level of my swf and i need to access a movieClip in the 2nd level .

Is it possible to use variable names instead of giving the real level name and movieClip...

My code is something like this...

var levelData:String = _level2.mc_myMovie;
levelData.onRelease = function()
{

[Code]....

View 2 Replies

ActionScript 2.0 :: Tweens And Variables In Instance Names?

Oct 18, 2007

I am using the tween class to change the alpha value of a MC upon rollOver and rollOut. To refine the effect, I assigned a variable to the MC's alpha value so if the mouse moves off the MC before it has reached 100% alpha, it wont start immediatly fading from 100%, but from the value it had reached before the user stopped the rollOver action. Unfortunately, when I leave my mouse over the MC until it goes to 100%, and then I wait a second or two, the alpha snaps back to 50% (the starting alpha value).I can't figure out why this keeps happening, but I have run into it with other projects and I surmise it is the way I am using the tween class. Below is the code I used to make this happen.To see the problem, here is a link to the compiled file:

// image 1 Set 2
groupA.group2.image1.onRelease = function() {
loadMovie("main_resized/1.jpg", pictureHolder);

[code]......

View 1 Replies

ActionScript 2.0 :: Concatenate Variables Onto Movieclip Names?

Jun 29, 2008

var c = mainSubThumbs.SubThumbsHolder[materialType].subthumb_mc[id] what i have obviously doesnt work. materialType and id are my variables that I want to be added onto these mc instances..

View 9 Replies

ActionScript 3.0 :: What Are Rules For Legal Variables Names

Feb 4, 2010

What are rules for legal variables names?ie: A-Za-z0-9, hyphen, underscore, etc. must start with an alpha at least n characters, no longer than n characters, etc.

View 3 Replies

ActionScript 2.0 :: Using Variables As Instance Names Not Working?

Nov 21, 2010

So, I have:

function respawn(enemyid){
clearInterval(respawnTimer);
enemyname = "enemy" + enemyid;

[code]......

View 5 Replies

Flex :: Object Doesn't Look Up Scope Tree For Variables?

Aug 4, 2009

I have a simple object defined by an object literal, and have a couple functions assigned to this object. Inside the functions, I try to access global variables, and it only gets undefined. The Flex debugger tells me the variables are just right up the scope tree.Yes, I know I can access Thing by using 'this', that doesn't solve my scope issue though.Project Flex Compiler Settings: Flex SDK 3.4, Require Flash Player 10.x.Example:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="Thing.bling();">
<mx:Script>
<![CDATA[

[code].....

View 2 Replies







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