Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

The Document Class of Flash CS3

This is a discussion on The Document Class of Flash CS3 within the Tutorials forums, part of the Flash English category; If we look to the Actionscript side, we discover that the Timeline of a FLA is nothing else then an ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  6 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 23-09-07, 17:58
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
The Document Class of Flash CS3

If we look to the Actionscript side, we discover that the Timeline of a FLA is nothing else then an instance of the Document Class.
To declare the Document Class to our FLA, we need to write the name of that class (without the .as extension) in the text field ‘Document Class’ in the property panel (at the bottom), as explained in the article on how to best declare a Document Class .
The Document Class extends the MovieClip Class, except in a few cases? Next, I will list the cases when those classes has to be subclasses of the MovieClip:

- If the timeline contains codes or scripts on frames

- If we want to control the timeline using the method of the MovieClip Class

- If the timeline contains components with personalised parameters or if: o The personalized parameters of the component present on the timeline are different from one frame to another. Example: the label property of a Button is ?OK? in the first frame and ?INVIA? in the second frame.

o The component placed on stage is not present on every frame of the timeline.





- If the timeline?s stage contains any component with personalised properties



If the FLA does not enter in any of the above case, the Document Class can then inherit of the Sprite Class.

Let us say that we decide to assign to the FLA a Document Class named ?Main.as?. We would write the name ?Main? in the property panel. If we would do a typing error and write ?Maina? for example, Flash would automatically create a class named ?Maina? and this ?auto? created class will extends the MovieClip Class.

If the FLA do not specify a Document Class, Flash will automatically create one.
If the following conditions are met in the FLA, the assigned class will be by default the MovieClip (flash.display.MovieClip):

- The timeline?s stage contains instance without name

- The timeline does not contain any codes or scripts on any frame

- The timeline?s stage does not contain components with personalised parameters

- The timeline?s stage does not contain components with personalised properties



If the FLA does not enter in any of the above case and the Document Class has not been assigned, Flash will by default create e Document Class which extends the MovieClip Class.

Every scripts placed on frames of the timeline can be, more or less, seen as methods? instances of the Document Class. The codes found on a frame of the timeline can be executed by Flash, independently of the methods or properties declared in the Document Class (clearly, if they do not have the same names). On the other side, any methods or properties assigned in the Document Class are directly accessible from any script on the timeline.

I will make an example:

I have a FLA named ?filippo.fla? to which I assign a Document Class ?Filippo.as?.
In the Filippo Class, ho un metodo vaiAlSito:
Code:
package
{
	import flash.display.MovieClip;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	public class Filippo extends MovieClip
	{
		public function Filippo()
		{
			
		}
		
		private function vaiAlSito(url:String):void
		{
			var richiesta:URLRequest=new URLRequest(url);
			navigateToURL(richiesta,'_blank');
		}
	}
}
The best part is now coming?
In my FLA, I create a keyframe at frame 9.
As we can see in the Filippo Class, the method vaiAlSito redirect the user?s browser to a chosen URL.
If now, we would like to execute the same action from frame 9 in our FLA, we could do it 2 different ways:
Code:
var richiesta:URLRequest=new URLRequest('http://www.flepstudio.org');
navigateToURL(richiesta,'_blank');
stop();
Code:
vaiAlSito('http://www.flepstudio.org');
stop();
This elasticity of communication in between the Document Class and the timeline, allows even to apprentice ?actionscripters? to use a Document Class into which the functions (methods) can be written and easily recalled from the timeline.
See you soon!
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Call from the timeline to the Document Class and vice versa with Flash CS3 Flep Tutorials 6 11-12-08 14:15
chiamate dalla timeline verso la Document Class e viceversa con Flash CS3 Flep Articoli e tutorials 13 01-12-08 06:03
La Document Class di Flash CS3 Flep Articoli e tutorials 1 23-04-08 11:21
document class marco792005 Actionscript 3.0 base 3 13-01-08 09:16
How to call another class from the Document Class with Flash CS3 Flep Tutorials 0 09-10-07 19:50


All times are GMT. The time now is 17:45.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap