Hello everyone,
I have been working on this for a while, and cannot get it working. I am quite new to AS. Ultimately what I would like to achieve is to read a number of strings from an .xml file, and as each one is read load the string into a text box within a movie clip, then do an alpha tween from 0 --> 100, then remove the text from the stage and repeat for the next value. Once the end of the .xml file is reached, I would want it to loop and the process repeat. Additionally, I am trying to get the text box to appear at random positions within a designated area on the stage for each string. The code I have so far is pasted below. What is happening is that the last string in the .xml file seems to work the way I want it to, but it is the only string that is displayed. The remaining strings from the .xml file are not displayed. If anyone has any advice on how to
a) Make all strings load, alpha tween, then disappear
b) get the process to repeat
I would be very grateful!
Thanks very much,
Russ
import mx.transitions.Tween;
import mx.transitions.easing.;
createEmptyMovieClip(“friend_mc”, 1);
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
friendText = [];
total = xmlNode.childNodes.length;
for (i=0; i<total;i++) {
friendText = xmlNode.childNodes*.childNodes[0].nodeValue;
var intStringLength = friendText*.length;
var intStringMaxWidth = intStringLength*13;
var intMaxXPos = 850-intStringMaxWidth;
var intRanXPos = Math.round(Math.random()*intMaxXPos);
var intRanYPos = Math.round(Math.random()380);
friend_mc.createTextField(“friendName_txt”, 1, intRanXPos, intRanYPos, intStringMaxWidth, 41);
friend_mc.friendName_txt.text = friendText
friend_mc.friendName_txt.embedFonts = true;
friendformat = new TextFormat();
friendformat.font = “Brush Script MT”;
friendformat.color = 0x006633;
friendformat.size = 30;
friendformat.bold = true;
friend_mc.friendName_txt.setTextFormat(friendformat);
var visInTween:Tween = new Tween(friend_mc.friendName_txt, “_alpha”, Regular.easeOut, 0, 100, 30, false);
//var visOutTween:Tween = new Tween(friend_mc.friendName_txt, “_alpha”, Regular.easeOut, 100, 0, 30, false);
}
friendNames();
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“friends.xml”);
friends.xml format:
<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?>
<friends>
<friend>Friend 1</friend>
<friend>Friend 2</friend>
<friend>Friend 3</friend>
etc…
</friends>