logo
468x60-2-495


  • Home
  • Privacy Policy
  • About
search
top
Jun 14, 2012 Posted on Jun 14, 2012 in Hints and Tips | 10 comments

Get $50 Cash by Joining Tuts+ Premium with PayPal

It’s been about 6 months since we launched our much improved New Tuts+ Premium complete with courses and eBooks. In that time we’ve added 97 hours of video training, 36 eBooks and of course our premium tutorial library has continued to grow and is rapidly apporaching 1000 tutorials, including lots of fantastic Activetuts+ content. Now, for a limited time only, thanks to PayPal we’re offering anyone who joins Tuts+ Premium with a yearly membership via the PayPal service, a $50 cash back to their PayPal account. It’s a good way to get an even better deal on Tuts+ Premium yearly subscriptions!

Join Tuts+ Premium

If you’re serious about skilling up, head over to Tuts+ Premium and invest in yourself and your development! We’re constantly adding more content and it’s only getting better and better, so buying a yearly subscription is worth it. Plus we have a money back guarantee in the first month, so if you discover it’s not for you, you can always bail out without charge (and of course without the $50 cash!) If you enjoy our free Tuts+, you’ll definitely find Tuts+ Premium a valuable edition.

Read the terms below and Join Tuts+ Premium today!


Terms – read these!

Disclaimer:PayPal is not responsible for the promotion offered by Envato and you should read the Terms & Conditions below. The PayPal service is provided by PayPal Australia Pty Limited (ABN 93 111 195 389) which holds an Australian Financial Services Licence, number 304962. Before deciding to sign-up for or use the PayPal service you should consider the Combined Financial Services Guide and Product Disclosure Statement, available at www.paypal.com.au.

  • The promotion is run by Envato Pty Ltd and the promotion period runs from 12.00 noon on 12 June (Australian Eastern Standard Time – AEST) until 11.59am on 19 June (AEST).
  • If you purchase a yearly $180 USD Tuts+ Premium subscription using a PayPal account during the promotion period, you will receive a $50 USD credit to that PayPal account.
  • Sorry, but existing Tuts+ Premium yearly members are not eligible for the promotion. Existing Tuts+ Premium monthly members who upgrade to a yearly subscription are eligible.
  • Payment must be made through PayPal for the promotion to apply.
  • Your PayPal account must be in good standing at time of purchase (e.g. not limited, closed or otherwise restricted).
  • The credit will be applied to the PayPal account used to purchase the yearly subscription, and will be made 45 days after the promotion period ends.
  • The credit will not be given if you exercise the Tuts+ Premium 30 day money back guarantee.
  • You may only take advantage of this promotion for one time, meaning one $50 credit per person.
  • The credit will not be given if there is a reversal, chargeback or fraudulent transaction on the subscription payment.
  • Play fair! Any attempt to defraud Envato may result in immediate disablement of your Tuts+ Premium subscription accounts. And there will be no refund on the Tuts+ Premium subscription. We will have the final say on whether there has been an attempt to defraud Envato.
  • This promotion cannot be used in conjunction with any other promotional offer or coupon.

Upgrades

If you are an existing monthly Tuts+ Premium member, and interested in upgrading to a yearly membership to take advantage of this offer, be sure to cancel your existing monthly subscription via PayPal. Also, thank you for being a member!!



View full post on Activetuts+

banner ad

