[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

AS3 Load Image and Text to Dynamic Movie Clip

Asked by slightlyoff in ActionScript, Adobe Flash

Hello,

I'm trying to create an xml driven event scroller for my site.  So far I've been able to get the XML loaded into flash.  

The movie demensions are 288X94.

My goal is to load the first event in the middle of the stage, while loading the last event off the stage (on the top) and the next event off the stage (on the bottom).  Eventually, the event will stay on the stage for 5 seconds, then scroll up.

That's the idea.  However, I'm starting with just trying to dynamically create movie clips and load them with the data from my xml.

I've attached my actionscript below.  The real issue with this code, is that i'm creating a new movie clip with an instance name of "mc" + t.  I need this loaded on the stage, and the the image from the xml file loaded into it.

This isn't working... I'm gettign this error:

TypeError: Error #1034: Type Coercion failed: cannot convert "mc1" to flash.display.MovieClip.
      at event_scroll_fla::MainTimeline/createObj()
      at event_scroll_fla::MainTimeline/ParseEvents()
      at event_scroll_fla::MainTimeline/LoadXML()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/onComplete()

Any ideas?  I appreciate the help, this is my first attempt with AS3...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
//XML Loader
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
 
//For Loading the Image
var imageLoader:Loader;
 
//Need to know how many events...
var totalEvents:int = 0;
 
//XML Lists for Data
var eventList:XMLList;
var imgList:XMLList;
var linkList:XMLList;
 
//----------- End variables
 
 
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("events.xml"));
 
function LoadXML(e:Event):void {
	xmlData = new XML(e.target.data);
	ParseEvents(xmlData);
}
 
function ParseEvents(eventInput:XML):void{
	//get info
	eventList = eventInput.theEvent.title;
	linkList = eventInput.theEvent.link;
	imgList = eventInput.theEvent.image;
	trace("imgList: " + imgList[0]);
	// how many events
	totalEvents = eventList.length();
	trace("the #Events = " + totalEvents);
	
	trace("totalEvents: " + totalEvents);
	createObj(totalEvents);
}
 
function createObj(n:int):void {
	var myMC:MovieClip = new MovieClip();
	var t:int;
	var space:int = 10;
	var initY = 5;
	var theImageText:String;
	
	for (t=1;t<=n;t++){
 
			myMC.x = 5;
			myMC.y = initY;
			myMC.name = "mc" + t;
		addChild(myMC);
		initY = initY + space;
		trace("img: " + t);
		theImageText = imgList[t];
		loadImage(theImageText, "mc" + t)
	}
	
	function loadImage(url:String, mcX:MovieClip):void {
	// Set properties on my Loader object
		imageLoader = new Loader();
		imageLoader.load(new URLRequest(url));
		imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
		imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded(mcX));
	}
	
	function imageLoaded(e:Event, imageURL:MovieClip):void {
	// Load Image
		imageURL.addChild(imageLoader);
	}
	 
	function imageLoading(e:ProgressEvent):void {
		// For current download progress
		// Preloader
	}
}
[+][-]11/05/09 02:43 PM, ID: 25754927Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:49 PM, ID: 25754980Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/09/09 03:12 PM, ID: 25781084Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: ActionScript, Adobe Flash
Sign Up Now!
Solution Provided By: NiklasMoller
Participating Experts: 2
Solution Grade: A
 
[+][-]11/10/09 12:15 PM, ID: 25789307Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625