Variables/arrays Assigned As Instance Names?
Hi,
I am using Flash MX 2004 Professional. I have a question about using arrays and variables as instance names. Please review the code below:
Code: // Please be sure to add the Button Component onto the stage then // delete from the stage as we just need the Button Component // in our library.
// Numerical variables var myWpos = 146.9, myHpos = 22.0; var myXpos = 14.4;
// Arrays var btnName:Array = new Array(); btnName[0] = "btnOne"; btnName[1] = "btnTwo"; btnName[2] = "btnThree";
var btnLabel:Array = new Array(); btnLabel[0] = "One"; btnLabel[1] = "Two"; btnLabel[2] = "Three";
var colorTheme:Array = new Array(); colorTheme[0] = "0x00CCFF"; colorTheme[1] = "0x0000FF"; colorTheme[2] = "0xFFFF00";
import mx.controls.Button;
for (iNum = 0; iNum <=2; iNum++) { // This code below appears to work as the buttons appears on the stage. createClassObject(Button, btnName[iNum], iNum, {label:btnLabel[iNum]}); //The next three lines is where I am having problems with. btnName[iNum].setStyle("themeColor", colorTheme[iNum]); btnName[iNum].setSize(myWpos, myHpos); btnName[iNum]._x = myXpos; //trace(btnName[iNum]); }
What I am trying to accomplish here is to use arrays to assign instance names, labels and color themes to my buttons.
The for loop is used to create the buttons and change the properties of my buttons. Instead of doing it the long and drawn way (listed below), I thought one for loop would make life easier.
Code: /* // Create Button #1 createClassObject(Button, "btnHorizon", 1, {label:"Horizon"}); btnHorizon.setStyle("themeColor", 0x00CCFF); btnHorizon.setSize(myWpos, myHpos); btnHorizon._x = myXpos; btnHorizon._y = 103.3;
// Create Button #2 createClassObject(Button, "btnValidation", 2, {label:"Concept Validation"}); btnValidation.setStyle("themeColor", 0x0000FF); btnValidation.setSize(myWpos, myHpos); btnValidation._x = myXpos; btnValidation._y = btnHorizon._y + 24;
// Create Button #3 createClassObject(Button, "btnAssessment", 3, {label:"Concept Assessment"}); btnAssessment.setStyle("themeColor", 0xFFFF00); btnAssessment.setSize(myWpos, myHpos); btnAssessment._x = myXpos; btnAssessment._y = btnValidation._y + 24; */
Can arrays and variables be used as instance names as well as other methods to modify changes to properties?
Any help you can provide would be greatly appreciated.
Thanks,
- Alex
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-17-2005, 08:24 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Using Arrays For Instance Names
How do I use Arrays for Instance Names?
If i put, for example "Button[0]" as Instance Name Flash tells me that I'm not using valid characters.
Using Arrays To Store Instance Names ...
can u use arrays to store instance names?
in more depth, heres the question:
I am using Flash to dynamically create containers with the createEmtpyMovieClip function. Within this function, I name the containers. The idea is that the user can hit buttons and create as many different containers as they want on the screen, position them, size them, and overlap them as needed.
I want to be able to create a group of standard controls that I can apply to any of these containers when they are selected. These controls change the scale, x and y position, and z level of the selected movie clip.
I'm approaching this by storing the information for each movie clip as it is created in an array. The problem with this is trying to get the information out of the array to use with each new function. Example:
If I write,
info_array[x].changeScale();
It doesn't apply the change to the name in the array at x. Instead, it applies the change to a non-existent movie clip named "info_array[x]"
Also, if I write,
mc_for_change = info_array[x];
mc_for_change.changeScale();
it has the same problem.
What am I doing wrong? How can I get the information out of the array to use as the name of the movie clip instead of as a variable representing the name?
any help will help.
Thanks!
Using Arrays To Store Instance Names ...
can u use arrays to store instance names?
in more depth, heres the question:
I am using Flash to dynamically create containers with the createEmtpyMovieClip function. Within this function, I name the containers. The idea is that the user can hit buttons and create as many different containers as they want on the screen, position them, size them, and overlap them as needed.
I want to be able to create a group of standard controls that I can apply to any of these containers when they are selected. These controls change the scale, x and y position, and z level of the selected movie clip.
I'm approaching this by storing the information for each movie clip as it is created in an array. The problem with this is trying to get the information out of the array to use with each new function. Example:
If I write,
info_array[x].changeScale();
It doesn't apply the change to the name in the array at x. Instead, it applies the change to a non-existent movie clip named "info_array[x]"
Also, if I write,
mc_for_change = info_array[x];
mc_for_change.changeScale();
it has the same problem.
What am I doing wrong? How can I get the information out of the array to use as the name of the movie clip instead of as a variable representing the name?
any help will help.
Thanks!
Instance Names As Variables
I am trying to have one movie clip give a play command to another movie clip based on a variable set by the previously played movie clip. I can make it work when I put the instance name directly into the script. However, when I switch out the instance name for a variable name it does not work. Is it possible to use a variable in the place where an instance name would normally go? I have tried using Tell Target and dot syntax.
Variables And Instance Names
My movie sends data to the database if, and only if, the text is stored in an input text field labeled using the instance name (not the variable name). The fields are on separate frames and then shown altogether as a summary that can be printed. The only way I know how to do that is to label the input text boxes with the variable name. But if I have it labeled w/both the variable name and instance name, it won't send. If I get the user to enter data in the variable named boxes, how can I populate the summary where the text fields are labeled with the instance name?
Thanks
Variables From Instance Names
Hi, I'm trying to finish off a project for today, and I'm caught on this one last thing.
I'm trying to make a dynamic menu. There are 4 instances of the same 'button'. Actually a button inside a movie clip. Also in this movie clip is line of dynamic text that should hold the title of the button.
The variables that hold these titles ("but1", "but2", etc) are saved externally in a text file.
I can load the variables no problem. But how do I call up the variables into that piece of dynamic text?
The problem being, as it's an instance of the same button 4 times, I can't just call it directly. What I was thinking of doing was somehow calling on the instance name of that button ("but1" the same as the variable name) and using
-that- in the dynamic text. So whereever the text is (whether it's in "but1" or "but3") it will call up the appropriate variable according to the instance name of the movie clip it's inside...
... if that makes sense?
Problem being I don't know how to do that?
Any help would be great, thanks.
Variables Into Instance Names
Friends,
Let's say I have three variables:
x=1
y=2
z=3
I also have movieclips in the library called:
mc1
mc2
mc3
I want to attach them, but using a loop similar to the following but I'm not sure if it's possible or what the syntax looks like. Here's the theory:
_root.attachMovie("mc1"; "mc" + x; 50);
Would this attach an instance of mc1 and call that instance "mc1" on layer 50?
Thanks!!!
Instance Names As Variables?
Help please...
I have a textfield named myTextTx and a background that sits behind it named myTextGrow so I made the function below to trigger the myTextGrow effect to be used in a number of texts and backgrounds with my naming covention swapping the Tx and Grow parts of the instance names to trigger the right nnnGrow mc with the appropriate nnnTx textfield.
function txPulse() {
var fieldName = Selection.getFocus();
trace(fieldName);
var growName = fieldName.substring(0, fieldName.length-2)+"Grow";
growName.loopIt = true;
trace(growName); //show the correct instance name with target path
trace(growName.loopIt); //debug shows this as undefined, why?
growName.gotoAndPlay(30);
}
Any ideas why it doesn't work? The loopIt var is declared at the start of the nnnGrow MC and works because it stops at frame 29.
Thanks
Variables And Instance Names
I am trying to control my buttons using variables, but I'm not sure if this is right.
On button 1 I have this action:
Code:
on (release) {
portfolioselection = "Monkey"
this.enabled = false;
}
On button 2 I have this:
Code:
on (release) {
portfolioselection.enabled = true;
portfolioselection = "Thornwick"
this.enabled = false;
}
In theory, when Button 1 is clicked it should be disabled. When Button 2 is clicked it should be disabled, and Button 1 enabled. But this doesnt seem to work.
I'm not sure where I'm going wrong here. Am I targetting the variables incorrectly?
PS - I deffinatley need to use Variables because I have lots of buttons, this is just a simplified example.
Thanks,
Jamie
Variables And Instance Names
ok, so i have a little problem. I need to be able to access Dynamic Text boxes inside a loop. For example, assume that there are 6 dynamic text boxes with instance names option0, option1, option2, option3, option4, option5. How can I access them inside a loop? In shell scripting, you would use a '$' in this case.
for (int x = 0; x <= 5; x++)
{
//i need to control dynamic text boxes using the variable x,
//the first iteration would set the dynamic textbox with instance name,
//"option0" equal to "Hello", and so on
option$x.text = "Hello";
}
is such a thing possible?
Instance Names To Variables
Hi,
I'm very new to Flash and ActionScript, but I do have a background in programming server and client-side web applications, so at least I'm not completely clueless.
I'm trying to figure out when an Instance Name actually becomes available to the ActionScript, so I can modify it.
I've got a Movie Clip in Scene 1 -> Frame 10, in that Movie Clip, on Frame 10 I've got an empty Movie clip that I'm trying to load a .swf into. I can actually load the .swf into it if I put the code to load it into the same frame that I'm displaying the .swf in, but, I want it to be completely loaded before I move into that frame.
Through trial and error I actually managed to get it to act like I need by putting the instance in frame 1 and setting it's alpha to 0, so it isn't visble. That solution doesn't seem very portable to me.
Is there a "correct" way to load a file into a Movie Clip before it gets instantiated? Or, what are the various ways people work-around this issue? This "solution" I've found works in this particular case, but there are a few similar cases in this project where this would be just too cumbersome.
Thanks,
Chris
Variables As Instance Names
Hi,
I have created movie clips using loops that names them box1, box2, box3.... via
i = i + 1;
duplicateMovieClip (_root.box, "box" + i, i);
but i then want to edit a textbox which is rooted inside each movie but related to the movieclip just produced. so if box1 had just been produced then:
box1.textbox.text = " E cell = "+j+"V";
is done so effectively i am looking to do:
box+i.textbox.text = " E cell = "+j+"V";
but this doesnt work. Does anyone have any ideas how i can do this?
sorry if this is confusing.
Thank you.
Get Instance Names For Variables
Hi, people.
There's a way to get the instance name of objects/symbols for variables and use this in actions and/or functions?
[]'s
Edu
Mixing Variables With Instance Names
This should be an easy one cos I think I'm close already.
Basically, I want to loop through an array and call the same method for each button instance. So instead of hardcoding this:
Code:
sections_mc.section2.alphaTo(10,.5,"easeoutquad");
sections_mc.section3.alphaTo(10,.5,"easeoutquad");
sections_mc.section4.alphaTo(10,.5,"easeoutquad");
sections_mc.section5.alphaTo(10,.5,"easeoutquad");
sections_mc.section6.alphaTo(10,.5,"easeoutquad");
I can use something like this:
Code:
for (i=0; i < sectionArray.length; i++) {
sections_mc.section + sectionArray[i] + .alphaTo(10,.5,"easeoutquad");
}
I tried various things like concatenating the command and using eval:
Code:
eval("sections_mc.section" + sectionArray[i] + '.alphaTo(10,.5,"easeoutquad");';
However, none of my efforts worked.
Please could somebody help me?
Referring To Instance Names With Variables
I have the following problem. I have two movie clips with the instance
names inst01 and inst02.
I have the code :
_root.inst01._alpha += 10;
Now sometimes I would like it to be for "inst01" and others "inst02".
Is there a way that I can just say set a variable like :
currentinst = "inst01"
or
currentinst = "inst02"
And then write the code as:
_root.currentinst._alpha += 10;
Would this work, how would Flash know whether "currentinst" was an
instance name or a variable name?
THANK!
Tim
Tweens And Variables In Instance Names
So I have two questions that perhaps someone can help me with:
Q#1
I am using the tween class to change the alpha value of a MC upon rollOver and rollOut. To refine the effect, I assigned a variable to the MC's alpha value so if the mouse moves off the MC before it has reached 100% alpha, it wont start immediatly fading from 100%, but from the value it had reached before the user stopped the rollOver action. Unfortunately, when I leave my mouse over the MC until it goes to 100%, and then I wait a second or two, the alpha snaps back to 50% (the starting alpha value). I can't figure out why this keeps happening, but I have run into it with other projects and I surmise it is the way I am using the tween class. Below is the code I used to make this happen.
To see the problem, here is a link to the compiled file:
http://www.shawnpiper.com/23hoyt/gallerytest.html
// image 1 Set 2
groupA.group2.image1.onRelease = function() {
loadMovie("main_resized/1.jpg", pictureHolder);
pictureHolder._xscale = 100;
pictureHolder._yscale = 100;
var alpha:Tween = new Tween(pictureHolder, "_alpha", Strong.easeOut, 0, 100, 5, true);
};
groupA.group2.image1.onRollOver = function () {
var g:Number = groupA.group2.image1._alpha;
var alphatween:Tween = new Tween(groupA.group2.image1, "_alpha", Strong.easeOut, g, 100, 1, true);
}
groupA.group2.image1.onRollOut = function () {
var g:Number = groupA.group2.image1._alpha;
var alphatween:Tween = new Tween(groupA.group2.image1, "_alpha", Strong.easeOut, g, 50, 8, true);
}
Q#2
Is there a way to loop through the instance names of similarly named movieclips? For instance, if I have 10 buttons with the instance name btn1 through btn9 and I want to change a certain property on all of them, is there a way I can substitute a variable for the number and use a for loop to cycle through them?
Thanks everyone
Using Variables To Reference Instance Names..? How?
So here's what i'm trying to do.....in code form. Picture a blue box on the canvas called 'box1'. I'm going to attempt to make it invisible, by referencing the instance name put together by vars:
Code:
var myName:String = new String();
var myNum:String = new String();
var instanceName:String = new String();
var myName = "box";
var myNum = "1";
var instanceName = myName + myNum;
trace(instanceName); //looks ok...
instanceName.visible = false; //fails
Somehow I think i need to convert the final product (instanceName) into a data type flash will deal with for instance names... anyone able to make this kinda logic work? I'm stuck..
-Nate
Variables Using Instance Names And Text Boxes
OK, a tricky one this.
I have a movie clip. It has 21 frames (not important) but in each of these frames there is a button, and an action to take the variable from one text field ("status") and make it go to the frame in that movie clip with a label equal to the value in "status", and then that frame put the value of "status" into another text box.
The problem is, that the movie will eventually have 116 of these movie clips. Yes, a hundred and sixteen. So, the current method I am using requires me to replicate the contents of this movie clip 116 times (I can't just copy and paste the original clip, because each one has to write to a different text box!), so I thought there must be a way of just having one...right?
The idea I had was to make one movie clip, copy it 116 times, and give each one a different instance name. This would be g1, g2, g3...g116. Then, instead of this:
On (Press)
Go to and Stop (/:status)
End On
and also
Set Variable: "/:g1" = /:status (changing "g1" in every one...which is what I have currently been doing)
Couldn't I have one mc, copy it, and instead, I'd have this inside it:
Keep the button action:
On (Press)
Go to and Stop (/:status)
End On
but then in the frame, instead of
Set Variable: "/:g1" = /:status
I could have
Set Variable: /:_name = /:status
Where "_name" is the name of the INSTANCE for each MC. Is this possible? So I would end up with 116 of the same MC, each with different instance names, then have 116 text boxes with the same names of the instances.
When called, the Set Variable action will take the value of "status" and write it into the text field (in the main timeline) with the name equal to that of the MC instance.
I hope that makes sense.
Tne problem is that
Set Variable: /:_name = /:status
DOes not work. Nor do any variations of it. I think I mjst be doing something wrong, as it seems a perfectly logical way of doing things.
If I have to have 116 diffferent movie clips, hte movie size will be about 1.5MB!! With one copied 116 times, it will only be about 250 ish.
Any help, please?? Pretty urgent too, sorry!
If a reply is too complicated to explain here, then please email me (noodlesdunn@yahoo.com).
Thanks!!
Flash 5 - Storing Instance Names In Variables
Synopsis for those who don't like to read: I want to be able to store an instance name in a variable, and use the contents of that variable somehow in a path name. Help.
Description for those who like more detail: So I have nine instances of a movie clip, all with instance names, "one", "two", "three", and so on.
I have a function that detects which one of these has an alpha level of 0. This function returns a string, "one", "two", "three", and so on... depending on which one is blank.
I want to store the returned value of this function (a string) in a variable called blank. I then want to use that variable later on in a path to the detected instance...
Ex:
blank = detect_blank();
if (valid_move(this._name, blank))
{
//this is where i have problems
this._x = _root.blank._x;
this._y = _root.blank._y;
}
See, above, say that blank = "five". Well, ideally, in the path _root.blank._x, the variable blank would be replaced with the word "five" and everything would work (note that I have tried putting an actual instance name in place of blank and everything works fine...) Unfortunately this is not happening.
I'm pretty new to AS so I have no clue why this isn't working. Any ideas are extremely appreciated : )
Question About Movieclip Instance Names & Variables
i'm stumped with a problem.
i was wondering how flash read movieclip instance names when using variables.
just say i had a movie clip with an instance named "window" and wanted to access the visible property of it.
i know that window._visible would get it's property.
but what if i put the name of window into a variable, like test?
so if i did this:
var test = "window";
test._visible
would flash look for the proprety of a movie clip instance name called window ? or would it look for the property of a movie clip instance name called test?
Assigning Instance Names Via Variables For Duplicatemovieclips
G'day fellas.
Been crunching my brain at this one for quite some time. I've setup a loop using an array to duplicate a movieclip twice and for dragging. So they need instance names.
Code:
function duplicateClips() {
appCall = new Array("null", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
i = 1;
k = 2;
while (k<4) {
while (i<27) {
origAppleNum = ("app"+appCall[i]+(k-1));
newAppleNum = ("app"+appCall[i]+k);
duplicateMovieClip(eval(origAppleNum), eval(newAppleNum), k);
_root.eval(newAppleNum)._alpha = 50;
//trace(origAppleNum);
trace(newAppleNum);
i++;
}
k++;
//send through i loop again for k2
i = 1;
}
}
I know its messy but hopefully you can work it out.
the use of eval(newAppleNum) in duplicateMovieClip isn't working and setting it as undefined.
Any ideas?
Cheers guys.
Question About Using Variables Inside Of Instance Names
I am trying to make a random team selector using 8 different dynamic text boxes on the stage with instance names person0_txt, person1_txt .... person7_txt.
I am using a for loop to generate 8 random numbers and the floor method to keep them as whole number. Inside of the for loop i have a switch statement showing what will happen for the 8 possible values that can be returned.
However i am having problems trying to get the values to go into the correct boxes. You can see my code below:
ActionScript Code:
for(var i:uint = 0; i<8; i++){
var randomness:Number = Math.floor(Math.random() * 8);
switch(randomness){
case 0:
person+i+_txt.text = "Darren";
break;
case 1:
person+i+_txt.text = "Tom";
break;
case 2:
person+i+_txt.text = "Danny";
break;
case 3:
person+i+_txt.text = "Dave";
break;
case 4:
person+i+_txt.text = "Headley";
break;
case 5:
Person+i+_txt.text = "Aidan";
break;
case 6:
person+i+_txt.text = "Katie";
break;
case 7:
person+i+_txt.text = "Steve";
}
}
I am pretty sure the problem is in this line here
ActionScript Code:
person+i+_txt.text = "Darren";
as when i type it out like this
ActionScript Code:
person0_txt.text = "Darren";
it works without any problems but i do not know what i need to do to fix it.
Thankyou in advance
Darren Rutter
Problem With Dynamically-assigned Clip Names
Hi there
I'm using Flash Pro 8
I'm having a problem with the names of some button clips I'm creating at run-time in a clip called "_level0.buttHolder" - when i click on the buttons they all output the same name!
here's the function I use to make the clips and assign the names
PHP Code:
buttonArr = new Array("","Accueil","Editions","Travaux","Contact");
pageArr = new Array("","main.php","editions.php","travaux.php","contact.php");
numButts = 4;
offColour = "0x666666";
overColour = "0x9B8D3D";
baseX = 0;
baseY = 0;
startX = 0;
rootUrl = "";
offset = 0;
function makeButts(){
for(i=1;i<=_level0.numButts;i++){
// make outer button
var nameVar = _level0.buttonArr[i];
trace(nameVar);
_level0[nameVar + "But"] = _level0.buttHolder.createEmptyMovieClip(nameVar + "Clip",i);
//_level0[nameVar + "But"]._x = _level0.baseX + (i*110)-110;
_level0[nameVar + "But"]._y = _level0.baseY;
// Add text
_level0[nameVar + "But"].createTextField("butlabel",1,0,0,0,0);
_level0[nameVar + "But"].butlabel.autoSize = true;
_level0[nameVar + "But"].butlabel.text = nameVar;
_level0[nameVar + "But"].butlabel.selectable = false;
_level0[nameVar + "But"]._x = _level0.offset;
_level0.offset = _level0.baseX + _level0.offset + _level0[nameVar + "But"].butlabel._width + 10;
// make active button clip in layer 100
_level0[nameVar + "ButActive"] = _level0[nameVar + "But"].createEmptyMovieClip(nameVar + "Clip",100);
var X1 = 0;
var X2 = (_level0[nameVar + "But"].butlabel._width + 10);
var Y1 = 0;
var Y2 = 22;
_level0[nameVar + "ButActive"].moveTo(X1,Y1);
_level0[nameVar + "ButActive"].beginFill(_level0.offColour);
_level0[nameVar + "ButActive"].lineTo(X2,Y1);
_level0[nameVar + "ButActive"].lineTo(X2,Y2);
_level0[nameVar + "ButActive"].lineTo(X1,Y2);
_level0[nameVar + "ButActive"].lineTo(X1,Y1);
_level0[nameVar + "ButActive"].endFill();
_level0[nameVar + "ButActive"]._visible = false;
_level0[nameVar + "But"].hitArea = _level0[nameVar + "ButActive"];
_level0[nameVar + "But"].onRelease = function(){
trace(_level0[nameVar + "But"]._name);
}
}
}
// START FUNCTIONS
makeButts();
can anyone see the error in my actionscript ?
thanks for any help you can give
Route Problem With Dynamically Assigned Names
I control the size of "clip1" by pressing on it or by pressing "leftClip1".
PHP Code:
clip1.onPress = leftClip1.onPress=function () {
clip1._xscale = clip1._yscale=200;
};
clip1.onRelease = leftClip1.onRelease=function () {
clip1._xscale = clip1._yscale=100;
}
The problem occurs when I add more clips.
I've tried this and some variations but nothing seems to work.
PHP Code:
for (i=1; i<5; i++) {
this["clip"+i].onPress = this["leftClip"+i].onPress=function () {
this["clip"+i]._xscale = this["clip"+i]._yscale=200;
};
}
Thanks.
Instance Names...changing...or Addressing Txt Field Instance Based On Instance Of Mc
i'm creating a mail form, that has a text effect which displays the type of info to be entered in each input box. To create this effect, i had to assign the variable name txt to the input boxes as well as the instance name txtBox. each of these text fields is contained within a movieclip, each with a unique instance name. what i need to do, is somehow assign a value/variable to each text field to pass to PHP to generate an email. I have always used components for contact forms so i'm not sure how to make the switch, AND.. the script i use for my contact form is an EXTERNAL AS file. (i use a customized version of a contact form from www.actionscript-toolbox.com [which apparently is no longer Flash related site])
ok.. this is hard to explain..... so bear with me....
If my original mail form component instance names were: tiName, tiEmail, tiSubject and taMsg (ti for textInput and ta for textArea)
and my current instance names for the mc's which CONTAIN the input boxes (with txtBox textfield instance inside them) are: name_txt, email_txt, subject_txt & comments_txt...
how would i pass/convert the users input text in each movieclip's txtBox, into the original instance name for my mail form so i can continue to use the form/PHP i have been using??
OR....
how do i take the values input by the user in each txtBox (i.e name_txt.txtBox.insertedTextFromUser or name_txt.txt, email_txt.txtBox.insertedTextFromUser or email_txt.txt) and send them to a new PHP script to send mail??
please keep in mind i am PHP retarded... hence why i re-use the same form over and over..
thanks in advance for any help. it's greatly appreciated...
if you're confused about my problem, please let me know... i'm having a difficult time explaining....
Arrays Assigned Specific Links
I have an array that generates a list of words that have links to site/page. but for some reason the URLs are being assigned randomly and i need to them to be specific to each word. Any suggestions? thanks.
Code:
// que of fill requests
fillRequests = new Array();
var vernacular = "Breakthrough Democracy Afghan Style Dwell DesignSource EndresWare Microsoft Darwin Min Day Nolo Now Rob Craigie Personal Science Squid Lab Instructables";
//links for words
links = ["http://www.breakthroughcollaborative.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com","http://www.ask.com","http://www.yahoo.com","http://www.google.com"];
//array of words
wordList = new Array();
wordList = vernacular.split(" ");
// fill the page with words!
fillRegion(0,0,720,480);
this.onEnterFrame = function() {
// pull fill requests from que and execute
if (fillRequests.length>0) {
freq = fillRequests.pop();
fillRegion(freq.x0, freq.y0, freq.x1, freq.y1, freq.d);
}
}
function fillRegion(x0, y0, x1, y1, d) {
// pick one of the words and place
n = random(wordList.length);
word = wordList[n];
ahref = links[n];
trace(n+" "+ ahref + word)
// place the word object
nombre = "word"+String(depth++);
neo = this.attachMovie("mcWord", nombre, depth);
// set word
neo.setWord(word);
neo.fitInto(x0, y0, x1, y1, d);
}
function fillRegionRequest(x0, y0, x1, y1, d) {
// request has been made to recursively fill a region
// only allow if reasonable
rWidth = x1-x0;
rHeight = y1-y0;
if ((rWidth>2) && (rHeight>2)) {
addFillRequest(x0, y0, x1, y1, d+1);
//fillRegion(x0, y0, x1, y1, d+1);
}
}
function addFillRequest(x0, y0, x1, y1, d) {
// que up a request to fill a region
var freq = {x0:x0, y0:y0, x1:x1, y1:y1, d:d};
fillRequests.push(freq);
}
[Q] MovieClip Instance Name And The AttachMovie And The Function Assigned To It... :)
Hehe... Long long question...
Okay... This is not so much of how to question rather why question...
Let's say that I have a movieClip called tab_mc on the stage and in that movieClip, I have two frames... In frame 1, I have a movieClip called 'test_mc', and another 'test_mc' in frame 2 with different content or color...
On the main timeline, I have this function...
PHP Code:
this.tab_mc.test_mc.onPress = function ()
{
trace(this._name);
}
Now, I have a Key Listener which checks if '1' or '2' is pressed... If '1' is pressed, it will gotoAndStop() to frame 1, and '2' will gotoAndStop() to frame 2...
If I do not change the frame with '1' or '2' key, the onPress handler works fine... I get the trace() working fine...
But, as soon as I change the frame, onPress handler does not respond as a movieClip even if I assigned the same instance name 'test_mc' for both movieClips on each frames...
Does anybody know why it is not working???
The workaround would be using the attachMovie() function to attach the movieClip under the tab_mc and it did the job for me...
Take 2 Arrays (1 Of First Names And 1 Of Last Names), Then Combine The First And Last
Hi everyone. I'm totally new to actionscript and trying to do somethng simple but I just can't see where I'm wrong. I'm trying to take 2 arrays (1 of first names and 1 of last names), then combine the first and last names into a string, and push that string into another array as one index.
My loop seems to be working fine, except that when I trace the array after the function, it just shows the last name. I think this is because I am not pushing within the function?
Can someone advise me or show related examples???
Thanks!
Code:
var classFirsts:Array = ["Albert", "Amber", "Conway", "Danny (Shyang-Min)", "Darcy (Yun-Ching)", "Dongwoo", "Fiorella", "Jae Hwan", "Jie Yun", "Julia", "Justin", "Kane", "Kunal", "Michael", "Rohini", "Scott", "Thai"];
var classLasts:Array = ["Dang", "Krishan", "Liao", "Chang", "Wang", "Kim", "Gu", "Kim", "Roe", "Vallera", "Blinder", "Albarron","Patel", "Thibodeau", "Rathi", "Hartman", "Le"];
var numFirstNames:uint = classFirsts.length; //COUNTS NUMBER OF NAMES IN ARRAY
var ourClass:Array = new Array() ; //EMPTY ARRAY TO FILL WITH CLASS NAMES
function getFullName():String {
for (var i:uint = 0; i < numFirstNames; i++) {
var fullName:String = classFirsts[i] + " " + classLasts[i];
}
return fullName;
}
var fullName:String = getFullName();
ourClass.push (fullName);
trace(ourClass);
Dynamically Assigned Variables
Baesd on the the code below, for a popup window on a button click
on (release) {
getURL("javascript: void window.open('http://www.website.com/index.htm', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=500,height=250,left=312,t op=100');");
}
Id like to replace the path for 'http://www.website.com/index.htm' with the variable 'popUp',
and the window property code (the 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=500,height=250,left=312,t op=100')
with the variable 'windowProp'
I have both variables defined in an external XML doc, and successfully importing into the swf.
The variables are defined with the appropriate formatting for thier use, so that the 'popUp' variable returns an formatted absolute URL, and 'windowProp' variable returns a string like ''toolbar=0,scrollbars=0,location=0,statusbar=0,me nubar=0,resizable=0,width=500,height=250,left=312, top=100'
so in pseudo actionscript, the code example from above would logically be something like:
on (release) {
getURL("javascript: void window.open('popUp', '', 'windowProp);");
}
the issue is that the varibles, even thought they are importing the correct data, dont work as intended with the event.
Can anybody have an idea for the correct syntax/form? Im not sure how to strip these items together
thnx for reading - Mike Halak
Preserving Variables Assigned To XML Node....
sawatdee khrup...
I have an XML node which i assigned some variables to...
XMLnode.firstChild.myObj = {stepX:50, stepY:32, etc.};
XMLnode.firstChild.status = 2;
XMLnode.firstChild.history = [0,0,3,2,1];
once i duplicate the node, the associated variables and objects are not duplicated....
is there a workaround for that?
can i just get all values assigned to an object without knowing them?
for (var i in XMLnode)
doesnt get all the variables....
enlightment
Pippo
Trying To Click A Button And Make The Number Variables I Assigned Add Up In The Total
Hello all,
I received help with this when I coded it in 2.0 but need to move it to 3.0. Would appreciate any help at all. I am trying to click a button and make the number variables I assigned add up in the total txt field.
The 2.0 file delivers correctly but my 3.0 tells me I am not returning anything. Extremely new to AS3.0 but a complete believer.
Thanks everyone find files attached.
How To Get Button's Instance Name On Stage? OR Can A Button Ahve 2 Instance Names?
i have a button the the stage, with an instance name of: "butt1"
the button itself lives inside a movieclip, where it is called thisButton
when flash runs and I click the button I want to output the button's instance name on the stage (i.e. butt1) but i'm only getting the button's instance name in it's own movie
this._name gives me = thisButton
is the name i want stored in a separate property?
edit: sorry - i realise that the problem is that the button code is inside the mc itself, where the button's name is thisButton
Instance Names
in flash mx how do i go about assigning an instance name ?
Instance Names
How do you instance an external .swf file that is loaded through action script using:
Code:
loadMovieNum("Page_1.swf", 1)
Any help would be great.
Thanks,
ex
Instance Names
okay this is basic....i think.
the situation:
I've got a frogger type game. There are 3 goals at the top of the screen. I have a collision detection block of code that detects when the player hits the goal. (duh)
So the goals are 3 instances of the same movie clip from the library all with the same collision detection code in it with one difference, the instance name. The question is, I'd really like to have all three blocks have the same code to call the "game over" function. To do this I'd like all the goals to have the same instance name, however it dosen't seem this is possible. Am I missing something or will I have to edit the code to say goal1, goal2, goal3 etc?... thus resulting in a lot of redundancy.
Instance Names
Is there a way to set instance names on the fly.
Im calling mc's from my library and the there not keeping my instance names I gave them after I call them to the stage.
Thanks
Josh
Instance Names
Hi!
I'm working with loops and I use the attachMovie() function alot to put different thumbnails, buttons etc. on to the stage.
I have e.g. this code:
Quote:
for(i=1;i<=5;i++){
s="thumbnail"+i
trace(s)
trace(s._x)
It's not working to put together an instance name like this. I have also used the concat() function without any luck. Previously, I have use _root["thumbnail"+i], but this is complicated and doesn't work when i have several movies loaded into each other.
Does anybody knows how i can solve this problem?
Thanks alot!
Instance Names
HI, probably a simple question as I am a newbie, I have some text which loads from XML to form a menu. I have that working but with long code:
this.mc_buttons.mc_btn1.menutxt.text=titlearray[0];
I would like to loop through the array to populate the text rather than specifying it.
e.g.
this.mc_buttons.mc_btnj.menutxt.text=titlearray[j];
The problem I am having is adding the j variable to the end of the mc_btn1 instance name, I want it to be something like mc_btnj.
Does anyone know how I would do this? I do not really want to change the way I am doing the menu as it works fine, just this little problem to solve.
Thanks
Bex
Instance Names
ok, im new to flash and actionscript.
I have an movieclip that i want to duplicate but respect the same hit tests as the original. Looking through the help documentation in MX i see that instance names need to be "unique" to there objects this explains why im having problems. My question is, is there a special class or something that i can use in order to have multiple objects with the same instance name? or is there some other way i can do this without having to refer the hit test to seprate instance names?
Thanks
Instance Names
Well I have been working with flash on some games and a lot of them have the same issue. They have to have hit tests on a lot of the same library objects but becuase a instance name only works for one of them on the screne i was wondering if there was a way to make a peice of script work for all of that library object, a entire layer, or something along those lines without having to add in a different instance name for the dozens of the same library object it might hit.
Thanks a lot.
Instance Names
Hello.
I am currently building a menu (which i unfortunately can't paste the fla here) and was wondering if someone could give me a little advice. I have it set up that the movie will duplicate itself upon loading and therefore I can't select the multiple graphics while designing in flash because they technically dont exist yet...
What I need to know is how can I refer to "instance names" in a/s and tell it to load a specific movie on press/release on that instances graphic? It might be very simple but I can't seem to find the answer.
Please let me know if I'm not making myself clear and I might have to try to post my fla later then. Thank you very much.
Thanks.
Help With Instance Names.....
I have a movie clip within a button within another movie clip all have different instance names. Flash does not recognise the instance name of the movie clip within the button. Does anyone know why, and of a way around this if possible?
AS 3 Instance Names
I know that you can add a movie clip to the stage using the addChild() function but my question is how can you give a instance name to a dynamicly placed MovieClip?
Instance Names & AS
I was wondering if there was a way to classify multiple instant names under one variable.
For example
my_cities = atlanta, boston, tokyo, la
my_cities being the variable.
atlanta, boston, tokyo, la being the instant names.
Then...
my_cities._alpha = 50;
^ & all of the instant names under the variable "my_cities" would be effected. I could use some help on finding the right AS lingo to make this work.
I'm asking because I'm making a map with lot's little pin points where the cities are... & a super big time saver would be being able to affect all of those pin points (cities) at once.
- THANK YOU EVERYONE
Same Instance Names?
I'm loading a movie clip onto my stage through xml (a dot). When it does this, it also creates a small list on the side. The user can rollover the different items in the list and the corresponding dot lights up. Here's my problem. Some list items need several dots. I have it working as far as putting the multiple dots on the stage, however, on the list rollover part I'm having issues.
When the list item should have multiple dots, I am making those dots have the same instance name. I then have a function tell that instance name to run (hoping to have all mc's with that instance name run) but only one dot works.
Here's my as.
ActionScript Code:
function thumbnails_fn(k){ if (duplicate[k] == "yes") { d=d+1; // making p equal to original k p = k-d; flashmap.dots.attachMovie("dot", "dot"+p+"dup", d+99); flashmap.dots["dot"+p+"dup"]._x = xpos[k]; flashmap.dots["dot"+p+"dup"]._y = ypos[k]; addbutton = false; } new_k = k-d; if(addbutton) { locations_mc.attachMovie("location_bttn", "thumb"+k, k); locations_mc["thumb"+k]._y = new_k*18; locations_mc["thumb"+k].location_txt.text = locations[k]; } addbutton = true; flashmap.dots.attachMovie("dot", "dot"+k, k); flashmap.dots["dot"+k]._x = xpos[k]; flashmap.dots["dot"+k]._y = ypos[k]; locations_mc["thumb"+k].onRollOver = function(){ flashmap.dots["dot"+k].dot.play(); // here's where I'm trying to get all mc's with the same name to play flashmap.dots["dot"+k+"dup"].dot.play(); } locations_mc["thumb"+k].onRollOut = function(){ flashmap.dots["dot"+k].dot.gotoAndPlay("out"); // here's where I'm trying to get all mc's with the same name to play flashmap.dots["dot"+k+"dup"].dot.gotoAndPlay("out"); } }
Instance Names
I want to use this test function to have certain objects brought to the front.
I want all objects to be able to use this same function to be brought to the front but have a problem in determining which object evokes the function.
Code:
import flash.display.*;
import flash.events.*;
function Main() extends MovieClip
{
t1.index = depth;
addChildAt(t1,depth++);
t1.addListener(MouseEvent.MOUSE_DOWN, test);
}
function test(event:MouseEvent):void
{
setChildIndex(event.target, 3);
}
With the setChildIndex line I get this error...
"1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.displayisplayObject."
Do I have to wrap "event.target" as an Object? Does AS3 allow wrapping? And if so, how?
Thanks
Instance Names...
(I would put Flash CS3 in the title if I could )
if you call an object several times in the timeline (i.e. in several keyframes), is it really required that you give each an instance name? Is there a way to apply a instance name to the object across the clip?
also... is this proper syntax? It doesn't appear to be working
(["contentline" + _root.contentopen]).gotoAndPlay("s1");
it works in this...
gotoAndPlay(["content" + _root.contentopen + "-open"]);
|