Hello, fellow Flash developer!
Did you find this page while looking for “the #Swift equivalent of this #ActionScript piece of code”? Or are you looking to transfer your #Flash skills into native #iOS development? In either case, you are in the right place.
If you have spent some time making Flash apps and coding in ActionScript, you are well on your way to knowing your way around Swift and won’t need to start from scratch. We have collected some resources that can help on your learning journey: they have been created with your experience in mind and by developers who speak your language – after all, they have made the same transition!
We have tried to systematise the available material and give you a sense of where you can start if you are new to Swift and where you can dig deeper:
- Online articles for when you need quick info on specific topics.
- Books for when you are ready to take the plunge.
- SDKs if you want to get your hands dirty right away.
1. Yeah, but is it Swift?
If you are new to Swift and need a crash course that will help you hit the ground running, start here.
YeahButIsItSwift.com offers a series of articles by Christopher Caleb, whom most of you know for his Flash, Adobe AIR and HTML5 tutorials published on YeahButIsItFlash.com and in his Flash iOS Apps Cookbook.
The series has four parts, but don’t let the modest number of posts on the website fool you. Each part covers a lot of ground with simple and easy to follow examples.
Here is what you will find inside:
– Part 1 helps you set up a Playground in Xcode – the IDE, which you will be using to create apps with Swift. The introduction to Swift starts gently with looking at its syntax and gradually leads to specific topics such as Optionals and their application in the language.
- Setting up a Playground in Xcode and writing your first line of code
- Variables and constants
- Types and type inference
- Floating-point numbers
- Printing values
- Type conversion
- Forced unwrapping
- Optional binding
- Implicitly unwrapped Optionals
- Basic operators
- Assignment operator
- Arithmetic operators
- Remainder operator
- Increment and decrement operators
- Compound assignment operators
- Logical operators
- Range operators
- for loops
- for loop
- for-in loop
- if statements
- if statement
- if-else statement
- if-else else-if statement
– Part 2 builds on your knowledge of the Swift basics learnt in Part 1 and expands it to include container types and more powerful control flow techniques. It also introduces Enums – something that’s been missing in ActionScript 3.
- More on Strings
- String interpolation
- Character indexing
- Initializing arrays
- Accessing and modifying an array
- Accessing outside an array’s bounds
- Iterating over an array
- Accessing and modifying a dictionary
- Iterating over a dictionary
- While loops
- while loop
- do-while loop
- Switch statement
- Explicit fallthrough
- Range matching
- Value binding
- Conditional statements
- Raw values
- Associated values
– In Part 3 you start writing and using functions and learn how Swift handles parameters and return values. It also presents Structs: something that is a bit like an Object in ActionScript 3, but not quite…
- Return values
- Returning tuples
- Local and external parameter names
- Default parameter values
- Variadic parameters
- Constant and variable parameters
- In-out parameters
- Instantiating a struct
- Accessing properties
- Structs are value types
- Custom initialisation
- Initializers and external parameter names
- Initializer delegation
- Computed properties
- Read-only computed properties
- Property observers
- Type properties
- Structs as constants
– Part 4 of the series takes you into the OOP realm of Swift and you learn how to use classes, how they differ from structures, how initialization and property observers work.
- Instantiating a class
- Classes are reference types
- Classes as constantsIdentity operators
- Type properties
- Property observers
- Return values
- Default parameter values
- Type methods
- The self property
Yeah, but is it Swift? was among the early tutorial series to appear online and the code in the examples works with earlier versions of Swift. There are plans for an update to Swift 3 soon, however, so watch this space.
2. Before I forget…
Once you have the basics covered, you will probably want to dip in and out of certain topics as the need arises. Craig Grummitt‘s blog, unassumingly titled “Before I forget…”, contains a series or articles which deal with some of the specifics of Swift. It also shows you how to work with user interface and manage your projects in Xcode.
Craig publishes his blog posts as notes to himself, in order to avoid a situation we are painfully familiar with: having to solve the same problem again when it sneaks up on you months after you have first found a solution for it and can’t remember what it was. Thus the blog title, you see. So it’s easy for some of these article gems to sink down the blog feed and become hard to find. We have tried to put them into categories for easier navigation – click on each category to see the topics in it:
– Language features
- Best practices differences between Swift and ActionScript3
- Communication between objects in Objective-C and Swift compared with ActionScript:
- Any vs AnyObject vs NSObject in Swift 3
- Ambiguous convenience initializers
- Func parameters in Swift 3.0
- Parameter defaults and Optional Function Parameters in Swift 3.0
- Sorting strings in Swift
- Localization playing nicely with string interpolation in Swift
– User interface
– Cookbook tutorials
– Xcode tips
But this is not all! If you find these articles useful, you will be thrilled to know that Craig has a whole book on Swift, which is pending publication very soon. More on this in a bit…
3. The Swift series
His articles and tutorials will help you understand behind-the-scenes topics like memory management in Swift and how it compares to using garbage collection in ActionScript, for example. It will also give you ideas for things you can do with graphics and data. Thibault finds it hard to stay away from binary! We love that. 🤓
5. Migrating to Swift from Flash and ActionScript
We couldn’t publish a list of Swift resources without shamelessly plugging our own book, “Migrating to Swift from Flash and ActionScript”. We have designed it to be a one-stop-shop in your transition to Swift, using Xcode and making iOS apps by building on your prior knowledge.
The book guides as you adapt not only to a new programming language but also to a new set of programming tools and workflow. You can read it from cover to cover or use it to refer to the topics you need in whatever order you need them – pretty much all chapters are self-contained.
– Part I: Your new tools
It can be frustrating when there is work to do and stuff to set up before you can run your first line of code on a device and only Google to search for answers. This part of the book helps you breeze through that and shows you what Xcode has on offer in terms of development tools.
- Chapter 1: Setting Up Your Environment
- Chapter 2: Hello, Xcode!
- Chapter 3: Introducing the Xcode Debugger
- Chapter 4: Additional Development Tools
– Part II: Your new workflow
All set up, now how do you create your user interface? How do you make it adjust itself to different screen sizes and orientations? How do you get code to run in the background and how do you make the most of the debugger? This part of the book deals with these and more workflow-related questions.
- Chapter 5: “Hello, Swift!”—A Tutorial for Building an iOS App
- Chapter 6: Adding a More Complex UI
- Chapter 7: Concurrency
- Chapter 8: Debugging and Testing Your App
– Part III: Your apps
This part comes with 12 self-contained tutorials for practical apps you may want to build: from posting to social networks and using the camera to producing high-end graphics.
- Chapter 9: Communicating: E-mail, Text Messages, and Calls
- Chapter 10: Getting Social: Posting to Facebook and Twitter
- Chapter 11: Knowing Your Location
- Chapter 12: Working with the Camera and Images
- Chapter 13: Working with Data
- Chapter 14: Networking
- Chapter 15: Adverts and Push Notifications
- Chapter 16: Using the High-End Graphics APIs
– Part IV: Your new language: Swift distilled
You have been learning how to code with Swift throughout the whole book. However, it is helpful to have a reference, which is focused on the language itself. Here Swift is presented from the point of view of your current experience with other OOP languages, especially ActionScript 3.
- Chapter 17: Swift Language Basics
- Chapter 18: Operators
- Chapter 19: Types
- Chapter 20: Control Flow
- Chapter 21: Object-Oriented Programming Topics
- Chapter 22: New and Different Concepts
– Bonus Chapter: Releasing Your Apps in the App Store
That’s the point of making apps, right? Releasing an app in Apple’s App Store includes jumping through hoops that are far from intuitive… We hope that the tips in this chapter help you navigate them and have a smooth sail.
4. iOS Development with Swift
This is the new book by Craig Grummitt we mentioned earlier. Craig is working on it as we speak (ok, as I write and you read) and it’s very exciting to see new chapters appearing on the publisher’s website in real time thanks to the Manning Early Access Program (MEAP).
It has a gradual approach in taking you from zero to becoming a proficient Swift developer.
– In Part 1 you get familiar with Xcode as your new IDE, try out Swift in a Playground and make your first app with it.
- 1. Your first iOS application
- 2. Introduction to Swift in the Playground
- 3. Swift Objects
– Part 2 helps you with building your app’s user interface and understanding Layouts and user interaction among other things.
- 4. View Controllers, Views and Outlets
- 5. User interaction
- 6. Adaptive layout
- 7. More adaptive layout
- 8. Keyboard notifications, animations, and scrolling
– Part 3 shows you how to build the backend of your app and deals with topics from working with data and iCloud to threads and networking.
- 9. Tables and navigation
- 10. Collections, searching, sorting and tab bars
- 11. Data persistence
- 12. Data persistence in iCloud
- 13. Graphics and media
- 14. Networking, libraries and threads
- 15. Debugging
– Part 4 adds finishing touches to app development: testing your code and distributing your app.
- 16. Testing
- 17. Distributing your app
At the very end of the book, you will find Swift syntax cheat sheets for quick reference.
You can see a short presentation of the book here, and follow the book’s progress and download Chapter 1 for free from the publisher’s website. We are looking forward to the book’s release in July 2017!
If you are a ‘ready-fire-aim’ kind of learner (aren’t we all?!), you may want to take Swift into a familiar corner, use it for a bit and then commit to reading books and articles about it. Wouldn’t it be nice if there was an API for that? Well, read on, you are about to discover one.
6. Swift API for the Flash Guy
This has to be our personal favourite: an ActionScript 3 SDK in Swift by… Craig Grummitt again. What can we say, Craig is a prolific writer and programmer!
If you are a die-hard ActionScript coder who would prefer a veeery gentle transition to Swift, give this SDK a go. It has been aptly named ActionSwift3 and is designed to make your first Swift projects feel as if you are still programming in Flash with ActionScript 3.
Craig has ported pretty much all you need to make a viable app: from basic classes like Object, DisplayObject, MovieClip and Scene through classes for event handling, designing your user interface and, get this: even data types that you’ll be familiar with from ActionScript 3.
The SDK comes with a tutorial for porting your first Flash game, called “Flashy Bird”, into Swift. This is a clever trick: while you remain wrapped in cosy and familiar ActionScript 3 working on this game, by the end of the tutorial you will not only have made your first steps in Swift, but will have also set up your Swift development environment: Xcode with Cocoapods and will have learnt how to use third party libraries to boot.
The SDK is open-sourced, up-to-date with Swift 3 and is available on GitHub.
Give us a hand
We hope you find this collection of resources helpful on your way to learning Swift. This relatively new language, however, and the knowledge about it, evolve with impressive speed and new learning materials become available by the minute.
Do you know of other resources that may help a Flash developer get to grips with Swift?
Post a comment below and help us keep this page up-to-date.