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








Making The Fisrt Part Of ".something" Variable?


It looks like a lot of code but its not that tough!

I want tobuild random green boxes in my .fla...
ive got this:
FRAME1
depth=10;
i=0;
k=1;
FRAME2
obstacleN="obstacle"+i;
obstacle.duplicateMovieClip(obstacleN, depth);
i+=1;
depth+=10;
FRAME3
if(k<100) {
k+=1;
gotoAndPlay(2);
}
FRAME5
obstacle0._y=random(100)*5;
obstacle0._x=random(110)*5;

obstacle1._y=random(100)*5;
obstacle1._x=random(110)*5;

obstacle2._y=random(100)*5;
obstacle2._x=random(110)*5;

and its in frame 5 ive got the problem... ive just build 100 boxes, but its not fun to make the same code 100 times (and what if i want 1000 boxes!?) therefor I ask:
Is it posibble to make the "obstacle0" as a variable? so that frame5 would look like this:

"obstacle+var"._y=random(100)*5
"obstacle+var"._y=random(110)*5

and FRAME6 like this
if (var<100)
var+=1;
gotoAndPlay(5);


Thanks in advance
-Hashmus-




FlashKit > Flash Help > Flash Newbies
Posted on: 09-23-2003, 04:53 PM


View Complete Forum Thread with Replies

Sponsored Links:

Making Part Of A Filename A Variable?
Hey all,

I'll keep this short: how do you make part of filename a variable (to later be displayed in a textbox)?

I ask this because I want to have a slide-show of sorts that is easily maintained and updated by the addition and re-naming of image files. For example, by calling a file "picture1.jpg" it will be displayed as "picture1" in the flash file.

I know there are some commands the exist for separating strings into smaller sections (words or letters) But I want to know is there a way of saying "make everything after the / symbol a variable and cut off the filename"? So if you placed that picture.jpg in folder so the filepath looked something like this "/images/beach/image1.jpg" it would return the variable "image1"?

Thanks for your time.

View Replies !    View Related
My Fisrt Homemade Component
well it's not great

it's a box component that can be used then opening a window in a webpage...or for a button.

well errrr....just look

View Replies !    View Related
My Fisrt Homemade Component
well it's not great

it's a box component that can be used then opening a window in a webpage...or for a button.

well errrr....just look

View Replies !    View Related
Making A Mouse Part 2
OK i can now see my animation instead of my mouse thanks to joejoe2288 next i would like it to show a small animation when you left click then go back to the original animation how do i equip the the animation on the left click?

View Replies !    View Related
Making Part Of A Line Look Closer
Ok, well, here is what i am trying to do.

I have three boxes in a row, each box is connected to the box next to it by a line.

Randomly a user will select one. And when they do select one that box will then enlarge.

My problem, is that I would like the line to scale with it. However, since the line connects two boxes, one that is enlarged, and one that isn't, then one side of the line should be enlarged, while the other side should not. So it can give a sense of depth. Does that make sense?

I know I can easily make each box a mc and enlarge the mc dynamically with actionScript. However, I'm kind of lost on how to do the line. You can't just scale part of a movie clip can you? Perhaps make one side taller while the other side remains the same?

anyone have any ideas?

Thanks
tyler

View Replies !    View Related
Making Buttons Part Of A Movie
I have a set of buttons that I originally had just laid out on some layer.

I have rethought this approace and would like to place these buttons on a new layer, then place them all on a block (so to speak) to make them stand out from the rest of the screen. The entire block I have converted into a movie. Now, however, the actionscript I had assigned to my buttons does not work -- the sound bytes that were attached still play properly, but nothing else is functional.

Can someone help a newbie out? Thanks.

Oh yes, I was addressing my buttons in the following way:


Code:
on(click){
_global.player1Cash = _global.player1Cash + _global.player1Bet;
_global.player1Bet = 0;
_parent.updateBetWindow();
}


I have a feeling that _global is not getting the job done, but don't know where to go from here. Thanks in advance.

View Replies !    View Related
Making Part Of A Text Box A Different Color
I would like to have part of a dynamic text box be a color and another part be a different color....

Like heres a text box that contains
"Item $15"

I want "Item to be white and "$15" to be red.