10 Responses to “Get $50 Cash by Joining Tuts+ Premium with PayPal”

  1. Collis says:
    June 14, 2012 at 9:34 am

    It’s been about 6 months since we launched our much improved New Tuts+ Premium complete with courses and eBooks. In that time we’ve added 97 hours of video training, 36 eBooks and of course our premium tutorial library has continued to grow and is rapidly apporaching 1000 tutorials, including lots of fantastic Activetuts+ content. Now, for a limited time only, thanks to PayPal we’re offering anyone who joins Tuts+ Premium with a yearly membership via the PayPal service, a $50 cash back to their PayPal account. It’s a good way to get an even better deal on Tuts+ Premium yearly subscriptions!

    Join Tuts+ Premium

    If you’re serious about skilling up, head over to Tuts+ Premium and invest in yourself and your development! We’re constantly adding more content and it’s only getting better and better, so buying a yearly subscription is worth it. Plus we have a money back guarantee in the first month, so if you discover it’s not for you, you can always bail out without charge (and of course without the $50 cash!) If you enjoy our free Tuts+, you’ll definitely find Tuts+ Premium a valuable edition.

    Read the terms below and Join Tuts+ Premium today!


    Terms – read these!

    Disclaimer:PayPal is not responsible for the promotion offered by Envato and you should read the Terms & Conditions below. The PayPal service is provided by PayPal Australia Pty Limited (ABN 93 111 195 389) which holds an Australian Financial Services Licence, number 304962. Before deciding to sign-up for or use the PayPal service you should consider the Combined Financial Services Guide and Product Disclosure Statement, available at http://www.paypal.com.au.

    • The promotion is run by Envato Pty Ltd and the promotion period runs from 12.00 noon on 12 June (Australian Eastern Standard Time – AEST) until 11.59am on 19 June (AEST).
    • If you purchase a yearly $180 USD Tuts+ Premium subscription using a PayPal account during the promotion period, you will receive a $50 USD credit to that PayPal account.
    • Sorry, but existing Tuts+ Premium yearly members are not eligible for the promotion. Existing Tuts+ Premium monthly members who upgrade to a yearly subscription are eligible.
    • Payment must be made through PayPal for the promotion to apply.
    • Your PayPal account must be in good standing at time of purchase (e.g. not limited, closed or otherwise restricted).
    • The credit will be applied to the PayPal account used to purchase the yearly subscription, and will be made 45 days after the promotion period ends.
    • The credit will not be given if you exercise the Tuts+ Premium 30 day money back guarantee.
    • You may only take advantage of this promotion for one time, meaning one $50 credit per person.
    • The credit will not be given if there is a reversal, chargeback or fraudulent transaction on the subscription payment.
    • Play fair! Any attempt to defraud Envato may result in immediate disablement of your Tuts+ Premium subscription accounts. And there will be no refund on the Tuts+ Premium subscription. We will have the final say on whether there has been an attempt to defraud Envato.
    • This promotion cannot be used in conjunction with any other promotional offer or coupon.

    Upgrades

    If you are an existing monthly Tuts+ Premium member, and interested in upgrading to a yearly membership to take advantage of this offer, be sure to cancel your existing monthly subscription via PayPal. Also, thank you for being a member!!


  2. Porter says:
    June 14, 2012 at 10:18 am

    Kongregate is one of the largest Flash game portals on the net, and has its own API that can be integrated into your games (for which Kongregate even rewards you financially). In this tutorial, I’ll show you how to implement the Kongregate API into your games, and also go into detail about what the API is capable of and why you should use it.

    (Note that this tutorial assumes you already have a Kongregate account; if you don’t, then please create one now.)


    Final Result Preview

    Let’s take a look at what the API enables us to do:

    Badges

    Mass Messages

    High Scores

    There’s another big reason to implement the API…


    Step 1: Let’s Get Motivated

    Before we dive into the technical aspects of implementing the Kongregate API, let’s get ourselves hyped up a little bit, and make sure that we actually want to implement it.

    There are many reasons to implement the API, but to most developers, nothing speaks louder than money, and there’s plenty of that involved. When you upload your game to Kongregate, you automatically earn 25% of all ad revenue generated by your game’s page.

    It gets better; if you implement their “Statistics & Challenges API”, you’ll receive an additional 10%! Finally, if your game is exclusive to Kongregate, or sponsored by them, you receive an additional 15%. This gives you the opportunity to earn up to 50% of the ad revenue for your game on Kongregate. If you’re wondering how much that is, check out some of my personal stats:


    Step 2: Setting Up Our Work Environment

    For this tutorial, we’ll be using FlashDevelop, a free (and amazing) open source editor for developers. We’ll be doing everything in simple .as files, so if you’d like to follow along using the Flash IDE, you shouldn’t have any trouble. If you’d like to use FlashDevelop and are unfamiliar with it, check out this excellent FlashDevelop beginner guide to get you started on what I would consider the best AS3 editor out there.

    To begin, open FlashDevelop, go to the Project tab, and select “New Project”. From here, select “AS3 Project with Pre-Loader”. Alternatively, you can grab the Preloader.as and Main.as files from the source download, and simply follow along.

    Your file should be a barebones Main.as file, like this:

    
    
    package {
    	import flash.display.Sprite;
    	import flash.events.Event;
    
    	/**
    	 * ...
    	 * @author Your Name
    	 */
    
    	[Frame(factoryClass = "Preloader")]
    
    	public class Main extends Sprite {
    
    		public function Main():void {
    			if (stage) init();
    			else addEventListener(Event.ADDED_TO_STAGE, init);
    		}
    
    		private function init(e:Event = null):void {
    			removeEventListener(Event.ADDED_TO_STAGE, init);
    			// entry point
    		}
    
    	}
    
    }
    

    Nothing above should be new to you; if it is, all you need to know is that this file is the entry point for our program, this is where it all begins. If you compile this with FlashDevelop, you should get a blank white screen, with no compiler errors.


    Step 3: Let’s Get Connected

    Before we dive into all the cool features of the API, we need to make sure that we have the API up and running.

    Unlike many sponsor APIs, the Kongregate API isn’t a standalone set of files that we need to compile with our project. The API is actually stored on the Kongregate server, and we load it in at runtime. There’s a number of ways to do this in your projects, but for the sake of this tutorial, we’ll simply connect within our Main.as, and a save a reference to it there.

    To start, copy the following code into our Main.as file just below the existing imports:

    
    
    import flash.display.LoaderInfo;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.system.Security;
    

    The above are just a few simple imports that will allow us to use the necessary classes for loading in the Kongregate API.

    Next, we’ll add a variable to store our reference to the Kongregate API. Go ahead and add the following right above the constructor of our Main.as file.

    
    
    private var kongregate:*;
    

    Notice that the data type of our kongregate variable is *. If you’re unfamiliar with this, we’re simply telling the compiler that the kongregate variable will accept any data type, much like a wild card.

    (Also, note that in a real game you’d want to store your reference to the API somewhere that your entire project has access to, such as a public static const. This reference is needed so that you can use the API from anywhere in your project, for any purpose, rather than just in the Main.as file when we first start up.)

    This next piece of code will be contained in a custom function by the name of initKongregateAPI(). This isn’t actually necessary, but I prefer to encapsulate ideas when writing code, as it helps keep the code readable and easy to work with.

    Go ahead and add this function below the init function in Main.as.

    
    
    private function initKongregateAPI():void {
    	// Pull the API path from the FlashVars
    	var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
    
    	// The API path. The "shadow" API will load if testing locally.
    	var apiPath:String = paramObj.kongregate_api_path ||
    	"http://www.kongregate.com/flash/API_AS3_Local.swf";
    
    	// Allow the API access to this SWF
    	Security.allowDomain(apiPath);
    
    	// Load the API
    	var request:URLRequest = new URLRequest(apiPath);
    	var loader:Loader = new Loader();
    	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    	loader.load(request);
    	this.addChild(loader);
    }
    

    While that may look like a lot of code, it’s really not much, and with the comments, it’s quite easy to follow.

    As you’ll see, in the first part we’re creating a variable to store the API path from the FlashVars (if you don’t know what these are, look them up really quick, they’re a great thing to understand).

    In the second chunk, we determine whether the SWF is on the Kongregate website or running locally, and we assign the proper information to the apiPath variable.

    Next, we give the API access to the SWF, with a simple security.allowDomain call, where we pass in the apiPath as the parameter.

    We then create a new URLRequest object, which gets the apiPath passed in to the constructor, a new Loader object, and add an event listener for the loader which will call loadComplete when done.

    Last, we call loader.load and pass in our request (the newly created URLRequest object, which contains the apiPath of the Kongregate API). If you understand what just happened, great; if not, don’t sweat it, as you won’t have to touch this again.

    Don’t Forget to Call It!

    Now that the initKongregateAPI function is created, and contains all of the connection code, we should probably make sure this function actually gets called! Simply go back to the init function that our Main.as file already contained, and add a function call to initKongregateAPI after the line that “entry point” line, like so,

    
    
    private function init(e:Event = null):void {
    	removeEventListener(Event.ADDED_TO_STAGE, init);
    	// entry point
    
    	initKongregateAPI();
    }
    

    Finally, we need to add that loadComplete function, to be called when the COMPLETE event is fired from our previous code. Add this function below the initKongregateAPI function in Main.as.

    
    
    // This function is called when loading is complete
    private function loadComplete(event:Event):void {
    	// Save Kongregate API reference
    	kongregate = event.target.content;
    
    	// Connect to the back-end
    	kongregate.services.connect();
    
    	// You can now access the API via:
    	// kongregate.services
    	// kongregate.user
    	// kongregate.scores
    	// kongregate.stats
    	// etc...
    }
    

    The above code is super simple; let’s go over it. We start off by saving a reference to the Kongregate API. As you can see, we’re referencing the Kongregate API through the passed in event parameter, via event.target.content – simple enough.

    Now all we have to do is connect, and our SWF is good to go. As you can see, we connect by calling the kongregate.services.connect method. No arguments required.

    While that may have seemed like a lot of work, it really wasn’t. I simply went over the connection process in a lot of detail, so that you can understand how we’re actually gaining access to the API, rather than just having that access and using it. Now that you understand it, you can use all the above as boilerplate code.


    Step 4: The Statistics & Challenges API

    Now that we’re connected, we can take a look at the most important feature of the entire API: the Statistics & Challenges portion. This API sends player related stats to the Kongregate server, which enables a number of things.

    First off, this is the most basic way to allow users to compete for high scores on Kongregate. With the API integrated, the Kongregate side bar will include a new tab labeled “ACHIEVEMENTS”, which can be found next to the “CHAT” tab. Players can view leaderboards for any stat you send to the servers, which could be anything from a basic high score to the total number of enemies defeated.

    The second and far more important use, is to allow Kongregate to use the stats you submit to create “badges” for your games. Badges are a central part of the Kongregate user experience, and are much like the achievement systems on platforms such as Xbox LIVE.

    The best part about having badges added to your game is that your game will become featured for a short duration, greatly increasing the number of views you get, and thus greatly increasing your ad revenue. Even after your game is out of the spotlight, all badged games on Kongregate continue to receive increased views over normal games, which gives you an excellent long tail revenue stream.

    Note that badges aren’t added by developers, but are instead created by the Kongregate staff. You’ll need a high rated game to get selected, but you’ll also need the API to be set up – so let’s get that half the battle out of the way!


    Step 5: Back-End Preparation

    To actually use the stats that we’ll be sending, Kongregate first requires us to let their server know what information it should be prepared to receive from us.

    To do this, we simply go to the Statistics page for our game on the Kongregate website. This can be found in the “Edit Game” page, or by adding /statistics to the end of your game’s URL (for example, http://www.kongregate.com/games/EpicShadow/pixel-purge/statistics). For this tutorial, we’ll simply upload our test SWF as the “game”.

    Before adding any stats to the Statistics & Challenges API, we need to first understand the four types of stats that can be used, and the rules that they are bound to. Values must be positive, and must be whole integers. The four types are as follows:

    • Max: The value on the server will be replaced if the new value is higher than the stored value. For example, a high score of 152,000 would replace an old high score of 120,000.
    • Min: The value on the server will be replaced if the new value is lower than the stored value. For example, in a racing game, a lap time of 31 seconds would replace an older value of 35.
    • Add: The new value will be added to the stored value. A common use of this would be total enemies defeated, player deaths, etc. Too many requests to the server may result in inaccurate data, so it’s advised that data is only sent in bulk, such as when a level is completed or when the player dies.
    • Replace: The new value will replace the stored value no matter what. This can be used for a number of things, such as average survival time or player ranking.

    Knowing which of the above types you need to use for each of your game stats is extremely important, so make sure you familiarize yourself with the above list. You’ll obviously want a list of stats that you want your game to send to Kongregate, so make sure that you have those prepared before you dive into the next step when actually submitting a game.

    For the sake of this tutorial, we’ll simply use the following stats:

    • Total Clicks (Add)
    • Max Clicks (Max)
    • Last X (Replace)

    Once your list is prepared, head to the Statistics page of your game, and input the required data. Once the back-end work is done on the Statistics page, the game will be ready to submit data to the Kongregate server.


    Step 6: How to Send Stats

    To actually send data to the server, we simply call the “submit” function, which looks like this:

    
    
    submit(statName:String, value:Number):void
    

    As you can see, the function takes two parameters:

    • statName is the name of your stat. It’s very important that the String passed is identical (case sensitive) to the name of the stat you listed in the previous step when prepping the server to handle your stats.
    • value is the actual numeric value to be passed. Even though the data type is Number, remember that your value must be a positive, whole integer.

    To call this function in your game, simply do the following:

    
    
    kongregate.stats.submit(“Your Stat String”, statValue);
    //stat value could be 1, 500, 5342324, etc.
    

    Even though we had four different types of stats we could send, this function only sends the value; the server itself will look at the information we provided in the previous step to determine how to treat the incoming data. It’s as simple as that; now we know how to send data to the server.


    Step 7: Prepping Our Project to Send Stats

    Now that we’ve prepped the back-end on the Kongregate website, and we now know how to send data, let’s give this project a go.

    The first thing we need to do is add some code to our project to actually send our stats. Since the easiest thing to track is mouse input, I’ve chosen mouse-related stats. As you saw in our previous step, I chose Max Clicks, Total Clicks, and Last X.

    Max Clicks will be the high score for how many times we click in a single game, to demonstrate the Max type; Total Clicks will be the grand total of all clicks we’ve done, to demonstrate the Add type; and Last X will be the x-position of our most recent click, to demonstrate the Replace type.

    To track our Mouse clicks, we’ll need import the MouseEvent class. Go back to Main.as, and add the following to your imports:

    
    
    import flash.events.MouseEvent;
    

    Now we’re going to need to add a variable for our Max Clicks stat, to keep track of the total number of clicks per game session. Right below where we added the kongregate reference variable (of data type *), add the following:

    
    
    private var maxClicks:int;
    

    We’re going to need an Event Listener to listen for our clicks, so we’ll add that now. In the init function, right below the call to initKongregateAPI, add the following:

    
    
    //Event listener for mouse clicks
    stage.addEventListener(MouseEvent.CLICK, clicked);
    

    As you can see in the above code, the function called whenever the event it fired is called clicked. Let’s go ahead and create that function. Add the following below your loadComplete function:

    
    
    private function clicked(event:Event):void {
    	maxClicks++;
    	kongregate.stats.submit("Total Clicks", 1);
    	kongregate.stats.submit("Max Clicks", maxClicks);
    	kongregate.stats.submit("Last X", mouseX);
    }
    

    All we’re doing here is incrementing the maxClicks variable by 1, and then submitting all the required information to the Kongregate server. This will add 1 to the Total Clicks stat, send the current maxClicks variable to the server, which will then determine if it’s higher than the previous value and replace it if so, and send the x-position of our previous click, which will automatically replace the previous value.

    Our SWF may just be a blank screen, but a lot is going on, and we’re about to see it in action. Make sure you compile the project before moving on.


    Step 8: Testing Our Project

    Now it’s time to actually upload our project, and see it in action.

    Go back to the Kongregate website, head to your game page, and upload the final version of our project. Once you’ve uploaded the project, you’ll be brought to a preview screen, where we can test our project before publishing it. To save the Kongregate staff a lot of time and energy, do everyone a favor and do not press publish on your test SWF. (If you’re working on a real game, go ahead, but for the sake of this tutorial we will not be publishing this project.)

    Once you’re on the test page, give the game a few clicks. Refresh the page, and you should now see that there is a “HIGH SCORES” tab next to the “CHAT” and “GAME” tab. If you’ve done everything correctly up to this point, you should have a drop down box that currently reads “Last X” that also contains “Max Clicks” and “Total Clicks”. Note that clicking quickly will result in innacurate stats, as the server can’t keep up with all the requests, so click slowly for best results. This is why I advised earlier that you send large batches of data upon death, or level completion, when possible.

    Well, there you go: you’ve now got the most important portion of the Kongregate API up and running. If your project isn’t working at this point, make sure that your Kongregate back-end stat names are typed exactly as they are in your submit function – case-sensitive – as that’s usually the problem.

    You can also find the completed code in the final files folder in the source download, so compare your code to that if you’re still having issues.


    Step 9: Mass Message Communications

    Ever released a game, then later, really wanted to reach out to all of your fans? Well, with the Kongregate API, you can do just that – at least, for all of your Kongregate fans.

    There are some restrictions on who can do this, but these restrictions are very much in the best interest of both developers and players. In order to qualify, your game must receive a 3.75 rating or higher, and have at least 10k gameplays.

    You can send an “active players” message at most once every seven days. These messages will be sent to any players who have played the game at least three times ever, and at least once within the last ten days.

    You can send an “inactive players” message at most once every 30 days. These messages will be received by any players who have played at least five times total, but not within the last ten days.

    There are many of reasons to send these messages to your players, such as alerting them of bug fixes, or perhaps informing them of an upcoming sequel. Regardless of what you use this for, it’s an incredibly useful system that can really help you leverage your fans.

    For more information, see this guide.


    So Much More…

    While we’ve covered a lot in this tutorial, the Kongregate API is capable of doing much more. Unfortuantely, I’d have to write a small book to go over all of the features, especially those that are useful for web based MMOs. If you’re interested in checking out what other features the API has to offer, I recommend checking out the Kongregate Developers Center for more.

    Now that you know how to get the Kongregate API up and running, I strongly encourage you to add it to all of your future games; if you’re lucky, you might even get some badges, and that’s when the real fun begins.


  3. Matt Stuttard says:
    June 14, 2012 at 10:21 am

    Last year, we released Tr.ace(), an open source debugging tool for Flash that expanded on the built-in trace() function. Now, Tr.ace() v2.0 introduces several new features including the much requested “textfield console” to help you squash those bugs once and for all!


    New to Tr.ace()?

    Tr.ace() was released nearly a year ago as an Exclusive Freebie on Activetuts+ and is an open source debugging utility for Flash that allowed you to restrict the traces shown within your application to particular users or classes or even both. You could also add linebreaks, timestamps and trace nested arrays and objects neatly with one line of code!

    Let’s take a look at what’s changed since Tr.ace() was first released…


    By Popular Demand: Tr.ace() Console

    The Tr.ace() library now features a class named TrConsole which provides you with a basic console within your SWF through which you can view all your Tr.ace() traces! Check out the demo below to see it in action:

    You can clear the console, copy the output to the clipboard and save the output to a text file. You can also minimize the console to reduce the space taken up on screen as well as move it around the screen by simply dragging it. It’s also fully resizable!

    To take advantage of this feature you only need two lines of code:

    
    
    // create the TrConsole instance and add it to the stage
    var console:TRConsole = new TrConsole();
    addChild(console);

    And that’s it – easy!

    There are also a few extra options for you to tailor the colours of the console and whether autoscroll is enabled or not. Check out the documentation and example files for more info.


    Optional Username and Class Parameters

    When Tr.ace() was intially released the username and class parameters were required for all trace calls whether you wanted to use them or not. You’ll be happy to know that they are now optional!

    This does reduce some of the functionality of the library but if you’re just wanting to see your traces via the console then you’re able to, without the bloat of the rest of the library.

    With parameters:

    
    
    Tr.ace("with parameters", TrUsers.MSFX, ClassName);

    Without parameters:

    
    
    Tr.ace("without parameters!");

    This will hopefully make the library more accessible and less “verbose” for tracers everywhere.


    Clear, Copy and Save Your Traces

    Via the console featured above you can clear, copy to clipboard, and save the current trace log.

    For those who aren’t using the console you can also achieve these via calls to the Tr class as shown below:

    
    
    // to clear the trace log
    Tr.clearLog();
    
    // to copy to the clipboard
    Tr.copyLogToClipboard();
    
    // to save the log as a text file with timestamp
    Tr.saveLog();

    The clipboard functionality must be triggered via a user interaction, as detailed here.


    Downloading Tr.ace()

    Tr.ace() is an open source library that is available to download here at Activetuts+ in ZIP format and is also available as a public repository on my GitHub, for those a little more nerdy or who wish to fork and/or contribute towards the Tr.ace() library.

    The library is AS3 only and has two separate repositories developed for both Flash Player 9 and Flash Player 10+

    To use the Tr.ace() library you must download one of the above source packages and copy and paste the ‘uk’ directory, located within the ‘src’ directory, into your global classpath directory. You’re then all set to go!


    Documentation for Tr.ace()

    Within the download package you’ll find a ‘docs’ directory; open the index.html file to view the ASDocs-generated documentation for Tr.ace(). You can also find the documentation online: http://docs.msfx.co.uk/as3/trace/.


    Happy Tracing!

    So, that’s it really. If you have any questions or suggestions for the library feel free to get in touch in the comments.

    Happy tracing!


  4. Michael James Williams says:
    June 14, 2012 at 10:45 am

    With Google I/O 2012 coming up soon, I thought it’d be a great idea to look back at some excellent talks from past events. This week, let’s watch Alex Russell explain how to learn to love JavaScript.


    Watch the Video

    Alex Russell is a Google engineer working on Chrome (desktop, Android, and Frame). In this talk, he discusses JavaScript’s strengths and explains why it is such a popular and important language.

    If you’re a keen AS3 developer that can’t see why people are so into JS – after all, its syntax looks like AS1 sometimes – have a listen to what Alex has to say.


  5. Maciej Sopylo says:
    June 14, 2012 at 11:02 am

    A web worker is a JS script that runs in the background, separately from other scripts, allowing us to introduce threading in our web apps. Although not part of the HTML5 spec, web workers can be used with HTML5 apps. In this Quick Tip, we’ll take a look at how to use them.


    Introduction to Web Workers

    In the land of HTML5 we have some very interesting APIs available. Some of them – like Web Workers – are useful for increasing performance, which is very important for both apps and games. But how do web workers… well, work?

    Every instance of a web worker creates another thread, in which your JavaScript runs. You instantiate one like so:

    
    
    var worker = new Worker('filename.js');
    

    Here, ‘filename.js’ is the name of file containing your script. Because Workers are individual environments, you can’t use code embedded directly in HTML; you must use a separate file.


    Communication: Sending and Receiving Data

    Workers don’t have access to the page DOM or the global object, so how do they communicate with the site? It’s simple. When you want to send some data from your page to a Worker, you invoke postMessage().

    This takes one parameter: data to send, which can be either a string or a JSON parsable object (which means that you can’t pass functions or circular references, or you will get a DOM_EXCEPTION). On some browsers there is a problem with objects, so it’s always better to manually parse the object with JSON.parse() so you don’t have to worry about incomplete implementations.

    The same goes if you are sending data from a Worker to the page: just invoke postMessage() on self, which refers to the Worker’s global scope. (You do this inside the Worker’s script, of course).

    Then, to receive the data you have to attach an onmessage event handler. There are two ways of doing that, just like with regular events for DOM elements; you can either directly assign some function to the Worker’s onmessage property, or you can use addEventListener().

    
    
    // First way:
    worker.onmessage = function (e) {
    	console.log(e.data); // Log the data passed
    }
    
    // Second way:
    worker.addEventListener('message', function (e) {
    	console.log(e.data); // Log the data passed
    });
    

    It’s your choice which method to use. Either way, the function’s parameter will be an event object, and the data you sent using postMessage() will be passed via the data property of this event.


    External Scripts and Libraries

    Okay, but what if we have to use some external library? We don’t have access to the DOM or the global scope, so we can’t just inject the script.

    Of course we don’t need to – there is a function for that. It is called importScripts() and it accepts one or more arguments: script names to load inside the scope of the Worker. You should be aware that scripts passed into this function are loaded in a random order, but they will be executed as specified and script execution will be paused until they are loaded.

    
    
    importScripts('one-lib.js'); // Loads one script
    importScripts('first-lib.js', 'second-lib.js', 'third-lib.js'); // Loads three scripts
    

    You can use importScripts anywhere in your code, making it easy to create JSONP requests inside the Workers, as we will do in the following example.


    Example: Workers in Action

    Right, so now you probably want to see a Worker in action. Instead of showing something fairly useless, like obtaining primes or Fibonacci numbers, I’ve decided to make something that you will maybe use after a few changes.

    The example script (I’ve included the Worker’s code only, the rest is easy to do) will get the last 100 Tweets from @envatoactive (we need to set the count to 121 instead of 100, as Tweeter API is sending fewer tweets than requested – don’t ask me why, I don’t know).

    Here’s the code that would go inside the actual Web Worker script file:

    
    
    // Helper function for processing the data
    var process = function (data) {
    	// Iterate through the data; we know it's an array, so it's safe
    	for (var i = 0, v; v = data[i]; i++) {
    		// And pass Tweet's text to the page
    		self.postMessage({ text: v.text });
    	}
    	// After work is done, let the page know
    	self.postMessage("finished");
    }
    
    // Attach event listener to handle messages
    self.addEventListener('message', function (event) {
    	// Check if command sent was 'start'
    	// Not necessary here, but may be useful later
    	if (event.data == "start") {
    		// Reply to the page that we started the work
    		self.postMessage("started");
    		// Core of the script, get the Tweets
    		// The callback parameter specifies the function to execute after the request is done
    		// (We call the process() function, defined above.)
    		// Count needs to be 121 because Tweeter API is sending lower amount of data than requested
    		importScripts("http://twitter.com/statuses/user_timeline/envatoactive.json?callback=process&count=121&quot ;) ;
    	}
    });
    

    It should be easy to understand how this all works from the comments. This lets your app load all the tweets in the background, using a separate thread.

    Now try inserting the following equivalent code, which doesn’t use web workers, into the head of an empty page instead, and note the delay. (It’s still small, but imagine if you were getting not 100 but 100,000 Tweets):

    
    
    <script type="text/javascript">
    	var process = function (data) {
    		// Iterate through the data; we know it's an array, so it's safe
    		for (var i = 0, v; v = data[i]; i++) {
    			// And log Tweet's text to the console
    			console.log(v.text);
    		}
    	}
    </script>
    <script src="http://twitter.com/statuses/user_timeline/envatoactive.json?callback=process&count=121"></script&gt;
    

    Conclusion

    As you can see, web workers offer you a simple way to remove lag from your GUI and move complicated calculations or networking to separate threads.

    I hope you learned something new from this article – maybe you will use Workers in your next project? If you have any questions or problems please comment below.


  6. Ashish Bogawat says:
    June 14, 2012 at 11:19 am

    Last time I did a critique, I suggested that Google Calendar was by far one of the last standing dedicated calendar web apps out there. This time around we look at a probable competitor: Teamup Calendar. Like Google’s offering, Teamup Calendar aims for the calendar-based scheduling app domain. Let’s see how this web based calendar app stacks up and whether it stands on its own as a viable alternative.


    Getting In

    Once I set out to give the app a try, the first hurdle I had to cross was figuring out how to get in. Unlike the standard “Sign Up” or “Register” links, the home page starts with three main “call to action” buttons: “Login with Facebook” (which I usually breeze past for a whole bucketful of reasons), “Live Demo” and “Create Calendar”. Now the Live Demo is pretty clearly going to be a dummy setup, and I don’t know if the app will let me create my own Calendar without first logging in – which is a well understood norm in web apps.

    Assuming you brave it and hit the “Create Calendar” button, the next page asks you to name your calendar and provide your e-mail ID. I assumed – again based on my experience with web apps in general – that I was going to be sent a password in mail which I could use to log into my new calendar. Turns out, all you get are a couple of links and a warning not to lose them. The links are to an administrator version and a user version of the calendar. What’s the difference, you ask? None explained at this point. Looks like I’m going to have to dig deeper.


    Familiarities Galore

    Let me get this out of the way right off the bat: if you have used Google Calendar before, you are going to feel right at home with the Teamup Calendar interface. The same mini month calendar on the left, list of calendars below it, views at the top-right and the actual calendar in the rest of the space. If anything, the Teamup version seems more optimized because it utilizes the space Google wastes in its monstrous header. Also, I found the overall color scheme and visual hierarchy much clearer than Google Calendar.

    One thing I did find very weird is that the calendar name I entered when creating the calendar appears at the top, while the actual calendar name defaults to “Calendar 1″. Sure, I can edit the name and add more calendars, but since I got here through a “Create Calendar” workflow, I expected the same of my calendar to be that. The way it works right now, I should have been asked to “Create a Context” for my calendars – like my company’s name, personal space, etc. – a superset that contain multiple calendars.

    What I sorely missed right away was a way to quickly add events to the calendar using a text field and natural language parsing. The only way to add an event is to click the right location on the calendar and add the necessary details in the box. To its credit, Teamup makes the event entry box much clearer than Google’s version. Inside is the same old “what, when, who, where” routine. There is a “More…” in this box that I expected would give finer control over the event details; instead it just opens up a text area to add notes for your event. So basically the “More…” button opens up a “Notes” section.


    A Simplistic Approach to Collaboration

    Teamup takes a very different approach to most other collaboration apps out there. There is no registration involved, so pretty much anyone can join in almost seamlessly. Remember how I mentioned about the two links you get when you create a calendar? Turns out, everyone with access to those links can collaborate on a calendar either as an administrator or a regular user. Admins have the ability to add or remove calendars, change display settings and create or edit user groups with specific access restrictions. Users, on the other hand, can only view events, or add/edit them based on what privileges have been assigned to the URL they have.

    I like this approach because it completely gets rid of the registration process for each individual user making it dead simple to add new team members to a calendar. For a small team like mine, this makes perfect sense. On the downside, you don’t get the usual perks associated with the system knowing each individual user. For example, there is no way to tell which team member added a certain task, and there is nothing preventing a miscreant on the team from messing around with the schedule of the rest of the team for whatever reason.


    Missing Touches

    Despite how optimized the interface is, the app itself does not feel as snappy as it should. Adding and editing calendars, for example, takes up an entire page, forcing a page refresh every time I want to do either. Ideally, it should be something one can do within the context right there on my calendar view. The app also lacks a number of subtle interface touches that could make the experience so much more seamless. Here are a few things I was surprised to see in an app in this day and age of dynamic, snappy user experiences:

    • When editing the time for an event, the dropdown always starts from the first hour of the day instead of the currently selected time slot.
    • There is no indication of the current time on the Week & Day calendar views. Just a small red line to state what the current time of day is can make a huge difference in a user’s ability to quickly glance through their events for the day.
    • In the Event Details box, hitting Enter after typing something does nothing. I found myself doing this often by practice.

    When working with others on the same calendar, updates made by one user do not reflect for others till one manually refreshes the page. This means multiple team members could end up editing an event with only the last one to change having it their way. This could be a trivial issue for some teams, but a deal breaker for others, depending on their particular use cases.


    Wrapping Up

    Teamup Calendar brings a very interesting frictionless approach to collaboration on calendars, along with a minimalistic feature set that might be just enough for small teams looking for a quick way to manage meetings and schedules. Although it has its downsides in terms of the overall user experience, nothing stands out as a show stopper unless you need ironclad control for mission critical situations. Also, in this era where smart phones are becoming an integral part of people’s information management routines, the use cases for a web-only app are pretty limited.

    I am myself going to give the app a fair try with my team at work. It seems to have just what we need and nothing more. How well it works for us and whether we are able to look through its limitations as a team, only time will tell.


  7. Vũ Hoàng Minh says:
    June 14, 2012 at 12:17 pm

    In this tutorial we’ll learn how to load and display a 3DS model file in Flash, using Away3D 4.0 beta and Stage3D’s GPU hardware acceleration.


    Final Result Preview

    Let’s take a look at the final result we will be working towards:

    Click to download the demo files.


    Introduction

    To use this tutorial you will need to have a 3D model (exported as a .3ds file) and its texture (as an image file).

    I created a simple 3D model of a teapot in Autodesk 3DS Max, and exported it to a file named Teapot.3DS along with its separate texture file, teapot.jpg. You can find both files in the source download.

    You will need to download a package SWC of Away3D 4.0.0 beta (you can also find this SWC in the source files).

    And you need to know that Away3D 4.0.0 beta version uses the new Stage3D features of Adobe Flash, meaning it can use the GPU for 3D graphics acceleration.

    We are going to build this demo using pure AS3, compiled in FlashDevelop (read more about it here). FlashDevelop is a free AS3 IDE, although it is Windows only. If you prefer to use another IDE, you will still be able to follow this tutorial.


    Step 1: Create a New Project

    If you don’t already have it, be sure to download and install FlashDevelop. Open it and start a new AS3 Project.

    Create a New Project in FlashDevelop

    FlashDevelop will create a blank AS3 template project for you. We’ll use the Main class for all our code.


    Step 2: Compiler Options

    Go into the Project menu, choose Properties and change a few options:

    1. Set the target platform to Flash Player 11.1.
    2. Change the SWF size to 550x400px.
    3. Set the background color to black.
    4. Change the FPS to 40.
    Target Flash 11

    If we want to run this tutorial from the HTML embed code, we have to include the parameter wmode=direct in the parameters of the Flash object in the HTML file. It’ll look like this:

    
    
    <object width="550" height="400" data="3DViewer.swf" type="application/x-shockwave-flash" wmode="direct">
    <param name="src" value="3DViewer.swf" />
    <param name="wmode" value="direct" />
    </object>
    

    In this tutorial we’ll load the 3DS file from local storage (rather than from a web server), so we must change some settings in the Compiler Options tab. Set Use Network Services to False.

    Local file load


    Step 3: Add Away3D Library

    Get away3d-core-fp11_4_0_0_beta.swc from the source files, or download it from Away3D’s site.

    Copy that file to your project’s lib directory.

    In FlashDevelop, right-click the SWC file, and choose Add to Library.

    Add Away3D Library


    Step 4: Imports

    Now let’s start coding with our Main.as file. To begin, we have to import the necessary library files for program to setup the Away3D engine and the Flash components. There are quite a few, so let’s get them out of the way:

    
    
    // 3DS Model Viewer Tutorial
    // by Vu Hoang Minh - http://www.3dgameflash.com
    // Created for active.tutsplus.com
    
    package
    {
    	//Away3D classes
    	import away3d.cameras.lenses.PerspectiveLens;
    	import away3d.containers.ObjectContainer3D;
    	import away3d.containers.View3D;
    	import away3d.entities.Mesh;
    	import away3d.events.LoaderEvent;
    	import away3d.loaders.Loader3D;
    	import away3d.loaders.parsers.Max3DSParser;
    	import away3d.materials.TextureMaterial;
    	import away3d.textures.BitmapTexture;
    
    	//General Flash classes for display and interaction
    	import flash.display.Bitmap;
    	import flash.display.MovieClip;
    	import flash.display.Shape;
    	import flash.display.Sprite;
    	import flash.events.Event;
    	import flash.events.MouseEvent;
    	import flash.geom.Vector3D;
    	import flash.text.TextField; 
    
    	//Classes for loading the 3DS file from the hard drive
    	import flash.display.SimpleButton;
    	import flash.events.IOErrorEvent;
    	import flash.net.FileFilter;
    	import flash.net.FileReference;
    	import flash.net.URLRequest;
    	import flash.system.Security;
    

    Step 5: Initialize Program

    Let’s get started. We’ll declare the variables that we’re going to need, initialise the 3D engine, and set up the “Browse” button and debug output text field.

    
    
    	public class Main extends Sprite
    	{
    		private var file:FileReference;
    		private var view3d:View3D;
    		private var loader:Loader3D;
    		private var labelDebug:TextField;
    		private var object3d:Mesh;
    
    		public function Main():void
    		{
    			//boilerplate loading code
    			if (stage)
    				init();
    			else
    				addEventListener(Event.ADDED_TO_STAGE, init);
    		}
    
    		private function init(e:Event = null):void
    		{
    			//allow us to load a local file
    			Security.allowDomain("*");
    
    			removeEventListener(Event.ADDED_TO_STAGE, init);
    
    			//init 3D engine
    			view3d = new View3D();
    			view3d.camera.lens = new PerspectiveLens();
    			view3d.camera.z = 100;
    			addChild(view3d);
    
    			//3D loader
    			initLoader();
    
    			//Button to open file browser
    			var mcBrowse:MovieClip = new MovieClip();
    			mcBrowse.graphics.beginFill(0xeeeeee);
    			mcBrowse.graphics.drawRoundRect(1, 2, 100, 25, 7, 7);
    			mcBrowse.graphics.endFill();
    			var labelBrowse:TextField = new TextField();
    			labelBrowse.text = "Browse";
    			mcBrowse.addChild(labelBrowse);
    			mcBrowse.mouseChildren = false;
    			mcBrowse.buttonMode = true;
    			labelBrowse.x = 25;
    			mcBrowse.addEventListener(MouseEvent.CLICK, onClick_mcBrowse);
    			addChild(mcBrowse);
    
    			//debug output
    			labelDebug = new TextField();
    			labelDebug.text = "...";
    			labelDebug.textColor = 0xff0000;
    			labelDebug.selectable = false;
    			labelDebug.y = mcBrowse.height / 2;
    			labelDebug.width = 600;
    			addChild(labelDebug);
    
    			//file
    			file = new FileReference();
    		}
    

    In lines 25-29, we initialise the Away3D graphics components. We create a new View3D (a container that stores the camera and objects), configure its lens and camera, and add it to the display list.

    After that we make a Browse button: we draw its background, add its label, configure it, and add it to the display list.

    To make it easy to keep track of the 3DS loading state, we make a debug label, which is a simple text field.

    Finally, we initialise a FileReference instance to handle browsing for the 3DS file.


    Step 6: Initialise 3D Loader

    The next important thing we must do is create a 3D model loader.

    
    
    	private function initLoader():void
    	{
    		//clear all
    		removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    		while (view3d.scene.numChildren > 0)
    		{
    			view3d.scene.removeChild(view3d.scene.getChildAt(0));
    		}		
    
    		//init new 3D loader
            	Loader3D.enableParser(Max3DSParser);
    		loader = new Loader3D();
    		loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onComplete_loader);
    		loader.addEventListener(LoaderEvent.LOAD_ERROR, onError_loader);
    		view3d.scene.addChild(loader);
    
       		//config camera
    		view3d.camera.lookAt(loader.position);
    	}
    

    This function has three sections:

    1. First, we clear everything out, in case our program has run before.
    2. After that, we initialise a new Loader3D instance, and add listeners to it which trigger when it fires an Error when a 3D file has completely loaded. To make it visible, we add it to the View3D‘s scene.
    3. To ensure that we can actually see the object once it has loaded, we tell the camera to look at it.

    Step 7: Handle All Events

    Next, we’ll add all the event handler functions, which all have something to do with loading the 3DS file.

    
    
    		private function onClick_mcBrowse(e:MouseEvent):void
    		{
    			file.browse([new FileFilter("3DS", "*.3ds")]);
    			file.addEventListener(Event.SELECT, onFileSelected);
    			file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
    			file.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    		}
    
    		private function onSecurityError(e:Event):void
    		{
    			labelDebug.text += ".Security Error!";
    		}
    
    		private function onIOError(e:IOErrorEvent):void
    		{
    			labelDebug.text += ".File not found Error!";
    		}
    
    		private function onFileSelected(e:Event):void
    		{
    			labelDebug.text = "File :" + file.name;
    			file.removeEventListener(Event.SELECT, onFileSelected);
    			file.addEventListener(Event.COMPLETE, onFileLoaded);
    			file.load();
    		}
    
    		private function onFileLoaded(e:Event):void
    		{
    			file.removeEventListener(Event.COMPLETE, onFileLoaded);
    			initLoader();
    			loader.loadData(e.target.data);
    		}
    
    		private function onError_loader(e:LoaderEvent):void
    		{
    			trace("Error loading File...");
    			labelDebug.text += " .Loading Error";
    		}
    
    		private function onComplete_loader(e:LoaderEvent):void
    		{
    			trace("3D File loaded");
    			labelDebug.text += " .Complete.Rendering...";
    			loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETE, onComplete_loader);
    			loader.removeEventListener(LoaderEvent.LOAD_ERROR, onError_loader);
    			object3d = Mesh(loader.getChildAt(0));
    			view3d.scene.addChild(object3d);
    			loader.dispose();
    			loader = null;
    
    			addEventListener(Event.ENTER_FRAME, onEnterFrame);
    		}
    

    When the user clicks the Browse button, we display the File Browse Dialog, which uses a FileFilter to restrict the files shown to those with a .3ds extension. We add several event listeners to this dialog, so that we can detect when a file is detected or if an error occurs.

    After a file has been selected, we load it to the FileReference instance that we initialised earlier. Once it has loaded, we call the initLoader() function that we defined in the previous step, which loads our 3D model.

    At this time, there are two possible states we can catch:

    • One is the “error” state, which implies that our program cannot load the 3D model file (perhaps the path is incorrect, or the map texture file is wrong…).
    • The other is the “loaded successfully” event, upon which we cast the loaded file to a Mesh and add it to the scene of View3D.

    To free up our memory and reuse it later, we should dispose of our loader.

    At the end of above code (assuming the file loaded) we add an ENTER_FRAME event, which we’ll use to render the object. We’ll write that handler now.


    Step 8: Start the Render Loop

    Now that everything has been initialized, we are ready to render it all. Every frame, we’ll make the 3D object yaw (rotate) and call the render() function of View3D to update the display.

    
    
    		private function onEnterFrame(e:Event):void
    		{
    			object3d.yaw(1);  //yaw by one unit
    			view3d.render();
    		}
    

    Step 9: Compile and Run!

    Almost done! Compile your SWF with F5, and see your final result. So interesting, right?

    You can do than just rotate the object – try calling object3d.moveFoward(10) or object3d.pitch(1). You could even do this in response to a mouse movement or a key press.

    Just for reference, and to ensure that you’ve used the correct filenames and locations for everything, here is what your FlashDevelop project should look like:

    Just for reference, and to ensure that you've used the correct filenames and locations for everything

    Conclusion

    We have finished first basic 3D tutorial on newest 3d Accelarate function of Adobe. I warmly welcome all readers to get in touch with me via the comments, or through my website, any time. Thanks for reading. See you next time. Good luck and HAVE FUN!


  8. Ashish Bogawat says:
    June 14, 2012 at 12:26 pm
    This entry is part 1 of 3 in the series Flash Tips and Best Practices for Designers

    The first time I used Flash was around 13 years ago. It was version 3 and Flash was hailed as the fancy new vector based animation tool that would soon take the web design world by storm. Over the years, Flash has grown into a fully-fledged rich application development tool, packed to the brim with ActionScript goodness.

    What a lot of people seem to be forgetting though, is how much Flash is still a designer’s tool, letting us create artwork and animations the old-fashioned draw-and-move-around way.

    May of 2011

    Let’s start with what pretty much anyone would start with in Flash (or any design application for that matter) – drawing. Be it drawing regular shapes or tracing lines, drawing is one of the most fundamental actions in Flash. What makes Flash unique though, is the way it handles shapes. It behaves quite unlike any other vector drawing tool out there, and is either loved or hated by many for it. Of course, there are advantages and disadvantages to segregating each part of an object for independent editing. Let’s take a look at some quirky little things that Flash does and how to use them to our best advantage.

    Although this post was written for Flash Professional CS5, most of the tips should work just fine in older versions. I will try and make it a point to highlight wherever something is very specific to the latest version of Flash.


    Regular vs. Primitive Shapes

    Typically, when you draw a regular shape (a rectangle or an ellipse) in Flash, it creates a patch with the selected fill and stroke properties. You can then select the fill and/or the stroke indidually and edit their properties. In Flash CS3, Adobe introduced what they call ‘primitive’ shape tools. Unlike the default shape tools, which separate the stroke from the fill, these create a shape that is selectable and editable as a whole.

    Primitive Shapes

    Although for veteran Flash designers this can be an irritating change, it brings with it a level of control that was unseen in Flash before this version. You can suddenly change properties of the object numerically through the properties panel, add rounded corners, and convert circles to pies with decimal point accuracy. There is very little reason to go back to the traditional shape tools once you have used the primitives, yet many designers I know continue to work the old-fashioned way. Part of the problem could be Adobe’s dumbfounding decision to retain the simple shapes as the default tools, burying the primitives inside a dropdown in the toolbar.

    Case study: Create an accurate pie chart using primitive shapes

    Let’s try using the primitive shapes in a real-life scenario where using the traditional shape tools would have proven to be an exercise in hair-pulling. Say you want to create an accurate pie chart using real numbers – market shares for mobile operating systems in 2010, for example.

    Once we have the percentages (that add up to 100), we will multiply each with 3.6 to equate them with the total 360 degrees in a circle. Then, it’s a simple matter of pasting six circles on top of each other and assigning the appropriate starting and ending angles for each one based on our calculations. See the math in the table below, as well as the properties for one of the pies, for a better idea.

    Pie chart using primitive the ellipse tool

    Freely Transform Shapes With the Mouse

    By their very nature, objects in Flash are freely editable in all kinds of ways. You can select a shape’s fill or outline, drag it around and it will affect all other shapes in that area as long as they are on the same plane. What happens when you select and/or drag an element though, depends on what you click and where. Let’s look at the various possibilities:

    Transform Types
    • Clicking and dragging a shape that is already selected will simply move it to wherever you let the mouse go.
    • Clicking and dragging inside a shape’s fill – even if it is not selected – will select and move it. Note that this will only move the fill and not the stroke. If you drop the fill on top of the stroke, any part of the stroke that comes under the fill will be deleted.
    • Clicking and dragging on a straight line will make it a curve. How long away you drag the line defines how steep the curve is.
    • Clicking and dragging on an existing curved line will alter its curvature.
    • Clicking and dragging a corner point will only move that point. If snapping is on, the point will snap to any other corner nearby.

    Case Study: Make waves the easy way

    Let’s try and apply this knowledge to make complex wavy lines the simple way – using straight zigzag lines. Start by simply drawing straight lines to define the approximate size and shape of the wave. Make sure the line is not selected. Then, click and drag each line segment to make a curve for the wave. Lastly, select the corner points and move them up or down till they snap to make the curve seamless on both sides.


    Smooth Rounded Corners

    For some reason best known to Adobe, they have never addressed an inherent problem with rendering rounded corners in Flash. If the outline of a rounded rectangle is an odd number (1, 3, 5, etc.), the corners tend to have these ugly artifacts that make the image look blurred. A typical hack I’ve used and have seen being used is to make sure the outlines on rounded rectangles are always 2, 4, 6 or any even number. It still doesn’t work if your shape is on a sub-pixel co-ordinate – either x or y co-ordinate is in decimals (2.6, 4.12, 98.57, etc.) – but that’s an easier problem to solve.

    Blurriness with rounded corners

    But what if I need the outline to be a single pixel? One workaround I recently found and have been extensively using since is this:

    1. Draw your rectangle using the primitive rectangle tool and set it to whatever size you need. Make sure the X and Y co-ordinates of the rectangle are each whole numbers without decimal points in them.
    2. Change the roundness to your preference.
    3. Fill this object with the color you need for your rectangle’s outline.
    4. Copy and paste the rectangle in place, then nudge it one pixel to the right and down.
    5. Reduce the height and width of the new rectangle to 2 pixels less than the original one, and change the fill to whatever color you need for the shape.
    6. We’re not done yet. Reduce the roundness of the new rectangle to one less than the outline. Because Flash assigns roundness by pixels and not by percentage, having the same roundness value for both rectangles causes minor inconsistencies towards the center of each curvature.
    Fixing the blurred rounded corners

    Although this technique should work in most cases, it is not without its pitfalls. It’s of no use, for example, in situations where you need an object to be translucent. Reducing the alpha of the fill rectangle will only show more of the outline color from the rectangle behind. A hack to get around it would be to break both rectangles (convert them to regular shapes).

    You might also consider using stroke hinting to guide you when drawing strokes on the stage.


    Distribute Gradients Across Objects

    Who doesn’t like gradients? Designs these days are pretty incomplete without at least a subtle hint of a gradient to give it a realistic and often contemporary feel. The problem with how Flash handles shapes though, is that each self-contained piece is a shape and has its own properties. You cannot apply gradient fills to groups of objects and there is no way to ‘connect’ two disparate shapes. What happens, then, when you need a gradient to span across multiple objects – say all words in a custom-made logotype?

    Well, ‘Lock Fill’ to the rescue. When using the ‘Paint Bucket’ tool, you will see an icon at the bottom of the tool palette with a gradient and a lock on it. Select the shapes you need to fill, toggle the ‘Lock Fill’ icon, select a gradient from the fill color palette on and click inside any of the selected shapes. Don’t worry if you don’t see the entire gradient applied. More often than not the locked fill spans way beyond the selected shapes and you need to use the ‘Gradient Transform Tool’ to resize the gradient the way you need it.

    Locked gradient fill applied to multiple objects

    This technique is not without its issues though. Here are some things to remember when using locked fills:

    • Locked fills only work with regular shapes. If you used primitive shapes, you will need to break them apart to be able to apply a gradient across multiple objects.
    • If you select one of a group of shapes with a locked fill, and then change its properties, that shape will be de-linked from the group.
    • Like I mentioned before, the bounds of a gradient in a locked fill tend to be way bigger than the area of the shapes. Just use the ‘Gradient Transform Tool’, select any one of the shapes and adjust the bounds of the gradient. You may need to zoom out a bit to be able to see the gradient controls.

    Play Around With Custom Strokes

    Flash comes with a set of stroke styles by default – Solid, Dashed, Dotted, Ragged, Stipples and Hatched – which work fine for the most part. For situations where you need more control over the stroke though, there is a pretty darn powerful stroke editor that comes with Flash. To really start playing around with your strokes, click the edit icon next to the ‘Style’ list in the ‘Properties’ panel of a selected stroke.

    Editing the dashed line with fine control

    Let’s say you needed a dashed line, but the dashes are currently way too close in the default ‘Dashed’ style. In the ‘Edit Stroke’ panel, simply increment the number in the second input field next to ‘Dash’ till you get the effect you need. And while you are it, check the ”Sharp corners’ box. If you’ve ever been bugged by the weird corners you get with the default dashed line in Flash, this fixes it.


    Helpful Hints

    Here are some more helpful hints to help optimize your workflow when working with shapes in Flash.

    • Because of the way Flash handles shapes, clicking an outline only selects a section of the line, not the whole thing. Double-click a section of the stroke to select all connected sections at once.
    • Double-clicking a fill selects the fill and all line sections around it.
    • If you would like to divide a shape with some space in between the two divisions:

      1. Draw a line where you need the division.
      2. Adjust the thickness of the line depending on how much space you need between the divisions.
      3. Make sure the line is selected; then go to ‘Modify > Shapes’ in the menu bar and select ‘Convert Lines to Fills’.
      4. Delete the line.

    • By default, lines have rounded ends and corners in Flash, but if you need the edges to be hard for some reason you can set them by changing the ‘Cap’ and ‘Join’ properties in the ‘Properties’ panel for a selected line.

    Conclusion

    And that’s a wrap for the first part of this series on Flash best practices for designers. I hope these tips will help you improve & optimize your workflow in Flash over the long term. Please feel free to share your own tips & best practices in the comments section. I will be back with the next part of this series with tips on how to manage your text and symbols in Flash.


  9. Michael James Williams says:
    June 14, 2012 at 12:26 pm

    Google I/O 2012 is less than a month away, so I thought it’d be appropriate to look back at a great talk from Google I/O 2011: Chrome Dev Tools Reloaded, presented by Paul Irish and Pavel Feldman. If you’re a JavaScript developer making games or apps for the browser, you should watch this.


    Watch the Video

    Paul Irish is, among many things, a member of the Google Chrome developer relations team, and Pavel Feldman is a Google software engineer on the Chrome team.

    In this talk, they cover the Chrome Developer Tools, which let you edit the DOM inline, alter CSS rules in a page on the fly, call JavaScript manually, set breakpoints, and more. If you’ve never used the tools before (or if you’ve just muddled your way through with them, discovering new tricks as you go), I recommend watching this video to help you get the most out of them.


    Further Resources

    Here are some other great resources along the same lines:

    • GoogleDevelopers on YouTube, which features plenty more videos for developers.
    • Paul Irish’s blog post about the talk.
    • Chrome Developer Tools Cheat Sheet on GitHub (it’s forkable).
    • Official overview and documentation for Chrome Developer Tools.
    • Chrome Canary, a build of Chrome with the latest features (beyond the current stable build).


  10. David Appleyard says:
    June 14, 2012 at 12:30 pm

    Each month, we bring together a selection of the best tutorials and articles from across the whole Tuts+ network. Whether you’d like to read the top posts from your favourite site, or would like to start learning something completely new, this is the best place to start!


    Psdtuts+ — Photoshop Tutorials

    • Quick Tip: Create a Metallic Copper Text Effect Using Layer Styles in Photoshop

      Quick Tip: Create a Metallic Copper Text Effect Using Layer Styles in Photoshop

      In this tutorial we will explain how to create a metallic copper text effect using layer styles in Photoshop. Let’s get started!

      Visit Article

    • How to Draw a Leica Camera in Photoshop

      How to Draw a Leica Camera in Photoshop

      Leica is considered one of the most prestigious camera brands. In this tutorial, we will draw one of the most notable Leica cameras in Photoshop, the Leica M1. Let’s get started!

      Visit Article

    • Create a Tasty 3D Typographic Illustration – Tuts+ Premium Tutorial

      Create a Tasty 3D Typographic Illustration – Tuts+ Premium Tutorial

      If you’ve got a sweet tooth, then we’ve got a mouth-watering tutorial for you. In this Tuts+ Premium tutorial, author Mark Mayers will show you how Photoshop CS6 Extended’s new 3D tools can be utilized to create a typographic illustration that includes lots of sugary treats. This tutorial is available exclusively to Tuts+ Premium Members.

      Visit Article


    • Nettuts+ — Web Development Tutorials

    • 10 Things I Learned While Interning at YUI

      Things I Learned While Interning at YUI

      For eight months, I had the opportunity to intern with the YUI Team at Yahoo, while I was completing my engineering degree. Today, I’d like to share the top ten things that I learned from my experience with YUI.

      Visit Article

    • Coda 2: Reviewed

      Coda 2: Reviewed

      Well, it happened; Panic finally released the long-awaited version two of their popular code editor, Coda. But does it live up to the hype? Well, that depends on what type of coder you are. Read the full review after the jump!

      Visit Article

    • 3 Key Software Principles You Must Understand

      Key Software Principles You Must Understand

      If you’re in software development, new techniques, languages and concepts pop up all of the time. We all feel those nagging doubts every now and then: “can I keep up with the changes and stay competitive?” Take a moment, and sum a line from my favourite movie, Casablanca: “The fundamental things apply, as time goes by.”

      Visit Article


    • Vectortuts+ — Illustrator Tutorials

    • Create a Vintage Vector Framed Silhouette Design

      Create a Vintage Vector Framed Silhouette Design

      In today’s tutorial I’m going to collaborate with a great friend of mine, Ashley Benson and show you how to create a Victorian styled Silhouette. She’s been great to give me this wonderful sketch specifically for our vintage vector art tutorial, so feel free to download it as part of your Tuts+ Premium membership to practice on. Learn basic techniques on creating a detailed, framed silhouette inspired by Victorian vintage postcard designs using scatter brushes, patterns and more. Using these techniques you can create your own vintage illustrations.

      Visit Article

    • Quick Tip: Microstock Illustrations with Corel Draw, Tricks and Tips

      Quick Tip: Microstock Illustrations with Corel Draw, Tricks and Tips

      With the vector software Corel Draw you are able to draw everything you can imagine. However, if you are using it to create illustrations for the microstock agencies – there are some issues that you must take into consideration. The problem comes with the industry requirement to provide an EPS (Encapsulated PostScript) file, which is mandatory for almost all agencies. See, EPS is Adobe standard and Corel developers don’t like Adobe standards very much…

      Visit Article

    • From a Logo to Business Card, How to Make a Self Promotion Set

      Logo and Identity Design Session

      Audiences identify with effective logos and well composed brand identities. Learn how to craft creative logo designs with impact. In this Creative Session, we have a compilation of inspiring logo design and branding material.

      Visit Article


    • Webdesigntuts+ — Web Design Tutorials

    • Quick Tip: Rounded Corners Done Right

      Quick Tip: Rounded Corners Done Right

      This is going to seem like a no-brainer to many of you, but I see it happening so often I figured it was worth bringing up. We’ll call this issue improperly nested corners; a small detail which can ruin an otherwise brilliant design!

      Visit Article

    • Create a Customized HTML5 Audio Player

      Create a Customized HTML5 Audio Player

      During this tutorial I’m going to be introducing you to HTML5 audio and showing you how you can create your own player.

      Visit Article

    • Employing AIDA Principles in Web Design

      Employing AIDA Principles in Web Design

      In this article we’ll discuss how we can use design to implement the principles laid out by AIDA (the marketing acronym, not the Italian opera) and help create sales-orientated web pages.

      Visit Article


    • Phototuts+ — Photography Tutorials

    • Simplify and Challenge Your Creativity Using a Single Lens – Tuts+ Premium

      Simplify and Challenge Your Creativity Using a Single Lens – Tuts+ Premium

      We have another Photo Premium tutorial exclusively available to Premium members today. In this tutorial, try going out on a shoot with only one lens to limit us and force us to think creatively. Luckily, we’ll be guided by professional photographer Simon Plant. Learn more after the jump!

      Visit Article

    • Easy Tips for Shooting the Moon

      Easy Tips for Shooting the Moon

      Pictures of a big moon over a landscape are many times the result of a double exposure. Even when the moon comes closer to Earth, as it did recently, it is too small to fill the frame with normal gear. Still, there are ways to get around the thousands of miles that separate us and our big nightlight.

      Visit Article

    • Building a Narrative Through Photojournalism

      Building a Narrative Through Photojournalism

      Telling visual stories is the work and craft of the photojournalist. I remember it from the first hard news story I covered, back in 1980: a bank robbery that completely defined my future.

      Visit Article


    • Cgtuts+ — Computer Graphics Tutorials

    • Building The Caterpillar 797 In 3D Studio Max – Creating The Tires, Rims, Cabin And Bridge

      Building The Caterpillar 797 In 3D Studio Max – Creating The Tires, Rims, Cabin And Bridge

      Today we’re kicking off an awesome new tutorial series by Sasa Posloncec where you’ll learn how to model the ridiculously huge Caterpillar 797B mining dump truck. Spanning three parts this series will give you an in-depth look at what it takes to create a fully realized vehicle model in 3D Studio Max using blueprints and photo reference. As Sasa walks you through the creation of each part, you’ll learn how to work with Max’s Edit Poly modifier, spline tools and much more!

      Visit Article

    • Image Based Lighting: The Complete Workflow with Maya, HDR Shop & Photoshop

      Image Based Lighting: The Complete Workflow with Maya, HDR Shop & Photoshop

      So Image Based Lighting…. What is it, and how can you use it to your advantage? Get the answers in this tutorial from James Whiffin where you’ll not only learn about implementing IBL into your projects, but how to setup and shoot your very own high dynamic range images, a topic rarely seen in tutorials.

      Visit Article

    • Modeling A Modern Interior Scene In Blender

      Modeling A Modern Interior Scene In Blender

      In this tutorial we will be modeling an interior scene from a reference photo. It is written for the complete beginner, you’ll learn how to setup a background image and how to match the camera to it, as we follow a very simple workflow for building up the scene with a variety of basic modeling techniques that will give you a very good basis on how to approach any kind of modeling.

      Visit Article


    • Aetuts+ — After Effects Tutorials

    • Fantastic Facial Motion Capture – Tuts+ Premium

      Fantastic Facial Motion Capture – Tuts+ Premium

      In this tutorial, I will be sharing with you how to achieve 2D facial motion capture in After Effects. The technique involves acquiring motion data from dots on a face, and using that motion data to manipulate the position of puppet pins on an image that you want to animate. It’s a very useful way of quickly creating detailed animations, and characterizing inanimate objects, like the rock face in the intro. It’s also possible to do face replacement.

      Visit Article

    • Muted Color Grading And A Vintage Film Burn Using Fractal Noise

      Muted Color Grading And A Vintage Film Burn Using Fractal Noise

      In today’s tutorial I’ll be showing how to take DSLR footage and give it the popular “Muted” color grade. After we cover the color grading, I’m gonna show you how to create a film burn effect from scratch using “Fractal Noise.”

      Visit Article

    • How To Create A Stupendous Stuttering Jumper Punch

      How To Create A Stupendous Stuttering Jumper Punch

      In this tutorial we will learn how to create an advanced and well composited Jumper Punch by using a matte, some displacement, and smoke to add style to the final effect. Throughout the tutorial, we will be using basic expressions. We’ll learn to position the jumps in time and space and give the illusion of a jumper disappearing and reappearing with a trajectory. Let’s “Jump” in… :)

      Visit Article


    • Audiotuts+ — Audio & Production Tutorials

    • 3D Mixing Part 7: Mastering, The Final Chapter (Part 2)

      D Mixing Part 7: Mastering, The Final Chapter (Part 2)

      In the final installment of the series, we are going to look at the final effects on the signal chain (Master EQ, Master Reverb, Master Limiter), and discuss the various final print options.

      Visit Article

    • Quick Tip: How to Make a Snare Roll Generator

      Quick Tip: How to Make a Snare Roll Generator

      Today I will show you my new gadget, and teach you how to make it. A snare roll is an important part of a song. It can be used in many situations: as a creative element of a song or introducing something important like a breakdown. My new toy will reduce the time it takes to create one.

      Visit Article

    • 10 Cures For A Songwriting Slump

      Cures For A Songwriting Slump

      Sooner or later, even the most inspired and prolific songwriter will stumble into that dreadful and frightening abyss known as writer’s block. To call it frightening is truly not an overstatement when one is attempting to land a writing deal, keep a publisher happy, or best-case scenario, keep the already lucrative royalties flowing. The voice of defeat stirs in every songwriter at some point, first as a murmur and then as a blood-curdling scream.

      Visit Article


    • Wptuts+ — WordPress Tutorials

    • The Complete Guide To The WordPress Settings API, Part 8: Validation, Sanitisation, and Input II

      The Complete Guide To The WordPress Settings API, Part 8: Validation, Sanitisation, and Input II

      We’ve reached the final article of the series. In the last post, we took a look at introducing validation, sanitization, and a couple of basic input elements that we can take advantage of when building option pages.

      Visit Article

    • Quick Tip: Conditionally Including JS and CSS With get_current_screen

      Quick Tip: Conditionally Including JS and CSS With get_current_screen

      As many stated before me: “A good WordPress citizen only loads their files where they’re needed”. This principle applies both to front-end and back-end (admin). There’s no justification for loading CSS and JS files on every admin page when you only need them on one single page you created. Thankfully doing things the right way is only one function call away.

      Visit Article

    • Adding Post Series Functionality to WordPress With Taxonomies

      Adding Post Series Functionality to WordPress With Taxonomies

      Ever wrote a “post series” on your blog? If you did, you probably needed to add the links of the other parts of the series into the latest post you wrote. Each time you finished a new part, you had to update the link list of the other parts. There has to be an easier way, right?

      Visit Article


    • Mobiletuts+ — Mobile Development Tutorials

    • iOS SDK: UIKit Theme Customization

      iOS SDK: UIKit Theme Customization

      Theme customization is a great way to stand out in the App Store, but it isn’t always easy to achieve. This tutorial will teach you several basic UIKit customization tricks that will help distinguish your applications and create more memorable user experiences.

      Visit Article

    • Introduction to Unity3D

      Introduction to Unity3D

      Unity3D is a powerful cross-platform 3D engine and a user-friendly development environment. Learn how Unity3D can help you create games in this article!

      Visit Article

    • Analyzing Android Network Traffic

      Analyzing Android Network Traffic

      Network traffic analysis can be a vital part of the software debugging and testing process. This tutorial will teach you how to monitor all incoming and outgoing traffic on an Android device in order to better debug your applications!

      Visit Article


Leave a Reply

Click here to cancel reply.

search search search search search
Find an Article
Categories
  • Flash Video Training
  • Hints and Tips
  • Recommended
Please Support Our Sponsors
Recent Posts
  • Tuts+ Community Meetup in New York!
  • HTML5 Canvas Optimization: A Practical Example
  • Recreate the Cover Flow Effect Using Flash and AS3
  • Drawing Activetuts+ to a Close
  • Intro to Dart: Creating a Marquee
Tag Cloud
2011 ActionScript Active Activetuts+ Adobe animation Basic Basix Best Build Button Character Code Create Creating Critique Custom design Effect Effects Files Flash from Game Guide HTML5 Introduction Macromedia Motion Muzzle part Player Premium Professional Quick Silverlight Simple Text Tool Tutorial Tuts+ Using Video website Workshop
About Our Site:

Hey there and welcome to "Flash Video Training Source", a resource for anybody interested in learning more about Adobe's great tool. We feature educational videos, which will help you master Adobe Flash and help you get to know all of its features. We at "Flash Video Training Source" believe that video training and video... more

Why don't you follow us on Twitter and get the latest video tutorials twitted to your account. Just click on the floating twitter bar to your right!

Go Back In Time
June 2013
M T W T F S S
« Jul    
 12
3456789
10111213141516
17181920212223
24252627282930
Pretty Blank Box
top

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Archives

  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
Powered by WordPress  |  Designed by Elegant Themes  |  Lightning Fast Hosting by Site 5 Hosting