all groups > flash data integration > february 2007 >
You're in the

flash data integration

group:

help with xml and onRollOver - text field


help with xml and onRollOver - text field depakchopra
2/5/2007 11:59:47 PM
flash data integration:
I posted this question in the actionscript forum, but no response.

What I am trying to do is create multiple instances of a button, hundreds in a
grid. When the user rolls over the button, which is at 1% alpha in its 'up'
state, the button will appear at 100% in the 'over' state, then fade in the
'out' state.

The buttons are created using xml, each button has a text field, each text
field will be linked to its own text (a name) through the xml.

I found a good tutorial online that takes you to the point where you can load
the xml into the actionscript and if you DONT have several states, it works
fine. My problem comes in when I try to give it the up, over, and out. Two
things occur in the code I will attach. One is that no matter which button you
hover over, only the last goes into the over state. The other is that the text
will only properly appear in the first frame. When you go to the 'over' state,
the only text that appears is when you embed the text. Otherwise, you get
nothing.

I have looked all over for a tutorial or a forum that might talk about how to
do this, and cant find anything. Help, please.

myXML=new XML();
myXML.ignoreWhite=true;
myXML.onLoad=function(ok){
if(ok){
allData=this.firstChild.childNodes;
for(i=0;i<allData.length;i++){
newBut=_root.attachMovie('butTemp','but'+i,i)
newBut._y=50;
newBut._x=(i*120)+50;
newBut.but_txt.text=allData[i].attributes.text
newBut.onRollOver = function(){
newBut.gotoAndPlay('over');
}
newBut.onRollOut= function(){
newBut.gotoAndPlay('out');
}
}
}else{
trace('error');
}
}
myXML.load('navII.xml');
Re: help with xml and onRollOver - text field MotionMaker
2/6/2007 12:25:51 PM
Try using an array to hold all the button references.

var myButtons:Array = new Array();
myXML = new XML()

myButtons.push(_root.attachMovie('butTemp','but'+i,i))
myButtons[i]._y=50;
myButtons[i]._x=(i*120)+50;
myButtons[i].but_txt.text=allData[i].attributes.text
myButtons[i].onRollOver = function(){
this.gotoAndPlay('over');
}
myButtons[i].onRollOut= function(){
this.gotoAndPlay('out');
}

Re: help with xml and onRollOver - text field depakchopra
2/6/2007 4:34:15 PM
I bet you just whipped that out, and I thank you with all my heart, its amazing
to me how many ways I tried to do what you did. Thanks

I have a second question relating to the same problem and that is in
referencing the over state. Currently, I can write 'text' into the text field
and see what I have coming in from xml in its place during the 'up' state.

However, when the timeline hits the 'over' state, the textfield will display
nothing, or 'text' if I have that written in. I suspect that I am not
referencing the'over' state correctly.

Should I add one line of code sort of referencing the text field and not just
the button while in the over state?
Re: help with xml and onRollOver - text field MotionMaker
2/6/2007 6:20:07 PM
Re: help with xml and onRollOver - text field depakchopra
2/6/2007 6:48:33 PM
I tried that, it works as you say, but I need the textfield to be invisible to
start with. What I have been doing is breaking the layer (with only the text
field on it) into two chunks by adding a key frame where the 'over' starts.
What I have been attempting is to change the alpha to 1% in the 'up' and then
bring it out at '100%' on 'over'.

What happens is that when I break the timeline up on that layer, it messes up
the textfield. The text works fine in the 'up' state, but implodes on the
'over' state. Is their a way to just reference the dynamic text in the 'over'
state?

Re: help with xml and onRollOver - text field MotionMaker
2/6/2007 8:30:52 PM
On the frames of the MovieClip symbol
but_txt.text._visible = false
but_txt.text._visible = true

AddThis Social Bookmark Button