Restrict game to play locally - actionscript-3

How to restrict the game locally?. I know the browser sitelock. But i do not know how much it is effective.
I played the games in http://www.gameark.com/. If you download the games from this website, you cannot play it locally. How to do this?
Thanks.

I'm using http://www.swfshield.com to do this without pain.
What they do is actually converting your swf into binary or some sort, and wrap it inside a loader (I'm not sure.. It's just my guess...). I use this swfshield to protect my swfs from being decompiled and being stolen.
It will not load locally if you do single domain lock. So, basically, it won't literally load in any domain other than the specified domain.
Additionally: I've tried at least five different decompilers to decompile the protected swf from swfshield.com, but none of them were able to get a single hint about the swf. :)

Related

Chrome's Flash player Shared Objects and External Flash Player Shared Objects

I am working on an AS3 application. I need to store some data locally (on user's machine). I used Shared Object concept. Now in chrome, the default flash player (pepper flash) stores the shared object in a different folder. So if a user changes from the default flash player to externally installed flash player and vice versa (by disabling/enabling flash player from plugins) there will be loss of data. Let me simplify. External flash player stores shared object at 'A' and pepper flash at 'B'. If I switch the flash players, i will miss the data at 'A'/'B'. How can I solve this problem? Is there a way to retrieve the data? Please help me.
Because the Flash plugin itself controls where shared objects are stored and you cannot (as far as I am aware) change that location nor determine what that location is, there is nothing you can do about this one, unfortunately. You will have to deal with the lost data. It will happen eventually anyway, because I believe shared objects are cleared when you clear temporary browser data (or at least they should be, anyway).
On the bright side, the average user does not know you can switch between plugins nor do they know how. The vast majority of Chrome users, even those with a more technical background, will be using the terrible Pepper Flash plugin, so your scenario should be a rarity.
There is a way around it, however. You could set up a remote server and store the shared object there. That way it is not stored locally and you decide where it is actually stored. I personally can't think of a situation where this would be preferable to having a couple users lose their data, but it might fix things for you.

Flash (Actionscript 3): Play 2 videos from 1 NetStream?

I'm streaming a video from an Amazon CloudFront RTMP source with
video.attachNetStream(myNetStream);
myNetStream.play(myVideoFileName,0,-1);
and it's working quite well. Now, what I want to do is something like this:
video1.attachNetStream(myNetStream);
video2.attachNetStream(myNetStream);
myNetStream.play(myVideoFileName,0,-1);
This doesn't work as written because only one of the two videos will play at a time for some unknown reason. I want video1 and video2 to play the same video from a single NetStream (to save bandwidth) and remain completely in-sync with each other. How can I accomplish this?
If you are playing an FLV file directly (not streaming it from FMS), you should be able to :
Load the file with URLStream
Wait for sufficient data to start copying the data to a ByteArray object
Create as many NetStream objects as you need and use the appendBytes(bytes) method
I haven't actually tested it, and the logic of appendBytes() needs to be looked at, but theoretically it should work.
Also, it deserves a benchmark. But it's probably better than re-drawing a bitmap copy at the same rate as the video, and keep the two videos in sync.
bitmapData can't be accessed at all because of security restrictions. I'm going with plan B which is playing 2 netstreams, but reducing the file size of the one the videos by removing its audio. I'll have to wait until Amazon allow security policy access to use the bitmapData solution.

SWF hosting security

I have started developing a drawing application in as3. I am thinking that I could integrate a cms and allow swf files to be uploaded in runtime as graphics.What are the potensial security issues involving third party possibly malicious swf files here?
I would simply be adding the swf as a custom sprite class to a masked container sprite.
Does this open a hole to run other scripts ( js on another server? ) and or give access to the client's computer in unsafe ways?
I would appreciate any recomendations reading and or advice / experience in swf hosting like this. I see this being done on many sites now such as wonderfl and activeden.
This is the ActionScript equivalent to XSS. Your domain will no longer be protected by the Same Origin Policy. This can be used by an attacker to hijack a Session ID (Cookie), deface your web site, or deliver exploit code to any browsers visiting your site.
I think instead of saving a whole mess of SWFs on the server, it would be better to serialize your drawing data, and have your main SWF just redraw the drawing based on the loaded data. You can still use a CMS/Database to store and manage this data.
EDIT*
If you need to load SWFs, take a look at Specifying loading context. And maybe also take a read through Loading Content.

Flash CS4/AS3 Writing local file from local game without save dialog prompt?

I'm writing a game to be run locally, on the user's computer. NOT over the internet.
I want to have a file that will hold the usernames and avatar indices (they're in an array).
I want to know if there's a way to write to files through Flash with AS3. I'm using CS4.
I'd also like to know if you can delete files through Flash, though that's just optional.
Thanks in advance for any help you can give.
If you want to make a game that runs locally on someone's computer, you should make it in Adobe AIR. AIR apps can read and write files, and do all sorts of useful things like show updates in the taskbar, etc. Whereas a simple SWF that you download and run locally can't do anything useful that it couldn't already do in the browser - it can't write or delete local files, for a start. (It can read local files, but only if you disable it from accessing the network.) Moreover, the standalone Flash player is not generally disseminated, so unless the user is a Flash developer they're just going to view your SWF in a browser anyway (unless you plan to publish projectors, which I also wouldn't recommend).
With all that said, however, even if you do your game as local flash content, you can still store information by using SharedObjects. They work the same way offline as online. You can't write the data out as a separate file, but you can store it between sessions easily enough.
if i understand what you are trying to do then why dont you use Adobe AIR? this is flash for the desktop

How to optimize the import of swfs in the preloader

I work on a big Flash project as the web backend guy that delivers all the files and assets to the main application SWF. Our last, really big packet of data are all the assets and sounds contained in swf files that are imported during the preloader.
Are there any ways to optimize this process in any way?
I'm really looking for ideas in any direction, no matter if its in the swf, the process of loading and so on. Also I look for solutions for the first time load (empty cache) and for consequent loads (prefilled cache).
A few tips for file optimization:
Choose the correct type of image extension, sometimes gif or png delivers better results then jpg's. Ask your designer to deliver tileable, scalable graphics whereever possible. Take advantage of vector graphics.
Use the sound optimization in Flash, so import wave files and try mp3 compression with lower bit rates.
Load sound effects/bg loops related with user interaction prior. Videos can wait. People are used to wait for videos.
For preloader optimization, obviously each HTTP request is extra load on the server. So reduce the number of swf's to be loaded, maybe by logically grouping them. Preloading the crucial stuff first, then background preloading lower priority swf's is always good for convenient user experience.