The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • Nutrox Author 
    • 1526 
    • 0 
    • 0 
    Conditional Compiling Tip
    Nutrox

    No comments yet

    Be the first to comment

    Posted: Nov 14 2009, 03:36 AM

    by Nutrox

     

If you are using Flash CS4 you will have probably noticed the “config constants” panel in the SWF publishing settings. In a nugget, they allow you to compile different chunks of code under different conditions.

For example, somewhere in your code you could have this:

VERSION::DEBUG
function foo():void {
    
// this function will be compiled into the SWF if
    // the DEBUG config constant is true
    
trace( "debug" );
}

VERSION
::RELEASE
function foo():void {
    
// this function will be compiled into the SWF if
    // the RELEASE config constant is true
    
trace( "release" );
}

foo
(); 

Now, if you are using Flash Builder, that code will throw an error because the compiler will have no idea what the [noparse]VERSION::DEBUG[/noparse] and VERSION::RELEASE values are. However, you can define config constants in Flash Builder with the help of some compiler arguments:

-define=VERSION::DEBUG,true -define=VERSION::RELEASE,false 

Doing that will make those constants accessible from anywhere in your code, and Flash Builder will happily compile your conditional code just like Flash CS4. You can view and edit the compiler arguments for your project by opening the project properties panel and then selecting the “ActionScript Compiler” settings (or “Flex Compiler” etc depending on the type of project).

good

  0 REPLIES
 
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 775  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,724  Assets
  • Profiles 282,659  Members
  • Topics 93,762  Topics
  • Blog 4  Blog
  • Facebook 1,680  Facebook
  • Twitter 1,165  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 04, 2012 - 19:05:23