The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Page 1 of 45 12311 ... LastLast
Results 1 to 15 of 669

Thread: ActionScript 3 Tip of the Day

  1. #1

    ActionScript 3 Tip of the Day

    ActionScript 3 is the next step forward in Flash scripting and to help with the transition (for those of you deciding to make it), I thought I'd make a new Tip of the Day thread for ActionScript 3.0 to help people prepare (after 100 tips, they will no longer be provided daily).

    Note: Many of these tips were created prior to the release of Flash and pertain to AS-only projects. Others were for use with the Alpha version of Flash (released prior to the full release of Flash). Most of these are noted as being for "Flash 9". Though much has changed in Flash CS3, most of those tips should still apply to it as well.

    To code AS3, you'll need one of the following:



    ActionScript 3 Tips and Tricks:

    Latest Additions
    (All categories are ordered from oldest (top) to newest (bottom))


    General


    Language Elements/Behavior and Syntax


    New Classes


    Regular Expressions


    Proxy Class


    XML


    Events


    Errors and Error Handling


    Display Objects (MovieClips)


    Flash Authoring



    Additional Resources:


    Samples:

  2. #2

    Change the frame rate of your movie

    Using ActionScript 3, you can dynamically change the frame rate of your movie using the Stage class.

    The Stage class (flash.display.Stage) is the class assigned to the stage object which is accessible from your main movie sprite/movie clip (or others within the same security sandbox) using the stage property. The stage object has a frameRate property which can contain any value between 0.01 and 1000 and determines the frame rate at which the Flash player plays back your movie. Changing this value lets you change the frame rate at runtime.

    Code:
    // change frame rate to 12 fps:
    stage.frameRate = 12;

  3. #3
    Nice to have an AS 3 thread. Maybe whole Flex/AS3 forum would be usefull as it seem to spred a lot.

    To the stage thing... is "stage" and not "Stage" a typo or do you need to import and instance the Stage to change the framerate? Shouldnt flash.display.Stage.frameRate = 12 do the job then?

  4. #4
    10,202
    posts
    Registered User
    Changing FPS with AS? Isnt this a dream come true?

  5. #5
    TheCanadian's Avatar
    10,305
    posts
    Noo doot aboot it, eh?
    Quote Originally Posted by mathew.er
    Nice to have an AS 3 thread. Maybe whole Flex/AS3 forum would be usefull as it seem to spred a lot.

    To the stage thing... is "stage" and not "Stage" a typo or do you need to import and instance the Stage to change the framerate? Shouldnt flash.display.Stage.frameRate = 12 do the job then?
    No, in AS3 it has changed - the Stage class is accessed through the stage property of a DisplayObject instance. However, they all reference the same thing I think.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  6. #6
    ieatcotten's Avatar
    127
    posts
    excess ain’t rebellion
    However, they all reference the same thing I think.
    Thats how I understand it.
    Inheritance:Stage->DisplayObjectContainer-> InteractiveObject->DisplayObject ->EventDispatcher->Object

    The Stage class represents the main drawing area. The Stage represents the entire area where Flash content is shown.

    The Stage object is not globally accessible. You need to access it through the stage property of a DisplayObject instance.
    http://livedocs.macromedia.com/labs/...lay/Stage.html

  7. #7
    So that example at livedocs makes it pretty clear... "stage" is a global object allowing you to view and change its properties or to register events with it.
    Code:
    package {
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.Event;
    
        public class StageExample extends Sprite {
    
            public function StageExample() {
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP_LEFT;
                stage.addEventListener(Event.ACTIVATE, activateHandler);
                stage.addEventListener(Event.RESIZE, resizeHandler);
            }
    
            private function activateHandler(event:Event):void {
                trace("activateHandler: " + event);
            }
    
            private function resizeHandler(event:Event):void {
                trace("resizeHandler: " + event);
                trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);
            }
        }
    }
    @fabiopb: Why? Isnt this just a sign, that flash goes on pretty well? If your worried anout the Adobe Flash application itself, then you dont need to be... Flex is just for something else than Flash. It wont also disappear from the Internet as everybody has the plugin, people are used to use it and it still has great potential.

  8. #8
    one more step towards making AS to Java!! Great!!

  9. #9
    Quote Originally Posted by sandeep_cdac200
    one more step towards making AS to Java!! Great!!
    There are more steps to come that reinforce this idea

  10. #10

    Class scope is now bound to class methods

    ActionScript 3 is entirely class-based. When you create classes, you create variables and functions (methods) which relate to and work with that class and instances of that class. Unlike ActionScript 2, methods in ActionScript 3 now retain their class scope when called, even if assigned to another object and called from that object, or if used with Function.call and Function.apply. Example:

    Code:
    package {
    	import flash.display.Sprite;
    	
    	public class ClassScope extends Sprite {
    		
    		public function ClassScope() {			
    			traceThis(); // "Class Instance"
    			
    			var obj:Object = new Object();
    			obj.traceThis = traceThis;
    			obj.traceThis(); // "Class Instance"
    			
    			traceThis.call(new Sprite()); // "Class Instance"
    		}
    
    		public override function toString():String {
    			return "Class Instance";
    		}
    		
    		public function traceThis():void {
    			trace(this);
    		}
    	}
    }

  11. #11
    this topic at least should be a sticky !
    thx Senocular.

  12. #12
    Quote Originally Posted by sepu
    this topic at least should be a sticky !
    thx Senocular.
    Since it's every day it won't have problems staying near the top

  13. #13
    icio's Avatar
    3,811
    posts
    looks better in lowercase
    Nice one, sen
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

  14. #14
    10,202
    posts
    Registered User
    A few questions...Whats AS 3.0 for? Is there a new flash coming out?

    And PK...why do you believe flash will decline?

  15. #15
    Quote Originally Posted by ~REEF~
    A few questions...Whats AS 3.0 for? Is there a new flash coming out?
    ActionScript 3 is the next release of ActionScript that will be supported in Flash Player 9. Flex 2 applications are built using ActionScript 3 and the next version of Flash (code named BLAZE) will support it when it's released some time after Flex. Unlike ActionScript 2, ActionScript 3 uses an entirely new virtual machine providing it with new robust features and increased performance.

    More details on available and upcoming products can be found on http://www.adobe.com/ and http://labs.adobe.com/ (where both the Flex 2 beta and Flash Player 9 beta are currently available for download)

Page 1 of 45 12311 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012