Solved

How rotate testimonials in a flash movieclip

Posted on 2008-06-13
11
825 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 42

Accepted Solution

by:
Rob Jurd, EE MVE 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now