Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Variable Name As Object Name


Hi. I'd like to be able to create some variables dynamically in AS3 and then use them as object names. For example, to create the variables circle1, circle2 etc I write:

for(var i:Number = 0; i < 10; i++)
{
this["circle" + i];
}

I would then like to create movie clips with the names of these variables so that I can add them to the stage and access their properties individually. Is this possible?




Adobe > ActionScript 1 and 2
Posted on: 08/30/2007 07:44:56 PM


View Complete Forum Thread with Replies

Sponsored Links:

_root.variable -> Object Variable
Hi,
I am rather new to flash, so please bear with me

I've downloaded a flashmovie at http://www.flashkit.com/movies/Inter...8449/index.php ( a very beautiful window navigation menu).

The menuitems to build this window-menu are placed within the object as variables.

I want to put these variables into the root timeline (where I can retreive menuitems from a database). The object however cannot retreive variables from the root-timeline it appears.

I've tried using _global.varname in the root timeline, but it didn't help.


Is there a way I can make these variables appear within the object?

help appreciated
Patrick

View Replies !    View Related
Name Object From Variable
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 Replies !    View Related
Get Variable Out Of An Object
Hi evryone,

I have a code that generates an object. In that object, there is another object, en in that object, there is a var. So it is:
game.currentmap.vgoals . Now I want that a dynamic txt field shows the value of that variable. But fe: if I use:

Code:
function updateStats() {
_root.tempVgoals= game.currentmap.vgoals;
_root.totalgoals = game.currentmap.goals;
}
it wont work.

So the dynamic txt field's var names are tempVgoals and totalgoals. The function is executed in an onEnterFrame. If I trace "_root.tempVgoals", it gives out the wright value, but it still wont appear on my screen.

Please help me

With kind regards, Dauntless

View Replies !    View Related
How To Name An Object With A Variable?
If I have the following

myObject = "ball";

How do I make an object called "ball"?

The following does NOT work, instead it makes an object called 'myObject':

var myObject:Object = new Object();

I've heard I can make 'variable variables' with eval(), but the following throws an error:

var eval(myObject):Object = new Object();

PLEASE HELP. This is driving me crazy.

View Replies !    View Related
Using A Variable To Specify An Object
I am going through the tutorials in the "learning actionscript 3.0" book by Rich Shupe.

I got to a tutorial in chapter 3 that deals with adding event listeners. It is based on a project file that contains a movieclip called "box" and a number of buttons to perform different transforms on the box (move up, move down, scale up, etc.). They are named "move_up_btn", "move_left_btn", and so on.

Now I got through the exercise fine, but I like to try and expand on these examples to test my comprehension. The original code for each button goes like this:

move_up_btn.addEventListener(MouseEvent.MOUSE_UP, onMoveUp);

for the listener, and then

function onMoveUp(evt:MouseEvent):void {
box.y -= moveStep;
}

for the associated function.

I was thinking I could make this more dynamic by having the listener pass the name of the target object from the listener to the function instead of having it hard coded into the function. This way I could have several listeners for different objects use the same function. I tried to modify the code to accomplish this, like so:

move_up_btn.addEventListener(MouseEvent.MOUSE_UP, onMoveUp("box"));

and for the function:

function onMoveUp(transTarget:String):void {
transTarget.y -= moveStep;
}

This doesn't seem to work. Flash looks for the "y" attribute of the transTarget object, which of course it doesn't find since transTarget is a string variable. What I want it to do is see transTarget as a variable and use it's contents as the target object to modify the "y" attribute of. Can anyone tell me how I would do this?

Also, on another note, in the original function, I didn't quite get why it has "evt:MouseEvent" as the input for the function, is the listener passing the mouse event to the function instead of just calling it? What is the purpose of this?

Thanks in advance for any help.

View Replies !    View Related
Variable Object Name
Is there anyway to have a variable object name? Such as
Code:
["event"+i] = new Object();

View Replies !    View Related
Using Variable Value As Object Name... Help
This shouldn't be too hard for someone with a little more experience...


ActionScript Code:
stuff = setInterval("fun",20);myVar = "stuff";clearInterval(myVar);


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.

ActionScript Code:
clearInterval(this[myVar]);clearInterval(_root[myVar]);

