ActionScript 2.0 :: Using Variable Value As Object Name?
Jul 2, 2006
[AS]
stuff = setInterval("fun",20);
myVar = "stuff";
clearInterval(myVar);
[/AS]
Obviously, the above clearInterval won't work, because the clearInterval looks for "myVar" instead of "stuff". I want it to be the other way around.
I tried using the following, but with no luck.
[AS]clearInterval(this[myVar]);
clearInterval(_root[myVar]);[/AS]
View 2 Replies
Similar Posts:
Sep 1, 2009
Is it possibile to call a field of a object using a variable? Something like:
[Code]....
View 5 Replies
Oct 28, 2003
How can I create an xml object (or any object in fact) named after a variable, i.e variable called section with value "names" create object [section value + "XML"] = new xml(); result: empty xml object called namesXML
View 3 Replies
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
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
Feb 15, 2010
i'm building a band website in joomla. Each band has it's own page. I want one mp3 player to cover al bandpages by just editing the url of the playlist.xml (the variable)
I want to connect the pageid (itemid as it is called in joomla) to the xml.
So artist nr 22 has page 22 and playlist 22.xml
with the following code i got the page id:
PHP Code:
<?php
$band = JRequest::GetVar('Itemid','');
echo $band;
?>
[Code]....
Behind autostart=false i can set "playlist=(itemid).xml
how can i get the value from itemid into the flash object?
I've tried going the other way around by saying the actionscript i wanted it to load a variable, but i didn't succeed..
View 0 Replies
Jun 9, 2010
Code:
theMap = new XML(mapXML.returnXML());
tSheet = new this[theMap.sheet](0, 0);
[code].....
View 2 Replies
Oct 28, 2003
How can I create an xml object (or any object in fact) named after a variable,
i.e
variable called section with value "names"
create object [section value + "XML"] = new xml();
result: empty xml object called namesXML
View 3 Replies
Jul 11, 2011
I am trying to figure out how I would get the value of a variable into an XML Object.
I have the variable
var dragonName:String = "Samuel";
var listing:XML = new XML();
listing = <thedragon>
[Code],,,,
However, the dragon name does not show up when I go trace(listing); How do I do it and should I have imported something as well or what?
View 7 Replies
Dec 3, 2011
I have some variables in the format: var like6Y:Number = 50; Later I am dynamically setting some: num=6; Then I am trying to use that num to get the variable like6Y: like+6+Y I know that is totally wrong but I seem to remember you could use some kind of object notation to accomplish this: ["like"+num+"Y"] Or something along those lines. But I can't remember how to do it.
View 3 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
Feb 11, 2012
So, if I need to give a custom variable name to an object how would I do that?
For instance, if I have a gameID that is 12345 and its rating is 3 I want to save a variable called gameRatings_12345 thats value is 3 in my shared local object.
//share object
protected var mySavedData:SharedObject = SharedObject.getLocal("mySavedData");
I have the game id in a string
var gameID:String = "12345";
Then when I try to assign the value like this...
mySavedData.data.gameRatings_gameID = 3
I think it's literally reading it as "mySavedData.data.gameRatings_gameID" instead of "mySavedData.data.gameRatings_12345"
How can I give the variable a custom name?
View 2 Replies
Jun 30, 2009
How do I relate a variable to an object on the stage? I want to have a mouse over and a mouse out effect on a button yet when I use the code below I get the error:
ReferenceError: Error #1065: Variable button is not defined.
obviously the object on the stage is called 'button' but I didnt think I had to define objects as variables? I thought the below code was correct?[code]....
View 1 Replies
Jan 19, 2010
I cannot get the name from a object that was click to a variable.
The code is the following:
var newQuadrado: Quadrado;
var Name:String;
stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
[Code]....
View 4 Replies
Jan 11, 2012
So ive made a custom message system for my game and the scrollpane component requires me to have the info inside one movieclip. I have a couple of textfields there that i want to change to some variables on demand. The vars are in an external as file and im able to reference them well on the main timeline. The problem is when im inside the scrollable object, all the vars return blank instead. This is the code which is placed inside the object:
Code:
import Variables;
var variables:Variables = new Variables();
function setMsgSlot (e:Event) {
[Code]....
View 0 Replies
Mar 28, 2012
I'm wanting to set an Object property using a variable value. I just can't get it to work as it assumes the variable name is the name of the property: I've simplified the issue rather than posting my whole code.[code]It always applies 'attrName' as the property name rather than the value of 'attrName'.Tried loads of things but just can't get it to work.
View 1 Replies
Jun 14, 2007
I am in no way very knowledgable with ActionScript, so this might be very simple and I am looking in all of the wrong places... but basically here is my issue: Instead of accessing an objects attributes like this, _level0.thumbnails.thumbnail0._width = 500; I want to be able to access it with _level0.thumbnails. (this.id) ._width = 500; where as (this.id) is a variable that could be equal to "thumbnail0" or "thumbnail99" depending on which object gets clicked. I have everything working to if I hardcode thumbnail0 it works fine, and this.id does get set to whatever thumbnail I click's "thumbnail" + ID
View 2 Replies
Feb 15, 2009
I'm trying to format a variable into the middle of an object so that I can pass the entire thing as a parameter to a javascript function via ExternalInterface, but I cannot figure out how to format the data correctly.
I need it to end up looking like this:
Code:
{gallery:'myvar'}
braces and apostrophes included. myvar would be my variable data, which is a string. I tried connecting it all together as a big string, but the javascript function didnt like that. It did accept it if I typed the entire thing staticly as an object variable and passed that. Is there any way I can format it all into a string and then convert the string data to an object? or is there another way to try and accomplish something like this?
View 4 Replies
May 18, 2009
Out of some curiosity and the use of possible standard key variables so I don't have to create several instances to the same class, I was trying the following:
[Code]...
My question is: Is there a better approach to this on AS3? Something tells me I'm just heading the wrong way there...
View 4 Replies
Dec 10, 2009
i only know AS2, and was not doing actionscript for a while. i can't pass the variable to the object, please check what's wrong with my script. i want to put a variable after the obj. so when it randomize, it pass the random number after the obj.
obj1._visible = false;
obj2._visible = false;
function reveal() {
[Code]....
View 5 Replies
Mar 11, 2010
If I wanted to change the 'x' of a object, and a variable contained a the object's name, how would I change the 'x' by using the variable.Without variable:
Code:
myObject.x = 123;
With variable maybe?:[code]....
View 6 Replies
Apr 1, 2011
I've got an external class and make like 20 objects with it. If I e.g. hover my mouse above them, the objects themselves know that, the parent clip however does not. Now I want a global boolean to be set to true, if one of those objects is focused. So in other words I want to set a parent variable from inside of an object that I created with a class.
I could make myself an enter-frame-loop and check all of the objects all of the time, but that doesn't sound like a good solution.
I could also add 20 change-listeners to the parent clip, but I'm not sure about the performance of that. And I have listeners inside the objects anyway, so those should be somehow able to take care of that, or isn't that possible?
View 1 Replies
Mar 2, 2004
I desperately hoping someone can shed light on my problem. I am trying to reference a movieclip with a variable. I've done it before but in loops reading from xmlobjects but cannot get it to work in the most simplist way....??ar i = 0;_root.movie[i]._visible=0;
View 2 Replies
Oct 20, 2009
I just started in as3 after a long break from flash and I have run into a slight problem and couldn't find any readily available solutions online so I thought I'd ask, I'm trying to do something like this:
Code:
switch(characters[ps[1]])
{
case 0:
[code]....
I want to create a different object of the same variable name with the switch statment but it gives me "1151: A conflict exists with definition player in namespace internal" which is of course because I'm redeclaring the variable. I'm not 100% sure it technically exists in the current scope though (but it must because I am getting this error.) I also tried a few ways of initializing as just MovieClip up topside and then just try and typecast it down here but as can be assumed that didn't work either.
Is there a way to get my intended effect or am I gonna have to make some like an above class containing all these other classes on it's various frames and just instantiate those?
View 3 Replies
Dec 20, 2011
I am developing an application in AS3 for Android devices and I am choosing to use XML for setting storage...
Unfortunately I have been able to test using the contains method whether there is the correct text in the XML file I have tried to use this...
Code:
var updates:Boolean = true;
var k:Number = 0
for(k = 0; k < 6; k++){
if(localXML.Party[k]){
[Code].....
View 1 Replies
Jul 28, 2011
array which I'm looping through to get variables(as text) to display in dynamic text fields..If possible I would like to sort the array into numeric order using "sTabArray[i].sHour". A variable of each of the array items..Is there a way I can do this ?aybe create a new array from the original one and then use that ?
for(i = 0; i < sTabArray.length; i++) {
var sMin:String = sTabArray[i].sMin;
var fMin:String = sTabArray[i].fMin;
[code]........
View 2 Replies
Dec 11, 2009
I want to do something like this in Actionscript 3:
if(variable is Object) ...;
else ...;
Where variable could be a String(), Number(), Array(), Object()...Currently the above check returns true for all of these types, which makes sense. I only want it to return true for objects made with new Object(), however.
View 2 Replies
Nov 7, 2010
how to create an object if the name is stored in a variable.
var className:String = 'Config';
var MySprite:Sprite = new ???
class Config extends Sprite {
...
}
View 1 Replies
Aug 8, 2011
URL...An untyped variable is not the same as a variable of type Object. The key difference is that untyped variables can hold the special value undefined , while a variable of type Object cannot hold that value.[code]Why is assignment to undefined allowed for obj? (not a big issue since it still prints as null)If we compare null with undefined the result true (even if null stored in an Object). What is the point of making a difference between null and undefined if they are equal?
View 2 Replies
Dec 14, 2009
why I am getting undefined every time I trace the following:
Code:
c = currentCount; //current is 1.
trace (eval("mcSlide" + c)._x);
trace (this["mcSlide" + c]._x);
I would think these would output, if I incrementally go through 3 slides, the correct _x for each slide e.g. mcSlide1._x , mcSlide2._x
View 1 Replies