View Replies !    View Related
Making Part Of A Movieclip Transparent?
I have a GIF file that I've made transparent background in photoshop and I want it to reflect the same thing in Flash, how do I do it? I get a black background in Flash, and for some reaosn I can't find any transparent background button... thanks!

View Replies !    View Related
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.

View Replies !    View Related
Making Image Move When Mouse Rolls Over A Part Of It
Ok, I cant get to grips with this.
if I have a long image, like, a room which is only partly visible, and i want to make the visitor navigate around in it, eg when they move the mouse to the left on the image, the image moves to the left, too.
and if the mouse is over the right part, the image moves to the right.
how does it work? please help, flash version 5 thanks for keeping me from madness.
S.D.

View Replies !    View Related
Part II Of My Tutorial: Making Nice Glowing Effect
Hi,

I've wrote the next tutorial and I hope it can help you.
http://www.bestcatalog.net/tutorial_...sh_part2_1.htm

Making Nice Glowing Effect and learning basic Flash techniques and ActionScript.
In this tutorial, you will learn how to work with rulers and guides, use oval tool to create effects for different parts of the image, adjust vector curves, use shape tween with radial gradient fills, create motion tween in combination with advanced color style for movie clips, use instance name and arrays to randomize the animation.

Your comments are welcome!
http://www.bestcatalog.net/tutorial_...sh_part2_1.htm

Thanks,
Eugene

View Replies !    View Related
[MX04] Making My Button Only Appear When Initial Part Is Selected
i have a button than expands when scrolled over. the only thing is that it appears when i go over any part where the rest of the animation is but i only want it to appear when the first part is scrolled over
anyone got any help

-bibby-

View Replies !    View Related
Making A Body Part Rotate And Move At The Same Time...
How can you make a body part -- say a arm -- move with the body and rotate at the same time, and with it the elbows rotating, too? Can this be done in with motion tweening?

View Replies !    View Related
Using % As Part Of A Variable Value
I am using an external file with values for text fields in my movie, but some of the values are statistics, that is I need to pull the precent sign from the text file, but evertime I put it in it just wont appear during the movie.

Is there a way around this? I cant have the % sign in movie sparately because the length of the text may change, and the sign would have to move accordingly, and also theres about 20 of these, so fancy scripting might be tedious to maintain.

There's gotta be a simple way to do this!

Can anyone please help?

Thanks

Simon H

View Replies !    View Related
Using Only Part Of A Variable Value
I have a variable in my Flash that relates to a date. The variable values are always in the form of mmyy. Therefore a value of 0407 refers to April 2007, a value of 0505 refers to May 2005, and so on.

I'm trying to figure out how to take the variable value and use only the first two digits to create a new variable with the value of the corresponding month.

So for example, say the original variable is:

issueDate = 0407

I would like to find a way to have actionscript take the first two digits in the value (04) and create a new variable (issueMonth) with the value of the corresponding month (April). So the final result would be:

issueMonth = "April"

That way, if the value of the issueDate variable was 0405, 0410, or 0420, the value of the new issueMonth variable would always just be April.

The whole point of this is so that I can take that original variable and create dynamic text like this:

confirmation.text = "Thank you for reading our" + issueMonth + "issue.";

Any help would really be appreciated.

View Replies !    View Related
How To Get Just Part Of A Variable
I have a movie that is passing the name of a movie clip to the _root. The problem is I can only get it to pass the entire name including the path by using this:

blueButton.onRelease = function() {
trace(this._parent);
}

it returns this:

_level0.scrollPane.spContentHolder.blue1


I would like to have it return this:
blue1 or even just 1

How can I do this?

View Replies !    View Related
Variable Part Of The Name
Hi guys i would like to make a variable called "i" part of the dynamic text field i'm creating by using: _root.createTextField("mytext",1,17.6,75,300,100);

this is so that when i put it in a loop with "i" begin the counter being added +1 at the end of the loop, a dynamic textfield is created everytime. Let's say i have a loop from 1 to 10, when the loop starts from 1, a dynamic text field called mytext1 is created and at the end of the loop i will end up with 10 text fields called: mytext1, mytext2 etc

Any help how to achieve this?

View Replies !    View Related
Remove Part Of A Variable
Hi....this is probably a newbie question...

this is the code i have so far


Code:
name = getProperty(this, _name);


this returns the value name1

how can i remove the text "name" from it so I'm just left with the 1

Any help would be much appreicated.

thanks

Rob

