Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 835
  • Last Modified:

How rotate testimonials in a flash movieclip

I want to basically add to an existing flash movie a small area that will rotate testimonials - if possible from a text file - as a small movie clip.  Any suggestions of where I could find one already done suggest the simplest way to do one that can be updated via text file?  Any help would be great.
0
brian2k1
Asked:
brian2k1
1 Solution
 
RobOwner (Aidellio)Commented:
http://www.flashkit.com/tutorials/Special_Effects/Continuo-Kirupa_C-649/index.php showing how you can do this with images.  if you substitute a movieclip with an embedded textfield then you can achieve the same effect
0
 
brian2k1Author Commented:
Also

Introduction to XML in Flash - http://www.kirupa.com/web/xml/index.htm
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
brian2k1Author Commented:
kinda answered my own question I guess.

Flash File Setup:
- create a new flash file "testimonials.fla"
- add one or more (two in this case) DynamicText area's with the names "dt_TestimonialArea" & "dt_TestimonialArea2"
- add the following actionscript code to Layer 1:Frame 1 in the actionscript panel
- create a text file (then change extension to xml) named "Testimonials.xml" and add the following text

<?xml version="1.0"?>
<testimonials>
      <testimonial>
            <fullname>Jane Doe</fullname>
            <citystate>Beverly Hills, Ca</citystate>
            <testimonial>Love it!</testimonial>
            <date>02-03-2006</date>      
      </testimonial>
      <testimonial>
            <fullname>John Doe</fullname>
            <citystate>Chicago, Il</citystate>
            <testimonial>Love it more!</testimonial>      
            <date>05-03-2007</date>
      </testimonial>
</testimonials>

I tried to use the Photo slideshow tutorial from Kirupa but it caused a serious memory leak because the interval function was not being cleared properly. So I reviewed the Adobe Help text on the setInterval function and using part of their example made the following code which works great and doesn't have a memory leak. I'm leaving this here for anyone else that needs the info.
///////////////////////////// VARIABLE DECLARATIONS
var intervalID:Number;
var intervalDuration:Number = 1500; //1500=1.5seconds initialize starting duration setting
var nodeID:Number = 0; //initialize starting testimonial id
var nodeMaxID:Number = 0;
var intervalCount:Number = 0; //just for debug/tracing
 
var xmlData:XML = new XML(); //setup new XML object in ActionScript
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("testimonials.xml");
 
function loadXML(loaded)
{
	if (loaded)
	{
		xmlNode = this.firstChild;
		fullname = [];
		citystate = [];
		testimonial = [];
		date = [];
		nodeMaxID = xmlNode.childNodes.length;
		
		for (i=0; i<nodeMaxID; i++)
		{
			fullname[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
			citystate[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
			testimonial[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
			date[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
		}		
 
		setTestimonialArea(0);
		beginInterval();
	} else {
		content = "file not loaded!";
	}
}
 
function setTestimonialArea(nodeID)
{
	dt_TestimonialArea.text = fullname[nodeID] + '\n' + citystate[nodeID] + '\n' + date[nodeID] + '\n' + testimonial[nodeID];	
 
	//ALL the text can go into one text area as above, I split it up just to illustrate 
	dt_TestimonialArea2.text = date[nodeID] + '\n' + testimonial[nodeID];
}
 
function getNextTestimonial()
{	
	trace("executeCallback intervalID: " + intervalID + " nodeID: " + nodeID + " intervalCount: " + intervalCount);
	if (nodeID>=(nodeMaxID-1))
	{
		nodeID=0;
	} else {
		nodeID++;
	}	
	setTestimonialArea(nodeID);
	intervalCount++;
}
	
function beginInterval():Void {
 if(intervalID != null)
 {
 	trace("clearInterval");
	clearInterval(intervalID);
 }
 intervalID = setInterval(this, "getNextTestimonial", intervalDuration);
}

Open in new window

0
 
SamuelRostolCommented:
Great work, and nice code :)
0
 
RNGeerCommented:
Hey Guys, I am trying to replicate this for a site and cannot get the xml data to display. Are there any steps in the above info that may be missing. I have added the dynamic text box and actionscript from the code box. Any info at all would be great, I only do flash about 10% of the time.
0
 
brian2k1Author Commented:
Did you name the dynamic text "dt_TestimonialArea"?

what is the output from the trace/debug window?
0
 
RNGeerCommented:
It is named correctly. Here is the error. I am sure I am jsut failing to set the ActionScript up correctly.

Scene 1, Layer 'Layer 1', Frame
1046: Type was not found or was not a compile-time constant: Void.
function beginInterval():Void {
0
 
brian2k1Author Commented:
zip up the entire thing and upload it. that error isn't very useful.
0
 
RNGeerCommented:
I thought not.

 I zipped it up but the Exchange won't let it through.
0
 
brian2k1Author Commented:
RNGeer please start another quest thread and take some screen shots of the various code pages, upload as JPG's. once you get the question started post a link as a comment here and I'll try to follow up. I'm sure it is just simple thing as the code I posted was copy/pasted out of file.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now