Recently, I took the spare time to do the flash games have been developed almost, ready to perfect under the UI and values, put into foreign flash game station. During the period also initiation of ideas, want to expand the game to the mobile platform. After two days of trying, removing the work to access the Ane interface, the game itself can be migrated to Android and iOS platforms without any changes. Just on the phone, the game dropped frame is very serious, far from the experience effect on the PC. It seems to do Flash mobile games, without Starling frame is not. Plan to study these days under the Starling, the project transformation.
Based on Starling Mobile project development Preparation work
From: Starling Chinese station-Starling Mobile development tutorial
Author: Guo Shaori (Neoguo)
Mobile development is booming now, and if you're a flash developer, maybe your team has started developing mobile apps based on Flash content. Since Adobe has provided air packaging technology to help us package the same program into systems or devices such as Ios,android,blackberry, this has greatly reduced the cost of cross-platform research and development, It also provides a great opportunity for the traditional flash research and development team to enter the mobile development field. But there are opportunities and problems. One of the big problems is performance. Now the PC platform has a very powerful computing power, our flash-based application development, generally not too concerned about performance issues, but into the mobile device, we will find ourselves facing a very harsh hardware environment (of course, now the smart machine hardware configuration has been greatly improved, so that the limitations of our development has been relaxed a lot). For example, we are based on the traditional thinking, with flash movie clips and other ways to do an application, the preview on the PC no problem, but on the mobile device but not very good execution (dropped frame phenomenon, which is the display of the pressure is too large). Why does this happen? Because the traditional display list mechanism (STAGE,SPRITE,MOVIECLIP) in Flash is CPU dependent, which means that the rendering pressure is basically on the CPU. In the case of low CPU processing power on mobile devices, it is no surprise that there is a drop frame phenomenon.
One way to improve this is to use GPU acceleration, which is the graphics computing power of the graphics card to reduce CPU pressure on screen rendering. But the tragedy is that Adobe has been slow to work on "GPU acceleration for the traditional display list mechanism," which has previously introduced a setup to add <renderMode>GPU</renderMode> in the configuration file to turn on hardware acceleration, But don't be excited, this setting is not valid for the PC, and it is a lot more restrictive and unstable for mobile devices. The author once set up the CPU and GPU mode in a project to test the program (IPad 1), and found that the CPU mode is running more efficiently and stably. The situation is frustrating, and Adobe's technical team has written a blog to explain the difficulty: Flash is completely CPU-based (often referred to as soft-solution) in the previous architecture, meaning that the traditional 2D display list is designed for CPU rendering, This is very effective across platforms, but now it's a hassle to move to the GPU.
This means that if we had a complex, flash-based, traditional display-list application or game, it would be difficult to migrate to a smart device intact, but also to ensure that the same execution efficiency is similar to that of a PC. Of course, Flash has been popular for so many years, developers have accumulated a lot of proven experience to improve operational efficiency (such as bitmap-based animation, space-time), these experiences can help us to some extent to improve the execution efficiency of existing applications. But it may not be enough, the features of the mobile device determine that we need to optimize as much as possible. To do this, we have to make more efficient use of the GPU. Of course, Adobe is aware of the importance of GPU for improving rendering performance, so Stage3D was introduced. Stage3D Although also made abstract (to address platform-agnostic), but is undoubtedly closer to hardware, based on Stage3D we can develop and desktop games comparable to the network 3D game. Of course, because Stage3D is the underlying API, the cost of learning and mastering is also higher. About Stage3D This article does not introduce too much, if you do not know Stage3D, it is recommended to refer to the following article:
- Stage3D translation of one of the series: How Stage3D Works (i) (concept article)
- Stage3D translation of one of the series: how Stage3D Works (ii) (in-depth article)
- Stage3D translation of one of the series: how Stage3D Works (iii) (end of article)
Of course, as its name, Stage3D is an API for 3D applications. If we just want to do 2D applications, can we not use Stage3D? Of course, but the programming and implementation of ideas will be very different from our previous Flash experience, we need to fully stand in the perspective of the graphics card to write the implementation process, which will undoubtedly be boring and difficult, and there is a high cost of learning. Fortunately, a number of technologies with a spirit of exploration and sharing have been further packaged on the basis of Stage3D to provide a more user-friendly technical framework for traditional flash 2D display objects. Such a framework already exists some, more well-known have starling,nd2d and so on. Among them starling get the Adobe official recommendation, its interface also and Flash original display object very close, so I also chose Starling to carry on project practice, and share this process experience with everybody.
Starling is a Stage3D-based 2D framework launched and maintained by the Gamua team. This is a team based in Austria with two core development members: Daniel Sperl and Holger Weissb ck. They are good at objective C and ActionScript, and because of this, they actually have two open source frameworks: The Starling framework and the Sparrow framework, and the two frameworks are designed to be the same, just the former for Flash, The latter is for iOS.
Download, install and configure
工欲善其事, its prerequisite, let's get the weapons ready first. The weapon here refers to our IDE, considering that most flash developers should be programmed based on Flash Builder (Flash Professional is really not suitable for programming, other third-party Ides such as Flash Develop, of course, are also excellent, But for the sake of brevity, other Ides are no longer involved, if you use other Ides, refer to the IDE's help to integrate the latest Air SDK, we will take the Flash Builder as a guide to the following steps.
Please install the latest Flash Builder 4.6, which is already supported for mobile project creation and contains the latest Flex SDK 4.6 (PS: The Flex Framework or Flex project is not included in our discussion later, just in Flash Any type of project in Builder is compiled from the Flex SDK, but the built-in Flex SDK 4.6 contains the SDK for Air 3.1, and Stage3D support for mobile devices is implemented in air 3.2. So this place we're going to make an adjustment to replace the parts of the air in the Flex SDK.
Operation Steps:
- Go to the Flex SDK directory (win below is {Your installation path}\adobe Flash Builder 4.6\sdks\), your latest version should be 4.6, copy 4.6 copies, named 4.6_air3.2
- Download the latest Air SDK from Adobe official, the address is: Air SDK download
- Unzip after download, overwrite 4.6_air3.2
- Start Flash Builder, open Window--preferences->flash builder-> installed SDK, create a new SDK configuration, point to the 4.6_air3.2 you just created, and set as default SDK
- Create a new ActionScript phone project to see the namespace of the main application's XML configuration file (for example, the main class is main.as, then the config file is main-app.xml), and if the namespace is, the configuration succeeds
Then we need to download starling. Of course, like all ActionScript libraries, we can use its compiled SWC, or it can use its source code. Here I suggest you try to use the source code, because as a new framework, the bug is inevitable, once there is a problem, we can trace the source to find and solve. If you use SWC, there is no such convenience.
At present Starling official website (), provides the stable download version is 1.0, download from here. And then there's a version under development, hosted on GitHub, address: The test found that the current version on GitHub is also relatively stable, and the demo has an example of iOS, if you do mobile development, you can try to use the latest code version on GitHub.
After downloading the source code, you can create a library project through Flash Builder, which contains the source code of Starling, and Flash Builder will automatically compile the SWC. You can then create an ActionScript phone project, which refers to the library project you just created, on the build path---Library path interface.
Just also said that the source code is attached to the example, if you download the source on GitHub, there is also a special example of iOS. If you already have Flash development experience, looking at this example is undoubtedly the best way to quickly understand how Starling is used.
Follow the steps below to start this example
- The Samples directory actually contains two examples: Demo and Demo_ios, where Demo_ios needs to rely on demo resources, which need to be noted in a later step.
- Create an ActionScript phone project in Flash Builder that can be set to iOS, platform to iphone, and then the Starling Library created above.
- In the Source Settings section, the DEMO/SRC and demo_ios/src two directories are all set in, and then set the startup application to demo_ios/src/startup_ios.as.
- If the compiler error is not indicated, it means that the configuration is successful and can be tested with the Flash Builder's simulation interface, and you can see the following interface:
If you want to test in real-world devices, it's a bit of a case: if it's Android, it's easier to pack it up with a self-built certificate, install it to an Android device, or if it's an iphone or ipad, you'll need an Apple-approved signing certificate to complete the package. This certificate needs to be registered and paid for by the Apple developer account, as described in the James Li Tutorial, which is not detailed here.
Here today, I will continue to discuss with you some of the problems and experiences in using the starling process.
[Go] Based on Starling Mobile project development Preparation work