Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Best way to instance the Document Class

This is a discussion on Best way to instance the Document Class within the Tutorials forums, part of the Flash English category; As we have already seen, we can create an istance of a class this way: var nomeIstanza:NomeClasse=new NomeClasse(); ...


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
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 12-10-07, 17:39
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Best way to instance the Document Class

As we have already seen, we can create an istance of a class this way:
var nomeIstanza:NomeClasse=new NomeClasse();

But, following the advice of a guru Adobe's Flash Architect ( Colin Moock ), the best solution in AS 3.0 to create an instance of our Main Class ( meaning the Class which will handle the full application and SubClasses ) is the text field that we have in the Properties panel called Document Class. In fact in AS 3.0 the Main Class is being called Document Class.
The Document Class represents the main Timeline of our project ( FLA ) and, usually, is a SubClass of the MovieClip Class.
So the Miles Class that we have seen before will be as follow:
Code:
package
{
	import flash.display.MovieClip;
	
	public class Miles extends MovieClip
	{
		public function Miles()
		{
			trace('Here i am');
		}
	}
}
And in the Properties panel (field Document Class) let's write: Miles.

Now we have created an instance of the Miles Class which represents the Timeline of the Fla from which it has been created. So, if from the Class we use a trace command to find out, for example, how many frames there is in total on our Timeline:
Code:
package
{
	import flash.display.MovieClip;
	
	public class Miles extends MovieClip
	{
		public function Miles()
		{
			trace('la Classe Miles è stata istanziata');
			trace(this.totalFrames);
		}
	}
}
Stay tuned!
__________________

 


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
Document class ariel Flash Italiano 2 16-03-08 01:37
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
Document Class.....By Rosy Rosy AIUTO utilità free 4 26-08-07 10:28
document class mariano.martucci Actionscript 3.0 avanzato 5 24-07-07 14:24


All times are GMT. The time now is 12:16.

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