2 "name": "ActionSwift3",
4 "summary": "AS3 SDK in Swift",
5 "description": " ![ActionSwift logo](https://github.com/craiggrummitt/ActionSwift3/blob/master/ActionSwift.png)\n \n Swift is awesome - but do you ever reminisce about the old days of ActionScript 3.0? The old days of MovieClips, DisplayObjects, Sprites, SimpleButtons, EventDispatchers - oh and who can forget gotoAndPlay? Well, now you can enjoy iOS native development using the power of Swift syntax but with the AS3 SDK! Whaa? How is this possible? Is this heresy?\n\n **ActionSwift3**\n\n Underneath the hood ActionSwift3 is based on the SpriteKit Framework but ActionSwift 3 SDK is based on familiar AS3 SDK classes:\n\n * DisplayObject\n * InteractiveObject\n * DisplayObjectContainer\n * Sprite\n * Graphics\n * Stage\n * MovieClip\n * SimpleButton\n * TextField\n * TextFormat\n * Sound\n * SoundChannel\n * EventDispatcher\n * Event\n * EventHandler\n * Touch\n * TouchEvent (in a touch environment TouchEvent makes more sense to use than MouseEvent)\n\n Easing classes are also included for convenience from [here](https://github.com/craiggrummitt/SpriteKitEasingSwift).\n\n API documentation can be found at [cocoadocs](http://cocoadocs.org/docsets/ActionSwift3/1.4/index.html)\n\n ## Installation\n\n ActionSwift is available through [CocoaPods](https://cocoapods.org/pods/ActionSwift3). To install\n it, simply add the following line to your Podfile:\n\n ```ruby\n pod \"ActionSwift3\"\n ```\n\n Don't forget to import the Pod where you would like to use it:\n\n ```Swift\n import ActionSwift3\n ```\n\n Alternatively, if you would like access to the example project as well, clone the github project [here](https://github.com/craiggrummitt/ActionSwift3).\n\n **ActionSwift**\n\n ActionSwift is a sample project that you can use to play with ActionSwift3. Start with taking a look at GameViewController.swift. GameViewController does the following:\n\n 1. Sets up the stage.\n 2. Creates a 'play' sprite that draws a circle containing a triangle.\n 3. Creates a 'stop' sprite that draws a rectangle containing a rectangle.\n 4. Creates a movieclip that displays textures defined by an array of strings referring to the images in the folder 'images.atlas'. \n 5. Shows how to create an event listener by setting up clicks on all three sprites. The stop and play sprites 'stop' and 'play' the movieclip. Touching the movieclip activates a drag-drop operation.\n\n ![Screenshot](https://github.com/craiggrummitt/ActionSwift3/blob/master/screenshot.png)\n\n **How to use ActionSwift3**\n\n Here is some sample code to get your head around how to use ActionSwift3.\n\n ***Stage***\n\n To begin with, you need to set up the Stage in a ViewController that contains a SKView(this is done for you automatically if you set up a Game-SpriteKit project)\n\n ```Swift\n let stage = Stage(self.view as! SKView)\n ```\n\n ***Sprite***\n\n You can now call familiar methods on the stage. For example, you could instantiate a sprite, and draw a rectangle on its graphics property, and then add this sprite to the stage:\n\n ```Swift\n let sprite = Sprite()\n sprite.graphics.beginFill(UIColor.redColor())\n sprite.graphics.drawRect(10,10,100,44)\n sprite.name = \"shapes\"\n stage.addChild(sprite)\n ```\n\n ***MovieClip***\n\n To create a movieclip, you will need images within a folder with the extension 'atlas' in your project (eg.'images.atlas'). This will automatically generate a Texture Atlas. Set up an array of these image file names, and pass them in when you instantiate a MovieClip. These will now be the 'frames' of your movieclip, which you will be able to call familiar methods - gotoAndPlay(), gotoAndStop(), stop() and play(). Use Stage.size to get the dimensions of the device. Oh and x=0, y=0 is the top left of the stage. Hooray!\n\n ```Swift\n let walkingTextures = [\"walking1\",\"walking2\",\"walking3\"]\n let movieClip = MovieClip(textureNames: walkingTextures)\n movieClip.x = 0\n movieClip.y = Stage.size.height - movieClip.height\n stage.addChild(movieClip)\n ```\n\n **SimpleButton**\n\n You can create a SimpleButton object, with an up and down state(not much point of over states on touch screens!) You can use sprites(with shapes on the graphics object) or movieclips(with textures) as the states.\n\n ```Swift\n let play = SimpleButton(upState: playUpState, downState: playDownState)\n stage.addChild(sprite)\n ```\n\n ***TextField***\n\n Use familiar syntax to create a textfield. Build the basics of the textfield using the TextField class, and then apply text formatting to the defaultTextFormat property, using the TextFormat class.\n\n ```Swift\n let text = TextField()\n text.width = 200\n text.text = \"Salutations to you, world\"\n\n let textFormat = TextFormat(font: \"ArialMT\", size: 20, leading: 20, color: UIColor.blackColor(), align:.Center)\n text.defaultTextFormat = textFormat\n\n stage.addChild(text)\n ```\n\n ***Sound***\n\n Use sound to play sounds included in your project - a big difference though - now wav files are supported as well as mp3. *Hooray!* Loop the audio, or play it from a point in the file. As per the strange AS3 API, use SoundChannel to stop the sound.\n\n ```Swift\n sound = Sound(name: \"ButtonTap.wav\")\n sound.play()\n ```\n\n ***EventDispatcher***\n\n Just as you would expect, Sprites, SimpleButtons and MovieClips will dispatch events. As Swift is not able to check equality between two functions, an additional class called 'EventHandler' stores the EventHandler, along with a string representing the EventHandler, that can be checked for equality. For example, here's how to set up an enterFrame event handler:\n\n ```Swift\n movieClip.addEventListener(EventType.EnterFrame.rawValue, EventHandler(enterFrame, \"enterFrame\"))\n func enterFrame(event:Event) -> Void {\n trace(\"This is called every frame\")\n }\n ```\n\n ***trace***\n\n Oh yeah - and trace is back!\n\n ```Swift\n trace(\"This is the most amazing thing I've ever seen, trace is back! How did they do this?\")\n ```\n\n **Enhancements**\n\n ActionSwift3 is a work in progress, feel free to contribute! \n\n Ideas for enhancements:\n\n * Date\n * XML\n * Add more complex shapes on Graphics\n\n **Updates**\n\n 1.1\n * Added int and Boolean data types\n\n 1.2\n * Added TextField\n * Resolved issue with stage updates not propogating\n * Added license\n\n 1.3\n * Added SimpleButton\n * Added UIColor extension for hexidecimal support\n\n 1.4\n * Added Sound, SoundChannel\n\n ***Credits***\n\n * \"Walking animation\" by [Kyoux](http://kyoux.deviantart.com/)\n * \"ActionScript\" by Adobe Systems Inc.\n * \"Swift\" by Apple Inc.\n * \"Swift logo\" by Apple Inc.\n",
6 "homepage": "https://github.com/craiggrummitt/ActionSwift3",
11 "authors": "Craig Grummitt",
12 "social_media_url": "http://twitter.com/craiggrummitt",
17 "git": "https://github.com/craiggrummitt/ActionSwift3.git",
18 "commit": "16e35700dc1d26df6f774ada2a346a7c5e72e220",
21 "source_files": "ActionSwift3/**/*"