I have not touched flash for ages - but I've been asked to make a little LSO storage system (inspired to a certain extent by Evercookiehttp://samy.pl/evercookie/ ) which will be used to ensure that a cookie & an LSO have the same value.
I've created a working example as an AS3 FlashDevelop project. No-one else here uses FlashDevelop, and no-one really knows flash, but we do have licenses for CS3. Somewhere down the line, someone is going to try to open the project in Flash, so I need to have the answer.
This is probably a simple question, but is all I need to do in order to make it the document class in the flash IDE the following:
I have (short form)
package {
[SWF(width="400", height="60", frameRate="20", backgroundColor="0x330066", quality="high", scale="noscale")]
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
Security.allowDomain("*");
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point - do some shit
}
}
}
Am I correct in thinking, all I need do is remove the line
[SWF(width="400", height="60", frameRate="20", backgroundColor="0x330066", quality="high", scale="noscale")]
and then create a new .fla, with "Main" set as the document class?
For bonus points: my .swf gets given a Guid (as a string) via Flashvars. It then sets the LSO with that Guid.
It then uses ExternalInterface to read a cookie via javascript, and compare values. If the cookie does not match the LSO, it does some logic, and then sets the cookie to what is decided to be correct.
Now, I have set allowScriptAccess:'always' in the embed code (SWFobject) & Security.allowDomain("*"); in init() - but as I will be hosting the .swf on domain A, and serving it embedded in pages in domains B, C, and D - will I be able to execute javascript by calls from a swf hosted on domain A to js hosted on domains B, C and D?
Is allowScriptAccess & Security.allowDomain all I need? I should not need a crossdomain.xml as I am not loading anything across domains
You are correct. This can be the main document class. You're going to want to do as many of the import statements in this class as you can though to avoid confusion later on when they compile with the IDE instead of FD. For example, specifically import ExternalInterface in this class for them. Sometimes I prefer a Document or Main movie clip on the stage instead that they put things into but because I don't know the project then it doesn't matter.
As for the crossdomain, try it without it and then use something like Fiddler if it's not working properly. If it requires crossdomain.xml you'll see a call to it and you'll have to stick it on each server.
Finally, I'm interested in the SWF line. Would it override the Flash IDE setup? Interesting. If it did, then you'd have to remove it for people wanting to set the size. but if you wanted to restrict them, would that work? hmmmm......I've never thought to try that in a Flash IDE document.
I think the swf line fails in CS3 but should be fine in CS5 flash. I think, when it does not fail it overrides. I would open the flash develop project file and check the setup... my advice would be to get it compiling via textmate or e-texteditor, as they do less for you and you can be sure your not missing something when moving to flash IDE, my experience is the IDE is more forgiving on code. If your using flashdevelop it's about time you switched to haxe, it compiles faster etc.., really no need to use as3. I have just been forced to use windows and must admit haxing in flashdevelop has its advantages ( really good support ) over textmate, but I still love textmate 
Cool thanks. I removed all the imports for simplicity, I have lots in the real code.
I have a friend who is a flash god - or at least, as close to a god as we get out here in the 3rd world, and he's using HAXE. Been wanting to learn, but i'm normally a .NET dev, so not much opportunity/need.
The company I am working with are a spin off from a games company with backgrounds in c sharp/ c++ and they choose haxe because it was more consistent and similar than as3 is, you can use haXe for other stuff than flash, it is good for cross platform desktop development for instance.