View Replies !    View Related
How To Get A Variable From The Object Tag
I need to get a variable from a param in the object into flash and apply it to the onclick event for a button. Can anyone help me out with that? Snippet below


Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="240" id="source" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="flashVars" value="urlToGoTo=http://myurl.com" />
<param name="movie" value="http://myurl.com/Controls.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="http://myurl.com/Controls.swf" flashVars="urlToGoTo=http://myurl.com/" quality="high" bgcolor="#ffffff" width="320" height="240" name="source" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>
</object>
This is the variable I have to capture and apply to a button.
urlToGoTo

As always thank for any help.

View Replies !    View Related
How To Use Variable In Color Object?
I would like to use a variable in the color object but dont know how to. What I am using is:
myColor = new Color(bg);
myColor.setRGB(bgcol1);
Here the RGB value is stored in the variable bgcol1 which is '0xffffff'. But its not working. I am getting the variable bgcol1 from a database. Is there a way to use the variable in the color object?? I have a book in which I want the pages in different colors and so I have taken a variable bgcol in the database and bgcol1 corresponds to page 1's color and so on. I am being able to get the correct values in the variables but somehow in the color object it doesnt work. Kindly help.

View Replies !    View Related
Naming An Object With A Variable
I have a square that is broken into four equal parts. The function that I have makes it so that they scale relative to each other in that when quadrant a gets bigger the quadrants below (c,d) decrease in height and the quadrants to the right(b,c) decrease in width. I have this working really well but I want to have multiples of this same efect throughout the page. I just want to set the name as "a"plus the variable "i" so I can just set the function up

a(i)._xscale= x;
a(i)._yscale= y;
b(i)._xscale=200*(1-(x/200));
b(i)._yscale=y;
etc...
But I don't know how to name a mc with a variable.
I hope this is clear. Anyway thanks for the help in advance.

View Replies !    View Related
Add A Variable To A Movieclip Object?
If I load a moviclip/button to a movie, can I add a variable to the movieclip/button object?
I'm populating a movie with a bunch of clips that are just duplicates of a movieclip which act as a hyperlink. I can store the text of the hyperlink in the object.label variable, but I have a record id that has to be stored in some other variable for THAT specific movieclip/button. How can I do that?

View Replies !    View Related
Replace Object With Variable
Hi,

My .fla contains the following script:

Code:
comboBx3.setSelectedIndex(9);
var varBx;
var numberBx;
numberBx = "4";
varBx = "comboBx"+numberBx;
varBx.setSelectedIndex(9);
stop();

"comboBx3.setSelectedIndex(9);" works fine but "varBx.setSelectedIndex(9);" doesn't seem to work.
Variable varBx contains the objects name "comboBx4".
When I replace varBx with comboBx4 it works but that isn't what I want of course.

Can anybody PLZ help my out?!?!

THX

View Replies !    View Related
How To Add A Variable To A Sound Object
Hi,

How can I store a variable inside a sound object. Forexample is this possible ?

var sndSound = new Sound();
sndSound.strVar = "SoundName";
trace(sndSound.strVar);

IS there a way to retrieve the name of the attached sound inside the sound object.

Thank you.

View Replies !    View Related
Object Instance > Variable Name
Hi all,

Ok, I have be faced with this problem so many times. Sometimes my workarounds work, sometimes not. But here we go:

I want to be able to store an objects instance name in a variable, and then reference that object elsewhere with the variable.

So,

onClipEvent (load) {
instName = "textFieldInstanceName";
}

then within that movie clip:

_parent.instName.scroll += 1;

I've tried this, but no dice:

_parent.eval(instName).scroll += 1;

I bet someone is looking at that syntax and laughing it up.

Anyways, I'm hoping someone can see what I'm trying to get at here and can tell me the proper way to handle this kind of situation as it always seems to come up for me.

-Blake

View Replies !    View Related
How Do I Get The Object Reference Of A Variable?
I have a few long named variables with long paths.

Can someone tell me how I can create a new short name variable and assign it to the reference of the long named variable?

Erm... perhaps I'm not being clear.

I have the following variable say:

myMovie.anotherMovie.holdingMovie.myVariable

I want to create another variable called:

shortVar

When I change the second, I want this to change the value of the first as well because in memory they point to the same variable stored in memory.

