Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 1 of 1

Thread: The Document Class of Flash CS3

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,457
    Rep Power
    8

    The Document Class of Flash CS3

    amazing Flash templates
    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!

+ Reply to Thread

Similar Threads

  1. Replies: 16
    Last Post: 12-03-09, 06:56
  2. Replies: 6
    Last Post: 11-12-08, 14:15
  3. La Document Class di Flash CS3
    By Flep in forum Articoli e tutorials
    Replies: 1
    Last Post: 23-04-08, 11:21
  4. Replies: 0
    Last Post: 09-10-07, 19:50
  5. document class
    By mariano.martucci in forum Actionscript 3.0 base
    Replies: 1
    Last Post: 24-07-07, 13:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO