Running timeline animation with a documents class

Posted on 2011-04-29
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?

	// import needed classes  
	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()

		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(;
			xml.ignoreWhitespace = true;


Open in new window

Question by:mrsam
    LVL 4

    Accepted Solution

    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())
    LVL 4

    Expert Comment

    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()

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    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…
    I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
    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…
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now