[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Running timeline animation with a documents class

Posted on 2011-04-29
2
Medium Priority
?
453 Views
Last Modified: 2012-05-11
Let me start with saying - I haven't done much AS3 and havent worked with the document class before.

What im trying to do is simple:
- Have a timeline animation along with the document class

In my document class, im loading some XML (see snippet)
Here im extending my class as a Sprite which means I can only have one frame on my timeline.

What would my approach be to this?
- Should I add the entire animation into a movieclip, give it a linkage name and add it to the displaylist?
- Or am I able to extend my class otherways, so I can actually have animation on the main timeline?
package 
{

	// import needed classes  
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.display.Sprite;

	// we extend sprite instead of movieclip as no timeline is needed    
	public class xmlLoad extends Sprite
	{

		// our xml object
		private var xml:XML;

		public function xmlLoad()
		{
			readXML();
		}

		private function readXML():void
		{
			// load the xml file using the URLLoader class
			var loader:URLLoader = new URLLoader(new URLRequest("dataFeed.xml"));
			// call our xmlLoaded function once the xml has loaded 
			loader.addEventListener(Event.COMPLETE, xmlLoaded);
		}

		private function xmlLoaded(e:Event):void
		{
			// assign loaded xml structure to our xml object
			xml = new XML(e.target.data);
			xml.ignoreWhitespace = true;
			
			trace(xml.news[0].@date);

		}
	}
}

Open in new window

0
Comment
Question by:mrsam
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
Jeremy Daley earned 2000 total points
ID: 35500783
What's the big deal with just having your Document Class extend a MovieClip? This would allow animation on the timeline. I do it all the time.

If you want to keep it extending a Sprite, then I suppose you could just create a MovieClip in the library with linkage, and then addChild(new MyClass())
0
 
LVL 4

Expert Comment

by:Jeremy Daley
ID: 35500785
Of course doing that, you might want to add a stop() action or some other code to keep it from moving along the timeline until your xml data has been loaded, at which time you'd then play()
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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…
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

873 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