View Replies !    View Related
Is Using [i] In Variable Callouts Possible? (part 2)
I have posted the following question before:

ok, so I know that you can use [i] callouts in for or while loops where "i" is a variable number that increments such as in the following example

answerTxt0.text = test.childNodes[i].attributes.name;

but is it possible to do the same thing on the variable side?

if I was to create several variables like the following:
correct0 = "";
correct1 = "";
correct2 = "";
correct3 = "";
etc.

can I make a call in a for loop to have the variable name increment as well? (see the following)

correct[i] = question[i].attributes.correct;

if anyone knows if this is possible, or if there is a work around, please advise - it is very much appreciated.

This one line of code would save me over 40 lines of code.

Krilnon and Creatify were nice enough to help me and solve my problem:

Using '[i]' won't work, but something like this["correct"+i] = ""; would work, if this was indeed the correct scope.


The code above did work and greatly helped me. However, I have come into a second problem regarding the same issue. I am trying to replace the following code:

for (j = 0; j<answer.length; j++) { //Loads Available Answers into Corresponding Text Fields
if (j == 0) {
answerTxt0.text = test.childNodes[i].childNodes[j].attributes.name;
// answerTxt0 is a text field on the stage
} else if (j == 1) {
answerTxt1.text = test.childNodes[i].childNodes[j].attributes.name;
} else if (j == 2) {
answerTxt2.text = test.childNodes[i].childNodes[j].attributes.name;
} else if (j == 3) {
answerTxt3.text = test.childNodes[i].childNodes[j].attributes.name;
} else if (j == 4) {
answerTxt4.text = test.childNodes[i].childNodes[j].attributes.name;
} else if (j == 5) {
answerTxt5.text = test.childNodes[i].childNodes[j].attributes.name;
}
}

with this code:

for (j = 0; j<answer.length; j++) { //Loads Available Answers into Corresponding Text Fields
this["answerTxt" + j] = test.childNodes[i].childNodes[j].attributes.name;
trace("Text = " + this["answerTxt" + j]);
}

Now the weird thing here is that (using the trace) I am able to get the correct values the way I want them in the output window:

Text = Conus medullaris
Text = Anterior dorsal roots
Text = Cauda equina
Text = Filum terminal
Text =
Text =

However, they are not filling the text fields on the stage. Now, the only thing I can figure out here is that when I was able to get the tighter code to work before (see code answer above in blue), I was storing the values into a variable and now I am trying to store the values into dynamic text fields. Using the code above (with all the "if" statements) does work but I am trying to learn how to write cleaner and tighter code. Any help on this would be greatly appreciated!

Sorry for the long description... just trying to be as clear as possible.

View Replies !    View Related
Two Part Variable Name? (mx2004)
Okay so I am trying to make a crappy song player that lists the songs on stage using strictly code. My key problem is getting text to display the names of the songs. It doesn't seem to like 2 part variables. Here is what I have. The red seems to be where the problem is at, the blue is what I am essentially trying to do. The fla is at the bottom.

Code:
songArray = new Array("song1", "song2", "song3")
onLoad = function () {
for(i=0;i<3;i++){
a="myText"
attachMovie("song", "song"+i,i)
_root["song"+i]._x=275;
_root["song"+i]._y=125+(i*_root["song"+i]._height);
_root["song"+i].createTextField("songNameMc"+i, i, _root["song"+i]._x,
_root["song"+i]._y, _root["song"+i]._width, _root["song"+i]._height)

_root["song"+i]["songNameMc"+i].variable = a+i
(a+i)=songArray[i]

}
}

View Replies !    View Related
Left Part Of Content Out Of A Variable
Hi there,

I've a variable filled with the name of a flash file. The thing I want is retreave the name of the flash file without the extention .swf.

I tried:

lengthtotal = length(variable);
lengthnew = lengthtotal - 4;
newvar = left(variable, lengthnew);

But "Left(,)" doesn't seem to work. I've look all day for it in different kind of forums and I hope one of you can help me out.

Tnx

View Replies !    View Related
Use Variable As Part Of Function Name To Execute?
if I have an if/else tree that changes a _root variable, can I run a function using that variable as part of the name of the function to be run?