Hmmm does that make any sense?

Any help would be appreciated.

Thanks.


OM

View Replies !    View Related
Replacing Object With Variable
I load a .txt file into a variable called picData1... that works fine this way:

I define the variable picData1...
m_alquileres.picData1 = new LoadVars();

the, inside a function i have this code to load new data on picData1...

p=m_alquileres.picData1;
p.load("picdata"+(_global.n)+".txt");

this piece of code works perfect.. but now comes the problem:

I want to make something like the next example, but didn´t found the way to make it work: (´targetmovie´ is the name of the movie i pass to the function, like "m_alquileres", or "m_ventas"....)

..function (targetmovie)..
p=targetmovie+".picData1";
p.load("picdata"+(_global.n)+".txt");


All I want is to target picData1 at diferent movies. This way i can call the function which populates data telling which movie must be populated each time.

How can I do it?
Should it work? must I use a special way to define ´p´ ??

View Replies !    View Related
(MX 2004) Specify Object With Variable...
Hi.

I'm hoping this is just a simple operand that I just am not aware of.

I am trying to use a rollover to both define a variable:

city = ("Atlanta");

and then use that variable to command a MovieClip whose instance name ("Atlanta") is the value of that variable:

//something like

city.play();

Could you help me?

Thanks!

View Replies !    View Related
[MX04] Specifying An Object By Using A Variable
Hi.

I'm hoping this is just a simple operand that I just am not aware of.

I am trying to use a rollover to both define a variable:

city = ("Atlanta");

and then use that variable to command a MovieClip whose instance name ("Atlanta") is the value of that variable:

//something like

city.play();

Could you help me?

Thanks!

View Replies !    View Related
[F8] Use Variable To Refer To Object
I have a variable called current_slide and new_slide which I am using to determine which slide to display. When current_slide changes, I would like to turn visibility off on current_slide, and turn it on for new_slide. I am having trouble getting this to work.

e.g.
current_slide = "welcome";
new_slide = "location";

new_slide._visible = true;
current_slide._visible = false;

Flash is not realising that I would like to use the value of the variable to determine the object I am referring to. If I use location._visible it works fine.

How do I use a variable to refer to an object?

View Replies !    View Related
How To Refer To An Object Through A Different Name/variable?
Let's say I have a:


Code:
var drawing_layer1:Shape=new Shape();
How do I then say something like:


Code:
selectedLayer = drawing_layer1;
So that in my code, when referring to drawing_layer1 I can enter selectedLayer ?

I know this is an easy task for you guys but I am noob lol

View Replies !    View Related
Using A Variable To Specify An Object Property
Hey all,

Suppose I have

columnName : String = 'name';

and then I have a dataGrid that I want to add an item to via:

dG.addItem({columnName:'joe'});

This creates a column called "columnName". Is there a way to use the value of the string "columnName" instead as the column title?

Thanks in advance!
fitz

View Replies !    View Related
Duplicating An Object Using A Variable
I'm quite new to AS3, and I've run into a problem that I can't solve.

I need the facility to duplicate an object from a variable. The reason for this is that I will be creating a large number of different objects that need to be duplicated, and do not want a separate duplicate function for each one.

This is what I have right now. The ObjectType:String is delivered by a button, and is then duplicated. However, this does not work. Is it possible to do this? or is there another method?


ActionScript Code:
function duplicateObject(objectType:String):void {
//uses the objectType string to determine what object to duplicate
    var newObject = new objectType();
    this.addChild(newObject);
}

Thanks in advance!

View Replies !    View Related
Load Variable Object Help
I am having trouble loading my variables into my mc BioInfo, this is my code so far:

Code:
MyLoadVars = new loadVars();
MyLoadVars.load("D:MultimediaProjectsRiversideCdTypes12667Bio.txt");

Error opening URL "D:ultimediaProjectsiversidedTypesV67Bio.tx t"

View Replies !    View Related
How To Use A Variable As Object Name? In Actionscript?
I am working on a flash menu and have a problem in it.
here is the code i am using.
I wanna use the variable mnu instead of this[mnu] but do not know how to do it. Any body can help me?







Attach Code

var mnu = 'menu1';

