ActionScript 3.0 :: How To Reference A Sprite With A String

Feb 21, 2009

I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i cant get it to work. And the String is well spelled btw!

PHP Code:
//Nothin Worksthis["myString"].alpha = 0.5;this[myString].alpha = 0.5;//Anyway to reference a Sprite with a String??? 

[code]....

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Reference A Sprite With A String?

Apr 6, 2012

I cant get the this[] keyword to work. I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i can�t get it to work.

PHP Code:

//Nothing Worksthis["myString"].alpha = 0.5;this[myString].alpha = 0.5;//Anyway to reference a Sprite with a String?

View 3 Replies

ActionScript 3.0 :: Reference A Sprite Or MovieClip Via A String?

Feb 21, 2009

I want to send a string to a function and then, via the string reference a Sprite. Are theire any other ways to adress a sprite with a String value?I thought this[myString].alpha = 0.5; was gonna do the trick but i keep getting (1010: A term is undefined and has no properties.). I tried every possible solution it feels like. Delaring Strings locally and Global...but i can�t get it to work. And the String is well spelled btw![code]

View 3 Replies

ActionScript 3.0 :: Can't Reference An Instance Of A MC Through A Sprite

Apr 13, 2010

I thought since a Sprite is a display object container and I can add an instance of a MovieClip to it I should be able to reference the MC through the Sprite.
 
var bh1:Sprite = new Sprite();            beerChan = new BeerChan();            bh1.addChild(beerChan);            trace("bh1 "+bh1);            trace(bh1.beerChan);
 
1119: Access of possibly undefined property beerChan through a reference with static type flash.display:Sprite.

View 10 Replies

ActionScript 3.0 :: Reference Sprite Or Movieclip In Document Class

Dec 9, 2009

How do I reference MovieClips or Sprites created in the Document class from a custom class?[code]But I have a lot objects I want to reference so using the above method would take to long.I know I can do this to reference a MovieClip on the main stage from a custom class.[code]Would referencing the sprite created in the document class be similar?

View 1 Replies

Actionscript 3 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 3 Replies

ActionScript 3.0 :: Reference Sprite Or Movieclip In Document Class?

Dec 9, 2009

How do I reference MovieClips or Sprites created in the Document class from a custom classI know I can do this

ActionScript Code:
//Sprite I want to reference
var orange:Sprite  = new Sprite()

[code].....

View 1 Replies

ActionScript 3.0 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 9 Replies

ActionScript 3.0 :: Sprite X / Y - Values Reference Top Left Corner Or Center

Jun 3, 2010

I've checked this behaviour: If I define a sprite (by programming) as:
var square:Sprite = new Sprite();
square.graphics.beginFill(16750899, 1);
square.graphics.drawRect(0, 0, width, height);
square.graphics.endFill();
return square;
When I check the position of the sprite ( square.x, square.y), they reference the TOP-LEFT CORNER.

If I create a symbol by Flash CS4 and export to Actionscript (I also associate one class which extends Sprite for doing "new()" in my code):
var square: MyClassExtendsSprite = new MyClassExtendsSprite();
When I check the position of the sprite (x, y), they reference the CENTRE of the sprite!

View 3 Replies

ActionScript 3.0 :: Using String Var To Reference Instance Name?

Jul 24, 2009

I've got a set of arrays being dynamically generated with paths to nested movieclips. The paths are coming in as strings, and I can't seem to get them to work as movie clip instance variables.as example, a string would be:

siteMC.b1MC.b1f1MC.rMC
(that path works fine outside of the array)

How do I get that kind of nested path from the string to something flash wont spit out as null?

View 4 Replies

As3 :: Flash - Reference To Array By String (name Of Var)?

Feb 15, 2011

is it possible to create a new reference to an array by using it's varname ?

e.g.

