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




Variable Help



For some reason I am not getting this tonight... I have a function I want to be able to call within movie clips, a la:
onClipEvent(enterFrame){
if(_alpha > 0){
_root.fade_me(this._name);
}
}

Right now, the function looks like this:

function fade_me(arg1){
var ft = _root[arg1];
ft._alpha = ft._alpha - 10;
}

And it works fine for clips contained off the root, however, when I try to call clips contained within other movie clips, it craps out.

I know the code is not built to do this, but I am having a real problem figuring out how to call the function properly.

Please help!

Thanks,
Mike



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-29-2002, 12:59 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Set One Variable Equal To Another Variable And Using Another Variable To Call It.
set one variable equal to another variable and using another variable to call it.

multiple vars on main stage.
var x in MC with
var y in same MC.

i want to set x = one of the the var on the main stage using var y to define which one.

Thanks
Keith

How Do I Make A Variable Store A Variable? - Dynamic Input Stuff ...
Hey, I got a little problem which I've usually been able to work around but in this particular case there really isn't another way. I want to give in a variable, say "x+x" and then use it as "x+x" and not as their assigned values ...

my result should be that I can alter the course of a loop like this ... for example:

input in text field = x+x

for(x=0,x<=50,x++){
...

y[x]=x+x

...
}

and if I give in 2*x it would make y[x]=2*x

I have no idea if there's a way in flash to accomplish this but if there is I'd sure like to know, thanks for any help I receive, I'll check back here soon.

Dynamic Text Field Is Calling The Variable Name Instead Of Variable Content
I'm having a problem getting something to work. I'm sure it has something to do with string variables and my syntax, but can't figure it out.

I have variables named cust1, cust2, cust3, etc. that are being loaded from a text file (these are customer names that will display in a text ticker).

I want a dynamic text field to display the customer names in incremental order, so I created a variable that consists of the string "cust" + a numeric variable called custNumber. At the end of each pass of the movie, custNumber is increased by 1.

var custNumber = 1;
var custName = "cust"+custNumber;

I want the dynamic text field to call the variable custName, but I can't get it to work. It keeps displaying custName as a string ("cust1", "cust2", etc.).

So I created a new variable called scrollText for the dynamic text to call, and made scrollText = custName;. But it does the same as above.

How do I get my dynamic text to call the variable that I create with another variable?

I want my dynamic text field to display the variable cust1, cust2, cust3, which would be "Jones Plumbing," "Smith Electric" etc., but all I'm getting is "cust1", "cust2", "cust3" etc.

Thanks,

Thom

Problem Assiging Class Variable To The Main Timeline Variable .... PLEASE HELP
Hi Guys

I just can't seem to solve this problem!!!

I have a random class that generates a random image and an id number from an xml file and a main class that reads information from an xml file according to the id number.

I'm having trouble assigning my random id number from my class to the _root.id variable on the main timeline for my other class to read. I keep getting undefined???

Random Class Code:


Code:

import mx.utils.Delegate;
class randomClass {

public var target_mc:MovieClip;
private var _xml:XML;
private var myTotal:Number;
private var random_number:Number;
public var myFid:Number;
private var myPic:String;
private var myTitle:String;

private var myImages:Array = new Array();
private var myTitles:Array = new Array();
private var myFids:Array = new Array();
function randomClass(url:String, target:MovieClip)
{
target_mc = target;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = Delegate.create(this, onLoadEvent);
_xml.load(url);
}

function onLoadEvent(success:Boolean):Void
{
if (success)
{
var i:Number;

myTotal=_xml.firstChild.childNodes.length;

for(i=0; i<=myTotal-1; i++)
{
myImages[i]=_xml.firstChild.childNodes[i].firstChild.firstChild;
myTitles[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.firstChild;
myFids[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild;
}

random_number=random(myTotal);

myPic="<A href="http://www.mydomain/images/"+myImages[random_number">http://www.mydomain/images/"+myImages[random_number];
myTitle=myTitles[random_number];
myFid=myFids[random_number];

target_mc.title.text=myTitle;

var TheMovieLoader = new MovieClipLoader();
TheMovieLoader.loadClip(myPic, target_mc.new_mc);

var pictureLoaderListener = new Object();
pictureLoaderListener = TheMovieLoader.onLoadComplete()
{
target_mc.new_mc._x=-9;
target_mc.new_mc._y=-5;
target_mc.new_mc._xscale=40;
target_mc.new_mc._yscale=40;
}
TheMovieLoader.addListener(pictureLoaderListener);
target_mc.random_id.onPress = Delegate.create(this, onPressEvent);
}
}

public function onPressEvent() {
_root.id=myFid; //Undefined
trace(myFid); //ok
}
}

Main Movie Code:


Code:

on (press) {
var Obj:myClass=new myClass("<A href="http://mydomain/fanbase.xml",_root.viewer">http://mydomain/fanbase.xml",_root.viewer, _root.id);
}
It just keeps saying undefined but yet i seem to be able to trace myFid

Any ideas???

Thanks in advance

Problem Passing Variable Values (from XML) To Variable In Child Movie
I'm reading something from XML, and store it in a variable. I can trace the variable and it shows two items. I can display those two seperately with variable[0] and [1], meaning that it works as intended.

After that, I'm calling a movieclip, which is supposed to read that variable.. sadly, it can't do it. So I resorted to passing the content of the first variable to a variable inside the called movieclip. This works, and tracing the second variable shows both items from the first. However, I cannot access the items seperately with variable2[0] for example.

What's the problem? The second variable is currently a string. I tried to declare is as other things (like xml or array) as well, but that didn't help. Is there also a way to make this procedure unnecessary, i.e. can I somehow access the first variable?

I've attached the fla/xml/swf in case my description doesn't make sense!

Problem Assiging Class Variable To The Main Timeline Variable .... PLEASE HELP
Hi Guys

I just can't seem to solve this problem!!!

I have a random class that generates a random image and an id number from an xml file and a main class that reads information from an xml file according to the id number.

I'm having trouble assigning my random id number from my class to the _root.id variable on the main timeline for my other class to read. I keep getting undefined???

Random Class Code:


Code:

import mx.utils.Delegate;
class randomClass {

public var target_mc:MovieClip;
private var _xml:XML;
private var myTotal:Number;
private var random_number:Number;
public var myFid:Number;
private var myPic:String;
private var myTitle:String;

private var myImages:Array = new Array();
private var myTitles:Array = new Array();
private var myFids:Array = new Array();
function randomClass(url:String, target:MovieClip)
{
target_mc = target;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = Delegate.create(this, onLoadEvent);
_xml.load(url);
}

function onLoadEvent(success:Boolean):Void
{
if (success)
{
var i:Number;

myTotal=_xml.firstChild.childNodes.length;

for(i=0; i<=myTotal-1; i++)
{
myImages[i]=_xml.firstChild.childNodes[i].firstChild.firstChild;
myTitles[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.firstChild;
myFids[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild;
}

random_number=random(myTotal);

myPic="<A href="http://www.mydomain/images/"+myImages[random_number">http://www.mydomain/images/"+myImages[random_number];
myTitle=myTitles[random_number];
myFid=myFids[random_number];

target_mc.title.text=myTitle;

var TheMovieLoader = new MovieClipLoader();
TheMovieLoader.loadClip(myPic, target_mc.new_mc);

var pictureLoaderListener = new Object();
pictureLoaderListener = TheMovieLoader.onLoadComplete()
{
target_mc.new_mc._x=-9;
target_mc.new_mc._y=-5;
target_mc.new_mc._xscale=40;
target_mc.new_mc._yscale=40;
}
TheMovieLoader.addListener(pictureLoaderListener);
target_mc.random_id.onPress = Delegate.create(this, onPressEvent);
}
}

public function onPressEvent() {
_root.id=myFid; //Undefined
trace(myFid); //ok
}
}

Main Movie Code:


Code:

on (press) {
var Obj:myClass=new myClass("<A href="http://mydomain/fanbase.xml",_root.viewer">http://mydomain/fanbase.xml",_root.viewer, _root.id);
}
It just keeps saying undefined but yet i seem to be able to trace myFid

Any ideas???

Thanks in advance

Problem Assiging Class Variable To The Main Timeline Variable .... PLEASE HELP
Hi Guys

I just can't seem to solve this problem!!!

I have a random class that generates a random image and an id number from an xml file and a main class that reads information from an xml file according to the id number.

I'm having trouble assigning my random id number from my class to the _root.id variable on the main timeline for my other class to read. I keep getting undefined???

Random Class Code:

Code:
import mx.utils.Delegate;
class randomClass {

public var target_mc:MovieClip;
private var _xml:XML;
private var myTotal:Number;
private var random_number:Number;
public var myFid:Number;
private var myPic:String;
private var myTitle:String;

private var myImages:Array = new Array();
private var myTitles:Array = new Array();
private var myFids:Array = new Array();
function randomClass(url:String, target:MovieClip)
{
target_mc = target;
_xml = new XML();
_xml.ignoreWhite = true;
_xml.onLoad = Delegate.create(this, onLoadEvent);
_xml.load(url);
}

function onLoadEvent(success:Boolean):Void
{
if (success)
{
var i:Number;

myTotal=_xml.firstChild.childNodes.length;

for(i=0; i<=myTotal-1; i++)
{
myImages[i]=_xml.firstChild.childNodes[i].firstChild.firstChild;
myTitles[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.firstChild;
myFids[i]=_xml.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild;
}

random_number=random(myTotal);

myPic="<A href="http://www.mydomain/images/"+myImages[random_number">http://www.mydomain/images/"+myImages[random_number];
myTitle=myTitles[random_number];
myFid=myFids[random_number];

target_mc.title.text=myTitle;

var TheMovieLoader = new MovieClipLoader();
TheMovieLoader.loadClip(myPic, target_mc.new_mc);

var pictureLoaderListener = new Object();
pictureLoaderListener = TheMovieLoader.onLoadComplete()
{
target_mc.new_mc._x=-9;
target_mc.new_mc._y=-5;
target_mc.new_mc._xscale=40;
target_mc.new_mc._yscale=40;
}
TheMovieLoader.addListener(pictureLoaderListener);
target_mc.random_id.onPress = Delegate.create(this, onPressEvent);
}
}

public function onPressEvent() {
_root.id=myFid; //Undefined
trace(myFid); //ok
}
}
Main Movie Code:


Code:
on (press) {
var Obj:myClass=new myClass("<A href="http://mydomain/fanbase.xml",_root.viewer">http://mydomain/fanbase.xml",_root.viewer, _root.id);
}
It just keeps saying undefined but yet i seem to be able to trace myFid

Any ideas???

Thanks in advance

About Refreshing The Value Of A Variable Inside Of Another Variable (in A Text Field)
Hello, I have a simple question, but I'm not sure this is possible in Flash:

I'll simplify the problem so that it's easy to understand.

I have a text field holding a variable called "products".

This variable is defined via ActionScript somewhere else, with something like this:


Code:
products = "Some text here" + variable1;


The problem is that, when "variable1" is updated, the value of "products" will obviously remain the same, as it hasn't been redefined (I could redefine it as [products = products + ""] or something, but if I don't include the "variable1" in the definition it won't pick its new value).

I really need to do this with just one text field, and I cannot redefine the whole variable "products" again, as it is much complex than this example and keeps storing info in different ways depending on what the user does.

Any suggestions?
Thanks in advance

How To Store A String Plus A Variable In A Dynamic Text Variable?
Hi,

I've got a dynamic text field with the instance name rightAnswer_txt.

I declare the variable in the frame it resides in, with the following code var rightAnswer_txt:String = "";

Then, when I want to populate it using the following code:

rightAnswer_txt.text = "You scored " + rightAnswers;

the script comes out with an error saying ...

**Error** Scene=Scene 1, layer=actions, frame=7:Line 15: There is no property with the name 'text'.
rightAnswer_txt.text = "You scored " + rightAnswers;

Any idea what this means anyone please?

Variable Scope - Dynamically Created Variable Not Working
Hi all,

For a movieclip obj, I created a dynamic variable and in the onLoadInit handler this variable is not accessible.

This is my code:
--------
var imagesList:Array = new Array("flagGreen.gif", "flagRed.gif");
var path = "images/";

var myMc:MovieClip
= _root.createEmptyMovieClip("myMc", _root.getNextHighestDepth());
myMc.url = path+imagesList[0];

var loader = new Object();
loader.onLoadInit = function(targetMc){
trace( "url1:"+targetMc.url);
trace( "url2:"+_root.myMc.url);
trace( "width:"+targetMc._width);
trace( "height"+targetMc._height);
}

var mcLoaderObj:MovieClipLoader = new MovieClipLoader();
mcLoaderObj.addListener(loader);
mcLoaderObj.loadClip(myMc.url, myMc);

-----------

Image is getting loaded. When myMc.url is passed as a param to loadClip, it is working, but inside onLoadInit it is printed as undefined.

Help will be appreciated. Thanks in advance.

- Kiran

Variable Take On Content Of A Root Variable And Not Its Path - Simple Please Help
Hi there ok my brain has died and fallen off somewhere , what i am trying to do is this:


l=0

l++


_root.advert= "_root.var" + l ;

then i have a text box on stage , dynamic, etc var: _root.advert
, vars are stored in a text file , vars are called, var1, var2 etc , text box needs to display variable contents, but at the moment it just says "_root.var1" etc and not the content s of var1 this is very simple problem but my brains dead please help.

-arran

Loading Variable Smarclip Into Variable Movieclip?
HO HO HO FashMonsters-

Damn, Loading a variable driven smartclip into a movie clip can be a lil' tricky. Problem is I think I need the movie clip to be a variable as well. My button action is calling up my movie clip instances which are referencing the variable smart clip. However, each button action loads a new movie clip atop the previous. I either need to remove the previous movieclip or make the movie clip a variable loading variable smart clips.

Da Dizawg wud LUV some Hizelp!

Dynamic Text Box Variable = Other Variable, No More Scroll
So I have this textbox. And I want it to display some text. And I want the text to scroll and I want the text to change when you click a button. W007 I did it I am done. But I have a little problem, and I do hope you can help.

I loaded variables from a text file into flash, gave the variables different names, and then I set the buttons that can be clicked on to set the dynamic text box variable to equal one of the loaded variables. Ít wouldn't scroll after that. Whats up wit dat.

I can get you the FLA if you want it, but I am hoping someone will just say oh ya, common mistake, you gotta check a box or something.

Make A Variable = A Variable From A Text Document
I'll try my best to explain this, but it might be easier to see the file itself, I zipped it up and can be found at:

DOWNLOAD ZIP FILE
(the flash file is not pretty, I am building the functionality first)

-----------------------------

The variable it is creating does not call up the variable in the text
document.

I have a textfield called: randomquote

the value for randomquote is being "created" by:

Set Variable: "randomquote" = "q"&VARX2

VARX2 is a random number being generated by:

Set Variable: "VARX2" = Random ( VARX )

VARX is a number being pulled from the text document:

Set Variable: "VARX" = (/:myNumber)


SO, If I hard code randomquote with the value q4 , then the variable q4 from the textdocument is pulled up correctly.

BUT, if randomquote equals q4 (generated from a random number) the variable q4 from the textdocument is not shown, but rather just a simple q4.

Passing Array Variable Name In To Component Variable & Getting It's Value
Hi, All
Anyone can solve my problem????
My Problem is that I want to store a array' s name in to a component variable. like this:-

working in this case

Scene action on timeline
_global.arr = "This is aray Test"

component parameters
VarName : _global.arr



Not working in this case

Scene action on timeline
_global.arr1 = new Array()
_global.arr 1[0]= "This is aray Test"




component parameters
VarName : _global.arr1[0]




in component I'm doing this on timeline action
abc.text = eval(VarName)


plz help me out of this

Regards
Ankur Arora

Php Variable -> Actionscript Variable (transfer Without Being Seen By User)
I am trying to secure up the sign up process with something similar to the "type these 6 letters"

the problem is, how to get a value between php(or any server-side language) and actionscript? I only know ways where the variable would be visible to a robot, rendering this extra sign-up step useless.


So I am wondering if there is a way to transfer a variable without it being seen during transfer?

I have a little bit of knowledge about public variable encryption and I know it would work for this but i have never implemented this encryption before. Is there a tutorial that shows how to go about creating a public encryption/decryption algorithm?

How Do I Convert A String Variable Into A Number Variable?
How do I convert a string variable into a number variable?

Thanks in advance.

Garry

Change String Variable To A MovieClip Variable
Hi

I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.

I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.

When I trace "drawingCanvas" I get

[object drawClass]

which is fine. Tracing drawingCanvas.name gets me the instance name

'drawingCanvas'.

This is a String variable.

Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.

The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :

TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.

I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).

Any ideas are most welcome. I'm sure I am missing something obvious.

Thanks for looking

Sting Variable To Mc Path - VARIABLE TYPES
Hey all Im building a variable like this

var m = "_root.subNav.subNav" + i;

When I do a trace to find the var type it comes back as a string so my function wont execute thinking it is a string and not a path. Does anyone know how to fix this or change the variable type on the fly in AS 1.0? Ive tried:

var m =eval( "_root.subNav.subNav" + i);

But that came back undefined....
Thanks.

Changing Root Variable With Text Variable
Simple question: I'm trying to change the value of a variable on the _root level (called "myVar") to whatever a user types into a text box (mytextvar) on the stage. I have a button that says:

ActionScript Code:
on (press) {
    _root.myVar = _root.myTextVar;
}
It isn't working... any ideas how to make this work?

Apply Variable Values To Variable Names?
I have a gallery with a series of 5 thumbnails, named gallery_position_1, gallery_position_2, etc, up to 5. I am loading an image with XML into gallery_position_(#), and have a button on top of that with scripts on it.

My question is whether I can have an integer variable (call it x) that starts at 1 and can be put into a for loop, using it then on the end of my other variable like so:

for (x = 1; x < 6; x++) {
gallery_position_x.loadMovie(URL path to image);
}

I basically want to be able to "index" a regular variable by changing a number within its name. I know its a long shot, as I've never seen it done before, but I thought I'd ask, all the same.

Convert String Variable Into Movieclip Variable?
I have a variable called something like city_str which has a value of "toronto". I also have a moveclip (exported for AS) called toronto_mc.

What I want is a way of concatenating strings of "toronto" and "_mc" and assigning it to a movieclip variable called toronto_mc. Everything I try gives me a mismatch error in the compiler. I'm writing AS2 using Flash CS3. Any ideas?

Overwrite Variable Versus Delete Variable
I'm assuming that if you were to create a variable that referenced an instance of a class, then if you were to overwrite that variable with an instance of a new class, the old class would be deleted without explicitly deleting that class. Am I correct in assuming this?

Can't Update Movie Variable With Loaded Variable
i have a php file that loads an array of variables with paths that load into some text fields in duplicated movie clips. The php path is right, but it just doeasn't load them into the txt fields. How do i get and set the variables???

this gets loaded into th movie from the php file;
_level0.work.client_mc6.web_work.web_mc0.file0 = "rm1.jpg"

but it doesn't replace what is already in there??!!
_level0.work.client_mc0.web_work.web_mc0.file0 = "remove me"

how do i update the old vaiable with the one tha'ts loaded via PHP?

|||---> Variable Textfields And Variable Sizes?
ok... i'm trying to add tool-tips

i would like to have the dynamic textbox (which follows the mouse) resize itself based on the /:tip variable i have created

so that if /:tip = "" no textbox appears

and if /:tip = "flash 20k" the textbox would be the right size to fit the text

i'm trying to do this with the background feature turned on, so that the text is black on white

---

can anyone point me in the right direction?? much appreciated

-steve

Set Variable: Setting Variable Name Dynamically
hi...

i want to set a variable dynamically, i have done:

soundCount = 5
set (eval("loading"+SoundCount), 1);

i want the outcome as:
loading5 = 1

which i wanna check later...

is it right? because i m not getting the result when i
trace (loading5)

please help

Evaluate Variable Value Then Update Corresponding Value Of Another Variable
Firstly thanks to KP who helped me out successfully last time.

I want a button to copy the user entered text from an input textbox and then add it to the content of a dynamic textbox...and I am STRUGGLING to say the least.

If you can help it'd be much appreciated!

Variable In Movie Clip With A Variable Name
Hello,
I need to find out the content of a variable in a Movie Clip with a variable name. I created several movie clips with "duplicateMovieclip" in a for... loop. Looks like this:
for (i=1; i<=5; i++) {
duplicateMovieClip (_root.oldname, "newname"+i, i);}
Now I want to know and set the content of a variable stored in this clip, but again in a for.... loop.
I tried it with:
"_root.newname"+i+".variable"=content;
This does not work. Anyone any ideas?
Thanks for any answer that might help me.
Greetings from cologne
Ole

Displaying Value Of A Variable In A Variable Txt Field
I am incrementing a variable (game score), how can this be displayed in a variable txt field on a "win" keyframe? Something like "printf" in C?

Can anyone tell me this code please?

Setting The Value Of A Variable, Checking The Value Of A Variable
i think this might be a simple question, but I can't figure it out and it's puzzled me for a long time. If I set a variable OnRelease - let's say I have 4 buttons that set a variable to 4 distinct values, depending upon which button is pressed. How do I create a check, later, from another part of the movie, for what the current value of that variable is?
Is the variable universal - that is once it is set, the entire movie sort of 'knows' what the value of that variable is? Or do I have to direct the attention of the movie back to the same clip or frame or wherever I set it. Either way, what is the syntax?
I hope I was able to explain this and that it makes sense to someone.
Thank you!
-ml

Variable Names Are Part Of A Variable Itself
hello,

i ahve a deadline and im in a bit of a mess, i was wondering if anyone knows the awnser to this one.

i am targeting a variable in another movie the name of the variable is ' ysh1 ' this is a score and the is 9 other they are ' ysh2 ' , ' ysh3 ' etc.
and a variable on the main time line called ' hole ' ,
it's value is ' 1 '.

this is the variable that targets ' ysh1 '.
set ("_level0.display.score.ysh"+_level0.hole, "_level0.display.score.ysh"+_level0.hole+"+1") ;

so it does target the variable, that works fine but i cant make the score increase by 1
im just try to increase the score by one evey time this function is called.

it's driving me mad.

any help would be great.

_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

Creating A Variable The Name Of The Contents Of Another Variable
Hi all

I've got a variable called "test"

Within "test" there's the string "monkey"

I want to create a variable called "monkey" in another movieclip and add a string to it.

How do i do this?


I've tried _root.movieclip.eval(test) = "blah"

But this generates an error....

any ideas?

Many thanks

Converting Variable Contents Into A Variable Name?
Hi

How do you convert variable contents into a variable name?
ie

var Monkey:String = "ape";

how do I then make

var apeBanana:String;

I've tried

var [monkey+"Banana"]:String;

but that doesn't work, any suggestions appreciated :-)

How To Put External Variable's From PHP Into Variable's In A Function
I already echo my variable's the right way. I want to make it possible to adjust collors trougout my database. This is what my PHP file echos:

&homecolor=33ff33&newscolor=000000

this is how my PHP file looks:

PHP Code:




<?php

require("connection.inc.php");

$query = "SELECT name, color FROM outlinecolors";
$result = mysql_query($query);

while(list($name, $color) = mysql_fetch_row($result)) {
print("&$name=$color");
}

?>







This way of using PHP also works for the text I use in my movie, which I let flash put in a dynamic textfield. So I tought that it should be possible to have the variable colors above being used in the next function:

code:
home_btn.onRelease = function() {
outline.fadeColor(homecolor, 100, tweensspeed, test);
};


"homecolor" is the place where the value/echo from php must come (&homecolor=33ff33) so "33ff33" must be in the function in stead of homecolor.

Can anybody help me?

Greets..

Make A Variable Equal Another Variable
Code:
set ("variable1",variable2.value);


Forgive this stoopid question but what's the right syntax here

I want to set a string variable called variable1 to equal the string variable called variable2.

TIA

Variable From Flash As Childnode Variable
Is it possible to take a variable from Flash and use it as an xml childNode variable?


Code:
function loadXML(loaded) {
if (loaded) {
i = int(_root.shoe_id);
_root.shoe = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_root.shoe_color = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
shoe_txt.text = _root.shoe;
shoe_color_txt.text = _root.shoe_color;
} else {
content = "info unavailable";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("brand_info.xml");

Javascript Variable To Flash Variable Name
I have a weird situ. where I have to convert a javascript string var into a flash var, but its not your typical value conversion.
I need to convert the javascript string value to flash's variable name.
in other words:

Code:
javascript:
function startMov()
{
elem.SetVariable("/variables:startStation", "stationA");
elem.SetVariable("/variables:endStation", "stationB");
elem.TCallLabel("/functions","setStation");
}

in Flash the "variables" MC:

var stationA = 239;
var stationB = 412;
var startStation;
var endStation;


_root actions:

setStation = function () {
currentStation = variables.currentStation;
startAtStation = variables.startStation;
stopAtStation = variables.endStation;
up_hall.gotoAndPlay(startAtStation);// no problem here, because its a string
stopAtEndStation();
};
stopAtEndStation = function () {
this.onEnterFrame = function() {
if(up_hall._currentframe == stopAtStation){
up_hall.stop();
delete onEnterFrame;
}
};
};
So when I pass in "stationA" I need for the value to be the integer 239.
I have tried to eval the var, but I just get "undefined"

[F8] _root.Variable VD _global.variable
Hi! This code i need help with is just for learning purpose, im not really trying to acomplish a certain thing. Just to understand more about AS.

FLASH 8

I have dynamic text box thats reading the variable _root.my .

In the first frame i have this


Code:
_root.my = "So long Jerks!";


i have a MC as buton with following


Code:
button.onPress = function (){
_root.my = "goodbye";
}


This is all cool. I try the movie and, WUEPA! the text box says "so long Jerks!". When i click the button the text chabges to "goodbye".


When i exchange _root.my for _global.my in all the before mentioned places., nothing works. The dynamic textbox never shows anything.

How do i use _global variables?

Comparing Javascript Variable Against An XML Variable
Hi,

I currently send a url variable (using javascript) into my flash movie.

I want to compare this variable against a name in an XML file and where they match show the images associated with those XML nodes.

e.g. I have the following xml:


Code:
<gallery cityname="london" xpos="0" ypos="0">
<image path="images/1.jpg" />
<image path="images/2.jpg" />
<image path="images/3.jpg" />
</gallery>


Say my variable name is "london" (from the URL http://www.thisisatest.com/test.html?city=london)

How can I compare this variable against cityname="london" from my XML file and display the images where they match?

Thanks

[CS3] [AS2] Using Variable Text Contents As Another Variable's Name
Hi guys. I was wondering if there was a way to use a variable's contents (such as an input text box's contents) as the name of another variable. Both variable will be global. So, if the text box's instance name is "txt_box" and
Quote:




txt_box.text = _global.hello




how would I use the contents of _global.hello as the name of another variable? I think it's something like
Quote:




_global[[_global.hello]] = "text";





or something along those lines.

Thanks,
Sportzguy933

Variable = Variable -1 = Broken Math?
Hi there,

At the beginning of my flash file, I have:

var beers:Number = 0;


Later in my game you can use your money to buy a beer, the code goes:

beers = beers +2


The code for when you drink the beers goes:

beers = beers -1


HOWEVER,

When you get down to 1 beer, and drink a beer, it goes to -1.


Anyone know why???

Setting A Variable Thats Contained In A Variable
This might sound confusing but I am trying to reduce my lines of code by making it more effecient. I want to save the name of a variable into a variable so for example...

_root.number = 50;

_root.saveVariable = _root.number;

Now how do I change _root.number by only using _root.saveVariable?

I am thinking it has something to do with brackets or parenthesis. Any help is appreciated this has really been bugging me.

New Variable = Global Variable Not Working
Could someone please explain why, when I add var newArray = _global.nameA[0], and try to trace newArray, it returns undefined, but returns the correct variable with _global.nameA[0]?

ActionScript Code:
xmlData.onLoad = function(success) {
        if (success) {
            _root.showXML = this;
            var comp = xmlData.firstChild.firstChild.childNodes;
            _global.nameA = [];
            for (i=0; i<comp.length; i++) {
                _global.nameA[i] = this.firstChild.firstChild.firstChild.nodeValue;
        }
//var newArray = _global.nameA[0];
playButt.onRelease = function() {
    trace(_global.nameA[0]);
       //trace(newArray);

};
Many thanks in advance

Dynamic Text Variable Variable
Hello,
I have a movie which loads data from a text file into flash (-no problem there).
The twist to this is that one of the fields in my movie loads text into fields from a text file which looks similar to the example below:
myText_district=109
&myText_Ian=189
&myText_Dave=8
&myText_Ray=14

If I select a specific field in my flash movie and put for example" myText_Ian" as my Var in the properties panel I have no problem getting the "109" to echo at runtime.

But what I would like to do is specify the Var in the properties panel as something like:

"myText"+_root.managername

and still get the same result. You see, I want to define the variable "managername" at runtime in a field so that if I type for example "Dave" in the field the movie will substitute "Dave" in place of the variable "managername" all throughout my actionscript and thus retrieve only info applicable to "Dave".
The biggest problem for me is that I am stuck with the property panel because I can't apply actionscript directly to a dynamic textfield.

Is there a syntax that I can use in the Var field of the property panel to get the result I want; to get the variable equivalent to "myText"+_root.managername?

OR

Is there an example somone can show me on how to load variables from a text file into a SPECIFIC dynamic text field completely in action script?

Any help is greatly appreciated.

If Variable=variable Simple Problem
Ok i'm having this problem;i have tried a lot of times to try to find what is wrong but could not;it looks pretty simple though but i'm a newbie;

here is the situation:
I have 2 buttons:
-Next page
-Previous page

a dynamic text box where i load an external text;it is called "contents"(the var).

my "Previous page" button works fine while i'm having problem with my "next page" button.

I use loadVariablesNum("../texts/"+pagenum+".txt", 0);
So that when i press on
next page" button;the pagenum is incremented and it loads 1.txt , 2.txt ,etc...(where in each text; "contents" variable is loaded).

I also use a variable(lastpage) so that to stop the "next page" button to go further than the last page.

I load the lastpage variable value from an external text too.

here is the code the "next page" button:

on (release) {
if (pagenum=lastpage) {
break;
} else {
pagenum = pagenum+1;
loadVariablesNum("../texts/"+pagenum+".txt", 0);
}
}


The "next page" button doesn't stop when pagenum=lastpage.

Any idea why? thanks in advance

If Variable=variable Simple Problem
Ok i'm having this problem;i have tried a lot of times to try to find what is wrong but could not;it looks pretty simple though but i'm a newbie;

here is the situation:
I have 2 buttons:
-Next page
-Previous page

a dynamic text box where i load an external text;it is called "contents"(the var).

my "Previous page" button works fine while i'm having problem with my "next page" button.

I use loadVariablesNum("../texts/"+pagenum+".txt", 0);
So that when i press on
next page" button;the pagenum is incremented and it loads 1.txt , 2.txt ,etc...(where in each text; "contents" variable is loaded).

I also use a variable(lastpage) so that to stop the "next page" button to go further than the last page.

I load the lastpage variable value from an external text too.

here is the code the "next page" button:

on (release) {
if (pagenum=lastpage) {
break;
} else {
pagenum = pagenum+1;
loadVariablesNum("../texts/"+pagenum+".txt", 0);
}
}


The "next page" button doesn't stop when pagenum=lastpage.

Any idea why? thanks in advance

Set Variable >> Push Variable Into Another Clip?
I am using set variable to create a variable name on the fly, but would like to push the variable into another clip so it isn't sitting on root. I have tried: databox.set(name, value); but it breaks the script. If I remove the "databox." then I am stuck with the value on root - anyone know a way around this? Thanks!

For Command And Variable Variable Names
i have a small 5x6 matrix of textboxes with var names in this scheme
11 means first row first column
12 means first row second column
34 means third row fourth column...

i wanted to create a reset function to set them equal to 100 times the row number

i am not very fluent in actionscript, but i know a little, i tried to fill in with psudeo-PHP style coding, and came up with this.

CODE//create a var "hundred"
var hundred = 0;
//define function
function reset(){
//for each column
    for(y=1;y<=5;y++){
//set hundred equal to 100 times the column number
        hundred = 100*y;
//for each row
        for(x=1;x<=6;x++){
//set the variable that has var x as the first digit and var y
//as the second digit equal to the current value of the var hundred...
//in php ${$x.$y} = $hundred
            {x+y} = hundred;
        }
    }
}
//apply the function
reset();

Copyright © 2005-08 www.BigResource.com, All rights reserved