this[mnu].onRollOver = function(){
var loTween_x = new Tween(this, "_xscale", Regular.easeInOut, 100, 150, .5, true);
var loTween_y = new Tween(this, "_yscale", Regular.easeInOut, 100, 150, .5, true);
trace(mnu);
}

View Replies !    View Related
Using A Variable To Reference An Object
Hello all,

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....??

var i = 0;
_root.movie[i]._visible=0;

should be just the same as

_root.movie0._visible=0;

should it not?

I have attached the .fla

thanks so much to anyone who can help me on this..its killling me...

View Replies !    View Related
Variable Object Referencing
Hello, I just stumbled across your forums today looking for an answer to my question on Google.

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

... any help?

View Replies !    View Related
Using A Variable To Reference An Object
Hello all,

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....??

var i = 0;
_root.movie[i]._visible=0;

should be just the same as

_root.movie0._visible=0;

should it not?

I have attached the .fla

thanks so much to anyone who can help me on this..its killling me...

View Replies !    View Related
Object Reference W/variable
This has been asked before, I've even had a similar problem before, but it's not working this time. Basically I have a MCL that works fine, but what I want to do is if it finds an error, It attaches a MC in the library to an empty MC created before the movie was loaded. But I want it all to be dynamic and I can't position the error msg MC in the right spot because I can't reference it w/a variable. I've tried eval() but it didn't work.


ActionScript Code:
// Checks for Error
    mcLoader.onLoadError = function(movClip, errorCode) { // Constructor
        var errLevel = level + 300;
        var msgName = "errorMsg" + prefix;
        // Checks type of error
        if (errorCode == "URLNotFound") {
            mcErrorLoad.attachMovie("txtErrorNoFile", msgName, errLevel)
        } else if (errorCode == "LoadNeverCompleted") {
            mcErrorLoad.attachMovie("txtErrorNoLoad", msgName, errLevel)
        }
        // Positions MC in center of designated area.
        mcErrorLoad.msgName._x = (movieWidth * .5) - (mcErrorLoad.msgName._width / 2) + xPos;
        mcErrorLoad.msgName._y = (movieWidth * .5) - (mcErrorLoad.msgName._height / 2) + yPos - 4;
    if (prefix == "nav") {
        LoadClip("secnav", 30, 0, 273);
        }
    if (prefix == "secnav") {
        LoadClip("sechome", 40, 149, 273);
        }
    if (prefix == "sechome") {
        LoadClip("home", 20, 0, 27);
        }
    }
    // End of Errors
 


This is how the MCL fires:

ActionScript Code:
//Use a loop to search through the File Array to find the appropriate file
    for (var i=1; i<_level0.listFile.length; i++) {
        if (prefix == _level0.listFile[i]["prefix"]) {
            var clipFileName = _level0.listFile[i]["file"];
            var documentName = _level0.listFile[i]["dName"];
            var movieWidth = _level0.listFile[i]["mWidth"];
            var movieHeight = _level0.listFile[i]["mHeight"];
        }
    }
    // Load Nav SWF
    mcLoader.loadClip(clipFileName, level);


It creates the 4 error MC's but I cant position them with:
mcErrorLoad.msgName._x = (movieWidth * .5) - (mcErrorLoad.msgName._width / 2) + xPos;

mcErrorLoad.msgName._y = (movieWidth * .5) - (mcErrorLoad.msgName._height / 2) + yPos - 4;

Because it won't point to the MC using the variable but if I use the actual name, it does fine.

As I've said, I cant get eval() to work with this. I really hate to repeat posts, but I'm at a loss.

View Replies !    View Related
How Do I Convert A (String + Variable)'s Value To An Object?
I hope I can explain this correctly.

How do I convert a (String + variable)'s value to an object?
This is an abstract of the code below:

Code:
createTextField(String("tf"+i),i,"tf"+j._x + "tf"+j._width,0,50,17);

I have tried String(); so that I can convert the value to an object but I don't think String is correct here. I have also tried Boolean(); but to no avail.

Can anyone please help me with this. Your help is graetly appreciated. Thank you.