private var _myArray:Array = new Array("a","m","d");
...
function getReference(_varName:String):void
{

[Code]....

View 2 Replies

ActionScript 3.0 :: Using String To Reference Variable Name In XML?

Apr 2, 2009

Is there, uh, a way to use the value of a string to reference a variable name?

I'm trying to dynamically assign XML node names and attributes using a string value, I tried something like this:

Code:
var sItem:String = "book"; // to be dynamically assigned
for (var i:uint; i < _xml.book.length(); i++) {
aList.push(_xml.(this[sItem])[i].@title);

[Code]....

View 2 Replies

ActionScript 3.0 :: Convert String To XML Reference

Jul 30, 2009

I'm trying to refer to a specific XML node dynamically. Is there any way to convert a string to reference properly? Or is there any other way?

So I want to be able to write...

Code:
trace(myXml.fruits[1].name);

...but have the "fruits[1]" stored in a variable so it can be changed easily. It might look something like...

Code:
var special:String = "fruits[1]";
trace(myXml.special.name);

...but that doesn't work.

View 1 Replies

Flash :: Turn A String Into A Reference To An Object?

Jul 6, 2010

I'm wondering, and hoping, if I can access and use a specific instance of an object if I only have the name of the object instance in a string? The code below perhaps explains it a littler better.

[Code]...

View 2 Replies

ActionScript 3.0 :: Access Instance By String Reference?

Sep 6, 2010

I have movie clip Ball what has public function glow[code]...

full access to Ball is MainMenu.ImagesPanel.Ball

I want to send command from server in text like:

string="MainMenu.ImagesPanel.Ball.glow"

How to convert sting to structure?

View 0 Replies

ActionScript 3.0 :: Reference A Variable By String Concatenation?

Feb 7, 2011

I want to reuse these two functions for about 10 items that need to be dragged and dropped. I need to reference 10 Boolean variables on the main timeline by building strings in the functions to make up the Boolean names so I can reuse the functions. Check the coded in red. [URL] Fla is above

[AS]
stop()
var startX:Number;
var startY:Number;

[Code]....

View 1 Replies

ActionScript 1/2 :: Reference Static Class Vars Via A String?

Feb 5, 2010

I am trying to set the value of some static vars but I need to reference the class with a string rather than a proper constructor. In AS3 I can do this with:

var ref:Class = getDefinitionByName(classDefinitionAsString) as Class;
ref[varNameAsString] = newValue;
 
I can't find an equivelant approach that will work in AS2 though. I have tried:

var ref:Object = new [classDefinitionAsString];
ref[varNameAsString] = newValue;

This seems to just create an Object and as the vars that I am trying to access are static I don't really want to be using 'new' I just want to reference the vars.

View 1 Replies

ActionScript 3.0 :: Telling Compiler To Reference MovieClip From String

May 3, 2010

I'm trying to keep my code succinct by naming my section labels the same as the buttons that navigate to them. I've also put the contents of each page in a movie clip of the same name with suffix _mc. The following code successfully traces the name of the movie clip, but how do I tell the compiler that I want to reference the movie clip whose name is held in the string, rather than the string itself.

function clickSection(evtObj:MouseEvent):void {
currentContent = currentLabel + "_mc";
trace(currentContent);
currentContent.alpha = 0;
gotoAndStop(evtObj.target.name);
mainNav_mc.gotoAndStop(evtObj.target.name);

View 3 Replies

ActionScript 2.0 :: Compare Array's Element (xml Reference) With String?

Jan 22, 2010

I need to compare a number with a element in a Array(curModeDisplay), I can trace the element and see it without problem. But when I try to compare the inside element with a String, it didn't work. Why?

ActionScript Code:
curModeDisplay = new Array();  \this is the Array I need
for (var tvM:XMLNode = tv.firstChild; tvM!=null; tvM=tvM.nextSibling){
curModeDisplay.push(tvM.childNodes); \received element fine here
}
trace(curModeDisplay);  \ This works fine. Array displays correctly

When I need those elements from the Array(curModeDisplay) and try to make some comparison work, it did not work:

ActionScript Code:
function DigitCompare():Void{
for(var index in curModeDisplay){
if(curModeDisplay[index]=="11265"){ //it seems didn't work here

[code]....

Is that because the element in the Array is reference to the XML node, and "11265" is String. If so, how should I fix this problem. The "11265" will be changed to any named String type variable in the future.

View 4 Replies

ActionScript 3.0 :: Flash : Reference Input Text Box String?

Dec 12, 2010

how to make a simple AS3 class.I've made a simple calculator application that allows you to add, subtract, multiply, and divide after entering 2 values into their respective text box.The problem, how ever, is once I moved it into it's own class, I cannot figure out how to reference the text fields. I have the movie clips referenced just fine, but, I cannot figure out the text fields.Here are the errors it's spitting out:

Code:
1120: Access of undefined property Number1_txt.
1120: Access of undefined property Number2_txt.
1120: Access of undefined property finalValue_txt.

And it does that for each instance of those in the Calculator.as

Main.as

Code:
package {
import flash.display.MovieClip;
public class Main extends MovieClip {

[code]....

View 5 Replies

ActionScript 2.0 :: Create A String Then Use It To Reference A Variable In An External Text File

Jan 19, 2011

So i have an external text file organized like this:

/* $file: data.txt */
&title0=Sacrum
&detail0=Detail text for Sacrum
&title1=L5

[Code].....

There are 28 of these 'title' and 'detail' pairs. The 'title' text is to fill a dynamic text box and the 'detail' to fill another dynamic text box depending on which section the user is mousing over.

My issue is getting the text from the file stored into arrays. For my test loop I keep getting undefined as the stored value, and i know it has something to do with converting a string value to object..

var lv:LoadVars = new LoadVars();
lv.onLoad = handleDataLoad;
lv.load('data.txt');
function handleDataLoad (success:Boolean) {

[Code]....

View 1 Replies

ActionScript 3.0 :: Error 1119: Access Of Undefined Property Text Through A Reference With Static Type String

Nov 30, 2010

I have the following code:

var myPercStr = myStr.text;
myPercStr= myPercStr.toString();
var myPerc = Number(myPercStr);

I am trying to get the value of a text field which is created by the user pushing a pin-pad.  This text field is a string which is joined() from an Array of the sequence of pin-pad entries.  Now my problem is that Flash will not convert the .text text field into a string with which I can use the value to convert to a Number and perform math on it.

View 1 Replies

Professional :: CS4 Support For Softkeyboard - Error: 1119: "Access Of Possibly Undefined Property NeedsSoftKeyboard Through A Reference With Static Type Flash.display:Sprite"

Sep 7, 2011

I need to use softkeyboard for a flash program developed for windows desktop, and I tried the example given on the following page: [URL] When I test the movie, it gives me a compiler error: 1119: Access of possibly undefined property needsSoftKeyboard through a reference with static type flash.display:Sprite. I noticed that this feature is available to flash players 10.2 or higher, so I updated my CS4, but it still didn't work. Does anybody know what is causing the problem?

View 3 Replies

Actionscript 3 :: Class Extending Sprite - Set The Sprite's Width And Height Properties?

Mar 5, 2010

I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite's width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.

What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it's been instantiated, so I don't get it.

package {
import flash.display.*;
public class ScrollBar extends Sprite {[code].....

View 1 Replies

Flash: `sprite.visible = False` Doesn't Hide Sprite Immediately?

Apr 4, 2011

I've got a sprite which I want to temporarily hide... But changing the .visible property doesn't do what I expect. The code looks roughly like this:

[Code]...

View 1 Replies

IDE :: Adding A Single Sprite On Main Moviclip Sprite Remains Invisible

Mar 2, 2009

I created a new AS3 document (550px by 400px) and added the following code to the first frame.

However, when I run this, I see nothing painted on the screen at all, the screen remains completely white.[code]...

View 3 Replies

Flash :: Rotating Sprite Moves The Sprite From It's Original Location

Jul 6, 2011

I'm doing a simple rotation on a sprite but there's a weird behavior where the sprite does not rotate around it's top left. I think I'm rotating along the top left of the test class instead of the sprite child. I would like to rotate the rectangle around it's top left corner (kinda like a clock hand). The code is pretty short so I'll let the code + pictures explain my problem:

package
{
import flash.display.Sprite;

[Code]....

I've read a lot of stuff about rotating around a fixed point, I've tried doing it with movieclips instead of sprites, I even copy pasted a tutorial on rotation and nothing works.

View 3 Replies

ActionScript 3.0 :: Sprite.addChild(NumericStepper) Resizes Sprite To 100x100

May 27, 2008

[Code]...

Then the numericStepper is drawn as if it is squished to 20% its normal height. If I pre-set mySprite width and height before adding the numericstepper, the trace output is 0,0 after adding it and it is not displayed at all. Is there some way I can make the sprite only adjust to correctly fit the numericStepper OR resize it afterwards without distorting the numericStepper component?

View 2 Replies

Actionscript 3 :: Difference Between Sprite.width VS Sprite.scaleX?

Sep 23, 2011

Both of sprite.width and sprite.scaleX can be used for scale a sprite. Is possible sprite.scaleX depends on screen size?

View 2 Replies

ActionScript 3.0 :: Sprite.graphics And Setting Sprite.width?

Jun 19, 2009

It has been a great resource of the years. No my problem. I am trying to dynamically resize a sprite that has a line drawn into it. Here is my code:

[Code]...

View 4 Replies







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