I have a card game with three automated computer players, and rather than have their actions be determined by the same exact same code duplicated for all three of them, with the only difference being 'P2' or 'P3' or 'P4' as the names of the variables in my if/else trees, I'd rather condense the code to one function and have the outcome be for whichever player it was that was checking his hand before 'deciding' what to do. So I'm trying to condense code.

Anyway, I have a function called P2checks(), but to determine if flash should run that program I have a function called P2holeRANK, with if/else tree that makes sure certain parameters are met before running P2checks(). So, the problem here is that I also have P3holeRANK, and P4holeRANK, as well as P3checks() and P4checks() - all with the same if/else tree and variables as P2checks(), but with the corresponding 'P' being different...

So, to bottle the ends, I'm making a function called analyzeHoleCards, that runs through all the same if/else trees. At the beginning of the function I say:


ActionScript Code:
function analyzeHoleCards(){
if (playerToAnalyze == 2) {
//use these cards in the following analysis
}else if (playerToAnalyze == 3){
//use THESE cards in the following analysis
}else if (playerToAnalyze ==4 ){
//use these cards in the following analysis
}
////then the analysis runs, checking the players hand, the size of any raises, the size of the pot, et cetera
////then the analysis comes up with a final recommendation
//ie, PXraises, or PXchecks, or PXcalls, or PX folds
///these correspond to P2raises, or P3calls
////and here's what I'm really asking (finally)...
////I want to go:
if (playerToAnalyze == 2){
P2FINALRECOMMENDATION;
}else if (playerToAnalyze == 3){
P3FINALRECOMMENDATION;
}else if (playerToAnalyze == 4){
P4FINALRECOMMENDATION;
}
}
//where 'FINALRECOMMENDATION' is a text string of either: 'checks', 'calls', 'raises', 'folds'