Code:
for (i=1;i<3;i++) {
if (i==1) {
createTextField("tf1",1,391,0,50,17);
tf1.autoSize = "left";
tf1.selectable=false;
tf1.text = t1;
tf1.setTextFormat(myformat);
} else {
j=i-1;
createTextField(String("tf"+i),i,"tf"+j._x + "tf"+j._width,0,50,17);
this["tf"+i].autoSize = "left";
this["tf"+i].selectable=false;
this["tf"+i].text = this["t"+i];
this["tf"+i].setTextFormat(myformat);
//trace(tf+i._x);
//trace(this["tf"+j]._x + this["tf"+j]._width);
}

}

View Replies !    View Related
Referencing Object Using Variable Syntax
I'm having trouble referencing an object using a variable in Flash MX.
In this example, I'm dynamically loading jpegs and need to test that they have finished loading.
The img var contains the url of the image to load.


On the first frame:

for(i=0; i<number_of_images; i++)
{
//duplicate the holder
duplicateMovieClip(my_movie.holder, i, i);

//create reference for the img to load
img_to_load = "my_movie.holder." + i;

//load image into the duplicated movie
img_to_load.loadMovie(img_url);
}

On another frame:
if(img_to_load.getBytesTotal() >= img_to_load.getBytesLoaded() )
{
//image has loaded
}else{
//image still loading
}


My problem is that img_to_load is a variable that returns a string and not an object - what do I need to do?

Thanks in advance

View Replies !    View Related
How To Create A Global Variable From Within An Object?
I have an object on my stage, and within that object I have embedded some ActionScript. It's simple, something like this:

number = 5;

It works fine within that scene, but when I go to any other scene, I can no longer reference that variable. It comes up as "undefined."

How do I create a variable within that object that I can access from anywhere within my movie?

View Replies !    View Related
Using A Variable As A Field Name For A Shared Object
Hi,

Does anybody know of a way to use a variable as the field name for a shared object?
I am trying to save data to a shared object that is indexed to a number. Ideally I would like the following to work

sharedobject.data.varname = "data string"

I can create this manually as in

sharedobject.data.datastring1 = "data string"
sharedobject.data.datastring2 = "data string"

etc.

As I don't know the number of times data will be saved ahead of time, I cannot go the manual route. Not to mention doing it manually would be very inefficient.

I have tried a few things but nothing seems to work.

Any ideas?

TIA,

Colin

View Replies !    View Related
Please Help - Variable Object Property Names
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";

Can anyone help me? Can object property names be variable?
Thanks.

View Replies !    View Related
Accessing An Object Variable With A Space In
This should be easy, but I am stuck. I have created a dataprovider for a datagrid and the data comes from a db.

I have an object that is populated by the data from db. The field names have spaces in, so the code that creates the object creates a series of variables such as:

object.First Name;
object.Last Name;

But flash is not happy with the spaces (syntax error). But I need them for my datagrid columns. How do I get flash to see property name correctly? I have tried eval[""] to no effect.

thanks

frank

View Replies !    View Related
Object Movement Based On Variable
I have a certain movie clip moving on actionscript.
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
_y -= 10;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_y -= -10;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x -= 10;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= -10;
}
}


How could I use a variable to get this to work?

View Replies !    View Related
Variable And Instance Object With Same Name Gives Problems
Hi Everyone.

I have been searching around to find a solution to this small but anoying problem. The scenario is as follows.

Basically I have a fla. file in which I make in instance of a Class. Inside the class I have several variables, which are used as references to again other instances of classes. Problem is - the variable (reference) and the class its instanciatting can not have the same name. Nothing happens?

Okay, I am not even sure I understand the above myself, but here is a code example:

Inside the fla. file:

code:
var gameWorld = new gameWorld();


Inside the gameWorld.as class:

code:
class gameWorld{

var viewport;

function gameWorld(){
viewport = new viewport(this, 480, 360, 240, 420);
doSomthingWithVieportInstance(); // call to function below
}

function doSomthingWithVieportInstance(){
viewport.update();
}
}


Since in "viewport = new viewport(..)" the viewport names are the same it is not possible to call "viewport.update()". It should be because var viewport has global scope within the class (at least I think so), but nothing happens.

The funny part is that if I call the variable "viewportOne" - renaming it - it will work like a charm. ???

But why can't they have the same name?

Hope someone can help - please.

View Replies !    View Related
Passing A Variable To The FLVPlayback Object.
Hello to all,

I'm using Flash 8.

I need some help, I don't even know if its possible. But can you pass a variable with a query string to FLVPlayback Object.

I did manage to figure out how to do this if the videoHolder that is created by going to the Library box menu and selecting New Video and then setting the video properties to be controlled by action script.

This is what I have:

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
var rootNode:XMLNode;
var videoXML:XML = new XML();
videoXML.ignoreWhite = true;
videoXML.onLoad = loadCombo;
videoXML.load(myVideo);

var listener:Object = new Object();
listener.change = function(evtObj:Object):Void {
playVideo();
}
video_cbo.addEventListener("change", listener);

function playVideo():Void {
var videoName:String = video_cbo.selectedItem.data;
dynamic_video.attachVideo(stream_ns);
stream_ns.onStatus=function(infoObject:Object):Voi d {
if(infoObject.code=="NetStream.Play.Stop"){
stream_ns.seek(0);
stream_ns.play();
}
};
stream_ns.play("FLV/" + videoName);
}

function loadCombo(success:Boolean):Void {
if (success) {
var cboLabel:String, cboFile:String;
rootNode = this.firstChild;
for (var i:Number=0;i<rootNode.childNodes.length;i++){
cboFile = rootNode.childNodes[i].attributes.src;
cboLabel = rootNode.childNodes[i].attributes.caption;
video_cbo.addItem({label: cboLabel, data: cboFile});
}
playVideo();
}
}

I'm basically building a video player that has a list component that gets populated with a xml file of flv files locations and when you click on a particular title in the list it plays it in my videoHolder.

Here is the problem I now need to build a seek bar to be able to navigate through the movie, which is a pain and I don't even know where to start for my videoHolder.

But if my video was using an FLVPlayback component I can then use one of the skins or build a custom one because it's easy for this Component.

But placing an FLVPlayback component on the stage instead of the videoHolder I have and giving it an instance name of dynamic_video just like my videoHolder had, doesn't seem to work. I hear the sound of the video but I don't actually see any video.

What am I doing wrong here? In theory shouldn't any video player method given the same instance act the same way with the same actionscript.

View Replies !    View Related
[CS3] LoadVars() Variable Trying To Load Whole Object
I have been working on getting a basic variable to load from an external source (PHP) into Flash, and thus far.. it's actually loading! However, for some odd reason the variable that displays the variable is trying to display the entire object it's in. Can anyone help with this?


Code:
seriesData = new LoadVars();
seriesData.onLoad = function (success) {
if (success) {
series1.text = seriesData;
} else {
series1.text = "Error Loading";
}
}

seriesData.load("listing.php");

View Replies !    View Related
Object Variable Defenition Not Working...
hi guys,
I have a clip named c1_1 on stage, in my code it is reffered to as
_root["a"+vertic+"_"+horiz]
it has a variable defined on it (from the main timeline)
_root["a"+vertic+"_"+horiz].cardName = "blank";

Now i have an object defined as cob66.
cob 66 has a variable defined on it as well cob66.cardName = "InvincibleTank";

Now if i want c1_1.cardName to equal cob66.cardName i simply use
_root["a"+vertic+"_"+horiz].cardName = cob66.cardName;
And that works, now i have an array called myHand. The 0 index of that array is 66, myHand[0] = 66;

i want to make it so i can set the c1_1's name and cob66's name equal using that array, so i made
trace("cob"+myHand[0]);
_root["a"+vertic+"_"+horiz].cardName = ["cob"+fmyHand[0]].cardName;
trace(["cob"+fmyHand[0]].cardName);
trace(_root["a"+vertic+"_"+horiz].cardName);

3 things trace:
cob66
cob66
undefined


Can anyone please help me out? I really appriciate any help, and thanks for your time.

PS - sorry for the color coding.

View Replies !    View Related
Attaching A Variable To A Class Object
Neither in flash help nor in google could I find the answer.

I'm trying to create sound objects sequentially inside a for loop but I can't name them the way I want. I have an array that states the names of the mc's. I know where the wrong thing is but I don't know how to fix that:

ActionScript Code:
var theArray:Array = new Array("zero", "one", "two", "three", "four", "five");
for (i=1; i<5; i++) {
    var "mySound"+i:Sound = new Sound();
    "mySound"+i.attachSound(theArray[i-1]);
    playSounds();
}
function playSounds() {
    // I'm building this portion at the moment
}
Neither of the following works:

"mySound"+i
_root["mySound"+i]
[mySound+i]
(mySound+i)

Any ideas?

View Replies !    View Related
Create A Variable On A Specific Object
I would to know the state of my checkbox

here is the code

Code:
on(release){
if(this._name[checkBoxState] == undefined || this._name[checkBoxState] == false){
this._name[checkBoxState] = true;
this.gotoAndStop(2);
}
else{
this._name[checkBoxState] = false;
this.gotoAndStop(1);
}
trace(this._name[checkBoxState]);
}
I would to merge the variable on the name of the button because I will have more than 1 checkbox on the screen. Is there a way of doinf it ?

View Replies !    View Related
Class Object Variable Issues..
I tried to post this earlier and got no answers.. maybe someone can help with this now:

I'm having this problem trying to access an object variable and an array variable for that matter that are part of a Player class that I am creating. Now when I set up the test code I made a temp object that I put some test variables in i.e.,

var temp:Object = {x: 5, y: 5, name: "Rob"};

then I set my Player.attr = temp and I also did:

for(var str:String in temp)
{
Player.attr[str] = temp[str];
}

I have tried this both using a public var attr and a private var _attr that I'm using getter and setter methods with and the result is the same every time. If I directly access the items i.e.,

trace(Player.attr.x) // returns 5

but I can't access it with a for..in loop...why??

for(var str:String in Player.attr)
{
trace(Player.attr[str]);
}

I get an error that the variable doesn't contain the static attribute... I don't get it.

same thing if I have an array variable within my class and i try to access it through a loop:

for(var i:Number = 0; i < Player.tempArray.length; i++)
{
trace(Player.tempArray[i]);
}

I get the exact same error...

Please, is there something that I'm doing terribly wrong to access this data. How do I utilize the loops to pull the data out. I need to use the loops specifically because the array is going to be for the inventory and it dynamically grows or shrinks so I have no way to tell how many elements are within it and although the object has a finite set of attributes there should be a way to get the information out of it through a loop. If not that's just crazy!! Thanks in advance for the help.

View Replies !    View Related
Dumping Object/Array/Variable In AS3
So I'm a PHP programmer and we have a very cool function called print_r that does this with an array:


HTML Code:
<?
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print "<pre>".print_r($a, true)."</pre>";
?>
The output is the following:


HTML Code:
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
So my question is this: is there an AS3 equivalent? or something like it? I'm debugging an AS2 to AS3 program in which I have tons of bugs and I'm going line by line trying to figure out why my translation isn't working and I would love to see the contents of each object/array/variable.

Any thoughts?

View Replies !    View Related
Using String Variable To Define Object
Hey guys,

im having trouble getting this code to work. I would really appreciate any help you can provide as its the only thing holding me back from finishing my project :-). what im doing is creating a map where when you click on a state, it brings up all the locations we have within that state. the locations for each state are within an xml file.

the file has the following structure. it is just a list of locations within different states. i used the each state's two letter code for the structure.


ActionScript Code:
<venuelist>
    <mi>
        <name></name>
        <address></address>
        <city></city>
    </mi>
    <mi>
        <name></name>
        <address></address>
        <city></city>
    </mi>
    <ma>
        <name></name>
        <address></address>
        <city></city>
    </ma>
</venuelist>

here is the result handler. right now it is set so that it always grabs the locations from michigan

ActionScript Code:
public function resultHandler(event:ResultEvent):void {
    var arrvar:Object = event.result.venuelist.mi;
    arrcol = arrvar as ArrayCollection;
    dg.dataProvider = arrcol;
    }

in my flex, i have a http service calling the xml file and assigning the entire xml collection to a variable. and then having it assigned as the dataprovider for my datagrid. when you click on a state, it creates a pop up with the data grid. i also have an alert that shows the two letter state code you click on

ActionScript Code:
public function createPopUp(event:USAMapEvent):void {
        var stateSelected:String = event.code;
        Alert.show(stateSelected, 'Alert Box', mx.controls.Alert.OK);
        PopUpManager.addPopUp(panel, this, true);
        PopUpManager.centerPopUp(panel);
    }

