Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 06-19-2006, 09:02 PM   #1
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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:

__________________
senocular is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 06-19-2006, 09:03 PM   #2
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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.

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

__________________
senocular is offline   Reply With Quote
Old 06-19-2006, 10:08 PM   #3
mathew.er
flasher
 
mathew.er's Avatar
Location Czech Republic: Prague

Posts 1,219
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?
mathew.er is offline   Reply With Quote
Old 06-19-2006, 10:18 PM   #4
REEFˇ
Registered User
Changing FPS with AS? Isnt this a dream come true?
REEFˇ is offline   Reply With Quote
Old 06-19-2006, 10:26 PM   #5
TheCanadian
Noo doot aboot it, eh?
 
TheCanadian's Avatar
Location Take a guess . . .

Posts 6,808
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.

Name Brand Watches
TheCanadian is offline   Reply With Quote
Old 06-20-2006, 02:33 AM   #6
ieatcotten
excess ain’t rebellion
 
ieatcotten's Avatar
Location Gainesville

Posts 127
Quote:
However, they all reference the same thing I think.
Thats how I understand it.
Quote:
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
ieatcotten is offline   Reply With Quote
Old 06-20-2006, 03:27 AM   #7
mathew.er
flasher
 
mathew.er's Avatar
Location Czech Republic: Prague

Posts 1,219
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.
ActionScript 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.
mathew.er is offline   Reply With Quote
Old 06-20-2006, 03:34 AM   #8
sandeep_cdac200
Registered User
one more step towards making AS to Java!! Great!!

__________________
with regards
sandeep
shiningsandy@gmail.com
sandeep_cdac200 is offline   Reply With Quote
Old 06-20-2006, 10:55 AM   #9
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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

__________________
senocular is offline   Reply With Quote
Old 06-20-2006, 11:12 AM   #10
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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:

ActionScript 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);
        }
    }
}

__________________
senocular is offline   Reply With Quote
Old 06-20-2006, 01:09 PM   #11
sepu
LDEA
 
sepu's Avatar
Location San Francisco, CA

Posts 438
this topic at least should be a sticky !
thx Senocular.
sepu is offline   Reply With Quote
Old 06-20-2006, 01:28 PM   #12
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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

__________________
senocular is offline   Reply With Quote
Old 06-20-2006, 01:42 PM   #13
icio
looks better in lowercase
 
icio's Avatar
Location Edinburgh, Scotland

Posts 3,689
Nice one, sen
icio is offline   Reply With Quote
Old 06-20-2006, 02:51 PM   #14
REEFˇ
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?
REEFˇ is offline   Reply With Quote
Old 06-20-2006, 02:59 PM   #15
senocular
If you can read this, I'm
 
senocular's Avatar
Location San Francisco, CA (USA)

Posts 17,266
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)

__________________
senocular is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 19 (0 members and 19 guests)
 
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 Off

Forum Jump


All times are GMT -4. The time now is 06:41 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com