so basically, if playerToAnalyze was 2, I want to run 'analyzeHoleCards', which will then see that P2 is being analyzed and run the analysis, and then when it's made it's recommendation, I want that to be a text string that gets added to 'P2' so that it becomes 'P2checks' or 'P2raises' - and then RUN that function (functions I've already created...)

is that possible, or when you run a function does it have to be run using ironclad text/name to fire it?

very sorry for the long-winded explanation, but I want to make sure you have all the info. Thanks in advance for any help!

View Replies !    View Related
Putting Part Of Instance Name In A Variable
I have some movie clip instances called slice1, slice2, slice3, etc...

I am trying to figure out how to extrapolate the number from the instance name and put it into a variable.

Anybody have any ideas?

View Replies !    View Related
Create Variable With An Argument As Part Of The Name
Sorry for the completely uninformed question, but I'm trying to create a variable with a function that passes part of the variable name by an argument like this:



Code:
function doit(testvar:Object):void {
var this["mc_"+testvar] = "Overview";
}
doit("test");
In this example, I'm trying to create a variable called mc_test but this doesn't work. to my understanding this["mc_"+testvar] will create a string of "mc_test" but I can't set that string as a variable name.

Any help would be greatly appreciated.

View Replies !    View Related
Grabbing Part Of An Instance Name And Using As A Variable
Hello again Gurus,

I have 36 buttons on my stage that are named [thumbBut0, thumbBut1, thumbBut2,..., thumbBut35]. Each button is a thumbnail image. I want to have it so that when the user clicks on a given thumbnail, the full-sized image corresponding to the thumbnail gets loaded and viewed...yada, yada, yada... So, if the user clicks on thumbBut25, the 25th image gets viewed...

My question: is there some cool way that I could avoid writing 36 different (although they would be similar) "_level0.thumbButXX.onRelease = function()..." type things for each of the 36 buttons. In other words, when the user clicks the instance "thumbBut25" something grabs the "25" part out of the instance name, converts it to an integer, and passes it on to a function that loads up the image that corresponds to "25"?

My brain just can't get a grip on how one would do this. Any help would be appreciated, as always.

View Replies !    View Related
Path To MoveClip With A Variable As Part Of It?
Is to even possible target something on the stage by using a variable as part of the path.

For example, I've got an item in my library, class of 'star'. I add a couple instances of it to the stage and then I want to do something to 1 of them. The one that is selected is determined by a variable.

Perhaps a (non working) code example will give a clearer picture:

ActionScript Code:
var starMC1:star = new star();var starMC2:star = new star();var foo:Number = 2;addChild(starMC1);addChild(starMC2);starMC1.x = 50;starMC[foo].y = 40


- obviously, this code doesn't work or I wouldn't be posting. But is there some way do this?

Thanks for any help

View Replies !    View Related
Create Variable With An Argument As Part Of The Name
Sorry for the completely uninformed question, but I'm trying to create a variable with a function that passes part of the variable name by an argument like this:


Code:

function doit(testvar:Object):void {
   var this["mc_"+testvar] = "Overview";
}
doit("test");


In this example, I'm trying to create a variable called mc_test but this doesn't work. to my understanding this["mc_"+testvar] will create a string of "mc_test" but I can't set that string as a variable name.

Any help would be greatly appreciated.

View Replies !    View Related
Two Part Question Involving Colors And MC Variable Passing
Hi everyone,
first let me set the "Stage" if you will...

I have two movie clips on the stage, one of which is called "shoe", and the other is "swatch".

the shoe instance has a shoe in it, each seperate part of the shoe separated into movieclips with their own instance names (tongue, laces, etc).

So when the user clicks on a part of the shoe, the swatch appears (swatch was always there, but it was held on an empty frame until user selected a shoe part).

My goal is for the user to be able to pick different parts of the shoe and change its colors.

So, I created a variable called "shoepart" that gets set to the instance name every time someone clicks a part of the shoe:
code:
shoepart = "swoosh";


The purpose of me doing this is that I intend on passing shoepart to the swatch movieclip, so that it knows which movieclip to affect in "shoe."
However, this will only work if I hardcode the instance name of "swoosh" into the code, as shown below (ignore the if statement for now):
code:
on (release) {
if (shoepart == "swoosh"){
var colorful = new Color("_root.shoe.swoosh");
colorful.setRGB(0xFF3355);

}

else
{
shoepart = "swoosh"}

}

What I would like to do is have it do something like this:
code:
on (release) {
var colorful = new Color("_root.shoe.shoepart");
colorful.setRGB(0xFF3355);


However, since I'm mixing variables into the dot notation, I think AS doesn't really know if it's looking for a variable or an instance name...? Or perhaps I'm using the wrong syntax in the parameters? If I could get this to work, all I would have to do is make sure the variable gets set every time the user clicks on a different part of the shoe so that they can change the color of it.

Also, for part two of my question, I would really like this only to change the FILL color of the movieclip -- as they are now, they are white with black stroke. When I click on the swatch, it changes the stroke and the fill to one color.

thanks for reading this long winded thread!

View Replies !    View Related
Loop One Part Of A Movie For Ever And Stop Another Part
does anybody know how to make a bit of my flash movie loop continously but another bit of it stops

View Replies !    View Related
Variable++ How To Call A Vairable That Is Part Of A Incramenting ["varname"+i] I++ Pl
ok i have these buttons that are created using
Code:
attachMovie("btn",["btn"+i], getNextHighestDepth(), {_x: btnx, _y: btny, _width: 100, _height: 20});
so they show up and work just fine having the names btn1 , btn2, etc.
but how do i call them and set their properties as i go ?
like ["btn"+i].btntext.text = somevar; ... each button is just a sqare with a text feild inside that is called btntext so i can easily set the text to something using btn0.btntext.text ="thistext"; but since ill be asigning dynamic data to each button i need a way to call them ?? anyone have any ideas ? maybe break the var into a array ?

View Replies !    View Related
Making A Movie A Variable?
there is a ray of light movie at
http://www.flashkit.com/movies/Effec...31/index.shtml

that has a movie instance as a variable.. I was wondering where you define these variables?

(Flash 5)

Thanks for any help =)

View Replies !    View Related
Dynamically Making A Variable Name
I know this is probably easy but...

How can I make a literal "myVariable" be made into a variable name such that ( is the word recast?) my script thinks it is not a literal but in fact a variable name so it can reference the contents of variable data loaded from the text file with the line &myVariable=Apple

The end result should be that my manufactured variable name now points to the data referenced in the loaded file.

View Replies !    View Related
Making A Variable Global
I know this is a simple issue, I am just confused at this point and need some assistance. How do I get this variable inside the loop (hexColor) to be global? Thanks in advance :D







Attach Code

hexColor = "000000";
_global.hierarchy_xml = new XML();
_global.hierarchy_xml.ignoreWhite = true;
_global.hierarchy_xml.onLoad = function(success)
{
if (success)
{
rankCount = String(hierarchy_xml.firstChild.childNodes.length);
_global.ranks = new Array();
for(var i=1; i<rankCount; i++)
{
iconName = String(hierarchy_xml.firstChild.childNodes[i].childNodes[1].firstChild);
descriptionText = String(hierarchy_xml.firstChild.childNodes[i].childNodes[2].firstChild);
hexColor = String(hierarchy_xml.firstChild.childNodes[i].childNodes[3].firstChild);
if (descriptionText=="null")
{
descriptionText="";
}
_global.ranks.push (iconName);
_root.legend.ranks["rank"+i]._iconName = iconName;
_root.legend.ranks["rank"+i]._description = descriptionText;
_root.legend.ranks["rank"+i].moreDownline._visible = 0;

MovieClip.prototype.setRGB = function(newColor)
{
(new Color(this)).setRGB(newColor);
}

//var setColor:String = ("0x"+hexColor);
//var nhexColor:Number = parseInt(setColor, 16);
//_root.shirt.test.shirt[i].setRGB(nhexColor);
//trace (hexColor);
-----> hexColor[i] = hexColor;

}

_global.numIcons = (hierarchy_xml.firstChild.childNodes.length) - 1;
_root.legend.ranks.gotoAndStop (numIcons);

helptext = String(hierarchy_xml.firstChild.firstChild.firstChild);
//_root.helpScreen.helptext = helptext;

}
else
{
output ("error loading ranks");
}
_global.tree_xml.load(treePath);
}

-----> trace (hexColor[1]);

View Replies !    View Related
Making A Variable Available Outside A Function
Basically I'm trying to load a variable from an external file and then make that variable available for anything.

Code:
var where;
locSource = new LoadVars ();
locSource.load("source.txt");
locSource.onLoad = function () {
where = this.loc;
}
trace (where);
I've tried all the variations of this I can think of. I've defined "where" as a global variable both outside and inside the function, tried to define a separate global value within the function (and changed the syntax of the trace accordingly in either case), nothing works. Basically, the function is being loaded properly; if I put the trace inside the function it shows up perfectly, but the variable isn't available for anything else, which is what I need to happen. Any ideas?

View Replies !    View Related
Making Filename A Variable
Hi all,

Does anyone one know if it's possible to have AS take the filename of itself and make it a variable. I need it to be done by AS only. I know it's possible in PHP, but I'm not sure about AS.

I'm guessing if it's possible it's one line of code.

I'm using Flash 8 but publishing at Flash 6, AS 2.

Thanks in advance,
Bret

View Replies !    View Related
Making A Variable Name Variable...
I have a situation where I have buttons on my root that are pushing variable text to a dynamic text field in a movie clip. I am doing that with this type of approach:

code:
on (release) {
moviecliptxtbox= button01txt;
}


In the movie clip, the user will be able to edit the text in the dynamic text field. When they are done, I want them to be able to put the updated text back to the original variable. I have a button in the movie clip that should push the new text back, but it needs to be able to do that for multiple buttons. I am stuck on how to "nest" the original variable name (in this case, "button01txt") into a variable so that the new text is sent back to it. In other words, something like this would be attached to the movie clip button:

code:
on (release) {
last root button clicked = moviecliptxtbox;
}


Any help would be very appreciated.

View Replies !    View Related
Making A Variable With A Variable Name
Hey, this is proboly another easy question. How do a make a variable with a variable name?


Code:
for(var tempX=0; tempX<15; tempX++){
for(var tempY=0; tempY<15; tempY++){
var "tile" + tempX + "_" + tempY:Tile = new Tile(gridOffset + (tempX * tileSize), gridOffset + (tempY * tileSize), tileSize, tileSize, "");
}
}

View Replies !    View Related
Making A Instance Names Variable
Ok, so I want to have my flash app dynamically create movie clips using the duplicateMC command and then change the contents of each movie clip (ie mc1.textvar="ABC" mc2.textvar="XYZ").

I have no probs if I hardcode the number of movie clips, but I want to make it dynamic (will be setting variables outside of flash)

Attached to a button in the root level I want to do something like

for i=1 to NumMoviesVar
myclipTemplat.duplicatemovieclip("myclip"+i,1);
myclip[i].textvar="This is clip" + i
next

Another button would then go through and hide all of the dynamically created movie clips.

Is there any way I can reference the instance name in a "variable" sort of way with this pseudo array? Or is there a better way?

TIA
-Rob

View Replies !    View Related
Simple Q About Making A Score Variable
hi there

I have a problem with my score variable

Here is what i have :

scoreText - Dynamic text box
coin - movieclip
moneyBag - movieclip

i then have the following scrip in an "actions" movieclip on the scene

onClipEvent (enterFrame) {
_root.coin._y += 5 ;
if (_root.moneyBag.hitTest(_root.coin)) {
_root.moneyBag._x += 10;
scoreText = Score+=10
}
}

and i have the following in the first frame of the scene
Score = 0;
scoreText = Score;


I think there is something wrong with where i define my variables bust have tried moving it around but does not seem to work

well hope someone can help i think it is a simple answer but i just cant seem to get it to work

thanks

moo

View Replies !    View Related
Making A Function Run When A Variable Is Changed.
Code:
//==============================================================================================//
//Create Local Connection with other SWF's
//==============================================================================================//
_global.topmenu_lc = new LocalConnection();
_global.topmenu_lc.GetMenuArea = function(param) {
XMLMenu = param;
};
_global.topmenu_lc.connect("incoming");
//
//==============================================================================================//
//Master Variables at beginning runtime.
//==============================================================================================//
XMLMenu = "soo.xml";

What I need is an efficient method to watch the XMLMenu variable so that when it is changed...... it will run this function.


Code:
//==============================================================================================//
//Rebuild Menu Fuction
//==============================================================================================//
MovieClip.prototype.RebuildMenu = function() {
//
this.LastMainButton = this.menuItems_arr.length;
this.ResetButton = this.LastMainButton-1;
// ---------- Loop all the Main Buttons Shut
for (var k = 0; k<Number(this.LastMainButton); k++) {
var ObjectPath = this["MainButton"+k];
var twnobj = ObjectPath;
var twnprop = "_y";
var twnbegin = ObjectPath._y;
var twnfinish = ObjectPath.MainBtnOrigin;
this.PositionMainButton_twn = new Tween(twnobj, twnprop, TT, twnbegin, twnfinish, Speed);
this.PositionMainButton_twn.stop();
this.PositionMainButton_twn.continueTo(twnfinish);
this.PositionMainButton_twn.addListener(ObjectPath);
if (k<Number(this.ResetButton)) {
ObjectPath.onMotionFinished = function() {
this.removeMovieClip();
};
} else {
ObjectPath.onMotionFinished = function() {
getXML(XMLMenu);
};
}
}
};
//
As soon as this swf file is sent a new variable via the Local connection I want it to automatically rebuild the menu. Really need to try and sort this out ASAP so help is appreciated guys.

View Replies !    View Related
Help Making A Variable Into An Expression Without _root
Hi there, hopefully someone can solve this little problem. I have a movie clip called "radio". In it, I need to call a variable from the main timeline called "thisAnswer". This is the code I used:

var theFrame = _currentframe+("/thisAnswer");

The idea is to move to the current frame plus the answer to the last question (represented by the variable thisAnswer). However, the code above here does not seem to work, I'm guessing because it does not come in as an expression. The simple solution would be this:

var theFrame = _currentframe+(_root.thisAnswer);

Which works correctly, however because I am ebedding this file into another .swf file several layers deep, the root gets all screwed up. I have tried messing with absolute notation in the main movie to solve it, but have not been successful. I'm running MX, so _lockroot is not an option yet.

I guess I'm looking for a way to convert thisAnswer into an expression, or a way to call it out from the main timeline so that it works like the _root.thisAnswer code. Whatever solves the problem.

Thank you in advance for your help.

Darren
var theFrame = _currentframe+(_root.thisAnswer);

View Replies !    View Related
Making A Button Appear Based On A Variable
Hi,

I'm just wondering if it's possible to actually make a button appear based on a variable.

So lets say if _root.mybttn = 1 the button will appear, and if it = 0 it won't.

If it is possible, how would I go about doing this? Should it be the frame at which the button should appear? Or in the button itself?

Also, what command should I use to make it appear/not appear?

Thanks.

View Replies !    View Related
Making A Imported Variable ( From Php ) Into A Number
hey

Quick question...
im importing a few variables with this

Code:
myVars = new LoadVars();
myVars.load("getinfo.php?user1="+userN+"&pass45="+passN+"&random="+refresh1,"0");
myVars.onLoad = function() {
_root.cash=myVars.balance;
....
thats all working good ..
but now how do i make a variable say...
_root.cash
into a a number which can be used in equations or used for logical compariosons such as < > ==
thank you

View Replies !    View Related
Making A Imported Variable ( From Php ) Into A Number
hey

Quick question...
im importing a few variables with this

Code:
myVars = new LoadVars();
myVars.load("getinfo.php?user1="+userN+"&pass45="+passN+"&random="+refresh1,"0");
myVars.onLoad = function() {
_root.cash=myVars.balance;
....
thats all working good ..
but now how do i make a variable say...
_root.cash
into a a number which can be used in equations or used for logical compariosons such as < > ==
thank you

View Replies !    View Related
Setting A Variable Is Making The Text Box Go .. Blank?
Hi everyone. So it's my first attempt at ActionScript. I've used flash since it was good old FutureSplash animator but scripting has always frightened me. Here goes:

I'm wanting to create a dynamic menu system in Flash, where it will load the main sections and sub-sections from an array.

As part of making it, I'm just testing out what I know (or don't know) first about ActionScript. The problem I've come across is that setting a variable appears to completely blank my dynamic text box.

I created a new movie and placed an dynamic text box on it, with variable name "test1". By default the text in the box is "Hello". Test movie, yep, it comes up fine; "Hello" in the text box. So then in the actions for the first frame, I place the line:

test1 = "Goodbye";

But when I test the movie it just makes the dynamic text field to blank. Nowt. Nothing at all. If I uncomment the line and re-test the movie, "Hello"'s back again.

Can anyone explain why this is happening? I'm sure it's something simple I'm not doing/doing wrong.

Thanx.

View Replies !    View Related
Need A Loop For Making Sure External Variable Has Loaded.
Im not sure what im doing wrong here, ive tried while loops (which just hang the browser). Basically i got it all set up to work, and the script works fine. The problem is i have to click twice to make the button work correctly because the vars havent loaded before they are used. I cant preload them because its coming from a database and is based off input from the user on the flash form.

Any suggestions would be very appericated. Thanks.


Code:
loadVariablesNum("login.php", 0, "POST");
login_status = php_message;

if (login_status == "1") {
//login successful
tempString ="Welcome guest.";
}
else {
//login failed
tempString="Access denied";
msgbox.play();

}

View Replies !    View Related
Having Trouble Making A Variable That Points To An Object
ok in actionscript 1.0, you could make a pointer to an object by typing


Code:
p = _root.player;



I tried something like this in a flash 8 class definition but failed

Code:
private var p = _root.player;


THis isn't working. What am I doing wrong here? How can I define a variable to point to an object like I could so easily do in AS 1.0?

View Replies !    View Related
Making A Button Invisible Using It's Instance Thru A Variable..
I am just trying to make a button disappear using a variable set to it's instance name. When i say invisible i also mean deactivated.

The code i've got is this..


Code:
[test]_visible = false;
but it doesn't work - any offers?

Thanks

:to:

View Replies !    View Related
Making A Button Invisible According To Incremented Variable
Hi, I am trying to make a button invisible once a variable reaches a certain number.

Here's my code ::
Code:
if (idx > ((_root.vars2.countImages)-2)){
_root.moreMC._visible = false;
}
else {
_root.moreMC._visible = true;
}
can anyone see any problems with this code? No matter what I try, it doesn't work.

thanks

View Replies !    View Related
Making A Button Invisible Using It's Instance In A Variable
I am just trying to make a button disappear using a variable set to it's instance name. When i say invisible i also mean deactivated.

The code i've got is this..


Code:
[test]_visible = false;
but it doesn't work - any offers?

Thanks

View Replies !    View Related
Play 1st Part, Preload 2nd Part, Play 2nd Part: Possible?
I've recently started with Flash development and I was wondering if the following was possible using only one Flash file?

- The first part is shown and the user can click a button here to continue.
- When he clicks the button, a preloader part is shown and the rest of the file is loaded.
- When it's done, the rest is shown.

I already have the parts seperated in movieclips and unchecked the "export in first frame" option on the movieclips for the second part, but that doesn't help.

If this isn't possible, how should I go about it then? Should I use a second .swf which I load with a loadMovie statement?

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