flashy Q
- Started
- Last post
- 15 Responses
- ganon
i am pushing instance names of MC to arrays like this...:
this.totalYears = 17;
this.circles = new Array();
this.textFields = new Array();
for(i=0; i_this.totalYears; i++) {
this.circles.push("circle" + [i]);
this.textFields.push("textField" + [i]);
}
//replaced "less than" cuz pvn doesnt like themi want to pull up a textField[i] when the corresponding circle[i] falls within a _x range...i have an if statement in an onEnterFrame, but i am unsure how to construct it...thoughts...?
- jkosoy0
hmmm....
I have some ideas on how to do this, but it truly depends on how the circle is being moved. Is it just floating around, or is it moving with a mouse drag or following the mouse...
I'm thinking 17 or so onEnterFrames might eat up the processor. So you'll want to make this happen in just one.
- ganon0
exactly...so i have a MC called "largeline", which has 17 circles spaced out horizontally, these are the ones whose instance name i am pushing to the array...this "largeline" MC is centered on the stage and moves dependent on _xmouse...so when each circle mc falls into the center range, i need to pull up a textfield MC....
- unfittoprint0
I think the better way is, instead of making a _root.arrays is to insert those values in the circle instances.
within them you should make an onEnterFrame [or a setInterval] to evaluate their _x pos and act accordingly.
- ganon0
so you are saying ditch the arrays and use something like this?..:
this.onEnterFrame = function() {
if(this.largeLine.circle[i]._x _ 20 && this.largeLine.circle[i]._x _ -20) {
this.textField[i]._visible = true;
}
}
//took out greater and les thansi am unsure how to make this code generic for all MC instance names circle 1-17 & textfield 1-17...thanks....
- unfittoprint0
wwait. your 'for in' loop is the right way. But instead of creating an array you should make something like within the loop:
this.attachMovie("circle", "circle"+i, i);
this["cricle"+i].textField= "textField"+i;
this["circle"+i].onEnterFrame = function(){
if(this._x _ 20 && this._x _ -20) {
_parent[this.textField] ._visible = true;
}
}
- ganon0
thanks unfit...but how will this for loop relate to the inactivity i have established...i have a "largeLine" MC with the 17 circles spaced out in it...the "largeLine" MC move left/right based on the user's _xmouse...?
- ganon0
ok thanks unfit, i got the for loop to pull out the 17 instances of the MC "circle" and add a number to their instance names...i have spaced them out in the MC "largeLine", which moves on _xmouse...now i am stuck trying to pull up the corresponding MCs...i have 17 different MCs titled "textField0..16."...i need these to appear when the corresponding circle number falls in the center range...thoughts?..:
for(i=0; i_this.totalYears; i++) {
this.largeLine.attachMovie("circ... "newcircle"+i, i);
this.largeLine["newcircle"+i]._a... = 50;
this.largeLine["newcircle"+i]._x = this.leftYears + (this.mySpace * i);
this.largeLine["newcircle"+i].on... = function(){
if(this._x "greater" 20 && this._x "less" -20) {
trace("center");
this._parent._parent["textField" + i]._visible = true;
} else {
trace("no center");
_this._parent._parent["textField... + i]._visible = false; }
}
}
- ganon0
*bamp
- unfittoprint0
make a test function [within the loop constructor, you can erase it after] to see if the textfields are exist on that location or if they're undefined.
this.largeLine["new circle"+i].onPress = function(){
trace(this._parent._parent["test...
}if not try using this._parent or this._parent._parent._parent until you find them in the right place of your file's hierachy.
- ganon0
keep in mind these are MCs on the stage with instance names "textField0 through 16"...if i
trace(["textField" + i]);
i only get "textField17"...so i am not finding the right instance names when the corresponding circle goes through the center zone....
- unfittoprint0
when tracing (this._parent._ parent["testFiedl"+i ]);
you should get a _level0.instance. etc...
or an undefined
because it's evaluting a string ("textField8") to an object (textField8).
- ganon0
ok unfit, with this
trace(this._parent._parent["text... + " unfit");
i get a _level0 instance...but now how can i get the textField #s to correlate with the circles?..i only get "textField17" now....
- ganon0
if i trace...:
this.largeLine["new circle"+i].onEnterFr ame = function(){
trace(["newcircle" + i] + " circle");i only get circle 17, so its not talking to the different circles...
- unfittoprint0
you shouldn't have the circles "talking2 to each other, but each one checking if their _x parameters will trigger the textfield _visibility.
the for in loop should create a mirror of the object within each circle in relation their "sister" textfield.
something like:
this["circle"+i].textField = this["textfield"+i].then, when using the onPress:
this["circle"+i].onPress function(){
this.textField._visible=true;
}
- ganon0
thank you unfit,
i was referring to the fact that the onEnterFrame isnt talking to the all the different circles, checking their xpos...it only is checking circle17...i want the textField MCs to appear when the corresponding circle rolls into the center...the movement is generated by _xmouse...so i am trying to have an onEnterFrame which checks the xpos of all 17 circle MCs, and when one of them rolls into the center, it shows the "sister" textField MC...i am trying to avoid have 17 onEnterFrames running at once....