I have an swf which does not use stage3D it's a simple swf. I also have an swf which runs starling. Now, I want to load the starling swf inside the first swf. Is something like that possible?
Short answer: Yes it is possible.
Hints:
you have to set the backgroundAlpha = 0, in your normal flash file, in order to be able to see the stage3D context.
take care your html file which is the wraper for flash, specifies that wmode = direct
watch out how you unload / stop the starling content when you do not need it any more.
Performance:
As long as you release the resources that you do not need, having a mix should not cause performance issues.
Try not to perform heavy operations on both normal flash and starling content in the same time.
It is possible you just need to remember that stage3d content (starling) will always be below display list. Performance should only be issue on mobile, if you only target web it should be fine.
Related
I am developing a 2D game using Adobe Flash Pro CS 6 and ActionScript3. I am having some trouble in developing some effects e. g. bomb blast, particle effects etc. I want to know, whether I can use After Effects for those and then use them the game. Please suggest me.
There's no problem of using any graphics data from any program in Flash as long as flash can support the file format.
In case of After Effects graphics, you'll probably have to export them as a PNG file sequence, so they'll most probably be pretty large in file size.
To import:
You can either make a movie clip and just import the first image of a sequence with CRTL/CMD + R and Flash with be "smart" enough to suggest to load the other files of that sequence.
If you want, you can load them during run-time, add them to the array/vector, create a Bitmap object and change it's bitmapData property on enter frame/timer to animate it.
If you are decided on using the actual After Effects graphics rather than emulating them using an Actionscript 3 particle effect, I'd actually recommend exporting them as video on an alpha channel and then converting that to flv and then hosting them individually and streaming them in via Netstream and placing them on the proper layer via an addchild. If bandwidth isn't a huge concern here, this would be a good method for achieving this effect.
Here is some documentation on Netstream. http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d4e.html
If this seems like it might achieve the desired result, I can explain further if needed.
I need to position a flash banner over gpu accelerated video player. I have read somewhere, that wmode direct is very important. But don't remember why.
How do i position a banner over it if i can't set wmode to opaque?
Thanks.
Short answer : You can't.
Long answer : wmode direct remove the swf from the browser display, and placed on top of it. That way, it is possible to make use of the gpu. With wmode opaque (or transparent), the swf is displayed by the browser, and the gpu acceleration can't be used.
The drawback of using wmode direct is that the swf is displayed on over all the document. So nothing can be placed over it (except maybe another direct swf - no tested, and I wouldn't recommend it). Ever.
What are the workarounds possible from this problems ? I can think of two :
foregoing gpu acceleration. Does your swf really needs gpu acceleration ? Chances are, if you don't display video, 3D graphics, or hundreds of moving sprites, that it doesn't really need it. If so, use wmode opaque, you'll loose a bit of performance, but you'll be able to place your banner.
place de banner within the swf. This'll need to edit the flash, but you could display a banner from within it. As long that this banner is an image, or another swf, it wouldn't be very hard using the Loader class.
I am creating a bejeweled style game using flash builder for the web and I am wondering if it would be best (higher framerates, less render intensive, fast on all types of computers) to use the native rendering of actionscript 3 (display lists) or the gpu rendering of the Starling 2D Framework? My reasoning for wanting to use the native flash rendering is because from my research I understand that flash will utilize redraw regions and only redraw portions of the stage that need to be updated whereas starling will re-render the entire stage every frame. In a bejeweled style game there are many static objects and fewer dynamic objects so generally the entire stage does not need to be redrawn every frame, only small portions of the stage. Would it be better for performance to stick with the native rendering calls of actionscript 3 or would it be wiser to use the starling framework to utilize the gpu to accelerate the rendering? Any perspective would be much appreciated. Thanks.
Starling will be faster if you are using images, particularly on mobile.
The static regions can either be rendered as a single Sprite, or you can flatten it at runtime to improve the performance.
If you are drawing, in Starling you'll need to draw to a bitmap and then use that as a Sprite. You'll get better performance if everything is in the same sprite sheet, however.
While it's true that Starling draws every frame, it's a different sort of operation. Here's what actually happens:
1) The textures (images) being used by the app are uploaded to the GPU. This is done once.
2) Each frame, Starling tells the GPU "render this texture at this position with this scale and rotation". This is called a "draw call" but it's extremely fast. The slick thing with Starling is that it can batch these draw calls under certain circumstances to get serious speed improvements.
So yes, everything is "redrawn" each frame, but the GPU's hardware acceleration is used.
On mobile, Starling (or similar) is really the only way to do something at 60fps.
Ask a question .. images resources of the flash game , How should I load? I use the Loader class, but some people use the embedded resources.Can you tell me in which case use "Loader" class and in which case use "[Embed]"?
It all depends on the game requirements. You have to have in mind that if you use Loaders your game will not work in offline mode (without internet access), which in some cases is critical (i.e. a flash game for a mobile device).
If the final file size isn't a problem, then you should always embed your assets and load only dynamic resources (i.e. ads). You can always use assets libraries to store the resources and to reduce the initial loading time for the application.
Using the embed tag literally compiles that resource into the final SWF output. So it's a matter of how much preloading you want to do and how big you want your initial swf to be. If you are embedding some small thumbnail images or sound files, this may be okay to an extent. But if you embed all of your assets or large assets, well you can figure it out from there, you're going to merge that file size + the size of any other files into 1 file, which is also meant to be your user interface. Keep assets external (for the most part) and dynamically load them in. There might be specific cases as mentioned here in other answers where it is required but unless otherwise dictated, organize your assets and simply load/unload them as needed. The other nice thing about using the Loader class is that is gives you more control over destroying the object from memory than anything else. You can call the unloadAndStop(Boolean CallGarbageCollector) method and directly request the VM to forcefully stop, delete and clean that object up. Anyway hope this clarifies things.
If you would submit your game to Kongregate or Newgrounds, they have strict rules - game should consist of one file. If you host game yourself, you may do as you wish, but take into account that loading needs time and your game find that some resource needed and not yet loaded.
As a rule of thumb, if your game is small, embed everything. If resources are vast and not used simultaneously, think about loading dynamically - this is much harder but allows for faster game start.
Is it possible to generate multiple thumbnails from a FLV using only as3? The flv is on the same server as the swf so I'm not using any dedicated streaming server. I'd imagine that as long as the flv has load the video you'd be able to pull bitmapdata from a specific time of the flv.
My idea is to pull around 8 images from every flv, convert them to buttons and use them as links to specific chapters in the flv.
If this is not possible, would it work better with a dedicated streaming server like red5?
Edit:
I'd also like to know how to do it if it's possible :)
The idea is to not use the server.
The thumbnails will only be used within the swif, so no saving to another location.
You can do this in AS3 as long as you're actually playing the video within Flash. While playing when you seek to the desired frame capture a bitmap. If you want to save the bitmap for later use you need server-side code to store it.
Streaming vs http download will not make this problem any easier or harder (although with a streaming server you can seek to the desired point without having to download the whole flv to that point).
This would be much better done on the server. You'll need an app that can extract an image from an FLV. ffmpeg can do it.
I know it is possible to get mplayer to output stills from an FLV (though might need a bit of fiddling to get the time reference right), and these in turn can be stuffed into ImageMagick to resize into thumbnails. Not best solution, but probably easier than digging around as3's API.
video thumbnailer is a good idea.
http://blog.chrometaphore.com/2010/03/26/how-to-create-video-thumbnails-runtime-in-pure-actionscript-3-0-videothumbnailer/