what i need to do is set the dataprovider for the datagrid to something like dg.dataProvider = arrcoll + stateSelected so that it will go to "
"venuelist.stateSelected". what is the proper way to do this. any help is appreciated!

View Replies !    View Related
Assigning Value To Object Member Variable?
This example comes from "Learning Actionscript 3.0" pp 138-9:


Code:
public function Particle(xp:Number, yp:Number, xvel:Number, yvel:Number, grav:Number, col:uint) {
_xpos = xp;
_ypos = yp;
_xvel = xvel
_yvel = yvel
_grav = grav;

var ball:Sprite = new Ball();
addChild(ball);

x = _xpos;
y = _ypos;
alpha = .8;
scaleX = scaleY = Math.random() * 1.9 + .1;

var colorInfo:ColorTransform = ball.transform.colorTransform;
colorInfo.color = uint(col);
ball.transform.colorTransform = colorInfo;

addEventListener(Event.ENTER_FRAME, onRun, false, 0,
true);
What not simply


Code:
ball.transform.colorTransform.color = uint(col);
instead of the actual three lines of code in bold?

When I try my substitution, the assignment fails. Why? And why the necessity for the roundabout assignment? Thanks, I'm coming to AS3 from other languages (not Javascript), so any understanding would be appreciated.

View Replies !    View Related
Append Path To Object Using Variable
I would like to do something like this

for ($i = 0, $i < 10, $i++){
_root.object1.object($i).text = "object"+$i;
}

And this would allow me to modify 10 text objects on the stage and insert the text object1, object2, object3, etc.

The part i don't know how to do is in bold and itallics.

Thanks Guys!

View Replies !    View Related
Creating New Date Object Using A Variable..?
Hello,

I am trying to create a new date object using the value stored in the variable.

Adobe Actionscript online manual says I can create a date object like this:

gary_birthday = new Date (74, 7, 7);


However I need to create a date object using the value stored in the already existing variable (as argument) something like this:

gary_birthday = new Date (varDateFromASP);

where the varDateFromASP is the variable value I receive from ASP using loadVariablesNum().

However, the code shown above didn't work.

Can somebody please show me how I can modify the code shown below to make it work?


varDateFromASP = "2008, 9, 15"
gary_birthday = new Date (varDateFromASP);

View Replies !    View Related
Variable To Another Function Metadata Object
I'm trying to do some math in a different function then the one listed below but the value will not store. The only way it works is below...if I tell it to go to another function. My problem is I want it to go to my scrub function which means it would scrub the video which I don't want unless someone clicks.

Anyway, why can I not say videoDuration = info.duration and then from now on be able to call videoDuration?


ActionScript Code:
var videoDuration: int;


function onMetaData(info:Object):void {
     trace("width: " + info.width);
     trace("height: " + info.height);
     videoDuration = info.duration;
     duration();
  }
 
  function duration()
  {
    trace(videoDuration); 
  }

View Replies !    View Related
How Do I Refer To A Object Or Variable Dynamically
Here it what I am trying to accomplish.

I have a few variables:
var x = "Crazy";
var y = "NotCrazy";
var superCrazy;
var superNotCrazy;

How do I do something like this:
"super" + x = "anything";
"super" + y = "whatever";

So that:
superCrazy = "anything";
superNotCrazy = "whatever";

This is how I imagined actionscript able to access variables and objects dynamically. But I get an 1123 error and I believe the error points to something only available in AS1.

So, how do I do this in AS3....hmmmmmmm!!

View Replies !    View Related
Pass Variable To New Color Object
I basically have an array of buttons and am looping through and assigning a new Color (instance name) to each.

Is it possible to pass a variable to a Color object like below?


Code:
buttons[i] = new Color (buttons[i]);
cos that aint working

If it can be done.... am I just using the wront syntax?

View Replies !    View Related
[AS3] Access Library Object By Variable Name
Let's say I have a button which sets the variable color to green:

var color:String = "green"

I have a movieclip in my library called "green". With AS2 we could simply use:
whatever.attachMovie(color, "someclip", 1);

In AS3 this works perfectly fine:
var whatever:Sprite = new green ();

to use the variable I tried the following:
var whatever:Sprite = new this[color] ();

but the movieclip is not loaded. Any ideas?

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved