Solved

How rotate testimonials in a flash movieclip

Posted on 2008-06-13
11
827 Views
Last Modified: 2009-08-31
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
Comment
Question by:brian2k1
11 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 500 total points
ID: 21787971
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
 
LVL 1

Author Comment

by:brian2k1
ID: 21788574
0
 
LVL 1

Author Comment

by:brian2k1
ID: 21788577
Also

Introduction to XML in Flash - http://www.kirupa.com/web/xml/index.htm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:brian2k1
ID: 21788840
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
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21791314
Great work, and nice code :)
0
 

Expert Comment

by:RNGeer
ID: 21915586
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
 
LVL 1

Author Comment

by:brian2k1
ID: 21916232
Did you name the dynamic text "dt_TestimonialArea"?

what is the output from the trace/debug window?
0
 

Expert Comment

by:RNGeer
ID: 21916333
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
 
LVL 1

Author Comment

by:brian2k1
ID: 21916357
zip up the entire thing and upload it. that error isn't very useful.
0
 

Expert Comment

by:RNGeer
ID: 21916390
I thought not.

 I zipped it up but the Exchange won't let it through.
0
 
LVL 1

Author Comment

by:brian2k1
ID: 21916555
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

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question