Re: [Flashcoders] AS3: for-loop in a static initializer - Access of undefined property i
That's a great response, thank you On Sun, Apr 12, 2009 at 10:14 PM, Juan Pablo Califano califa010.flashcod...@gmail.com wrote: The problem is that, while static initializer blocks look like their counterparts in Java, they have a little but important difference. Even though you use curly braces, you're not creating a new scope. In AS, scope is either class / global or local (to a function or method). So, you cannot declare var i:int and access it statically, since by default variables and methods are not static. An option is to make i static as you did, but it looks ugly, since i is clearly a temporary variable. In C# you can declare a static constructor to handle such a situation (I'm not 100% sure, but I think you can't use static initializers). This constructor is automatically called when the class is loaded, or at least, before the first instance is created. In Actionscript, you don't have this feature, but you can do something similar, except you'd have to call your static constructor (or, more properly, initializer method) manually. You could do something like this: private static var BLACK:TextFormat = new TextFormat('Arial', 24, 0x00, true); private static var RED:TextFormat = new TextFormat('Arial', 24, 0xFF, true); // run static initializer method { staticInit(); } private static function staticInit():void { BLACK.letterSpacing = -4; RED.letterSpacing = -4; // i is now a local var and will go out of scope when this function returns for (var i:int = 0; i 10; i++) trace(i); } In fact, there is a static constructor, but it's created ad hoc by the compiler and called automatically by the runtime when the class is initialized. If you decompile / disassemble your code, you'll see a method called: static function YourClassName$cinit() This method contains all the inline static initializers. But since it's generated by the compiler, you cannot declare it yourself. Nevertheless, making your own static initializer method and calling it seems a bit cleaner if you need some static initialization logic. Cheers Juan Pablo Califano 2009/4/12 Alexander Farber alexander.far...@gmail.com Hello, I have a static initializer in my class and it works ok: private static var BLACK:TextFormat = new TextFormat('Arial', 24, 0x00, true); private static var RED:TextFormat = new TextFormat('Arial', 24, 0xFF, true); // place 1 closer to 0 in the 10 string { BLACK.letterSpacing = -4; RED.letterSpacing = -4; } But when I try to add a for-loop there (I need to add some data to static array I have in the class), then I get errors Access of undefined property i: { BLACK.letterSpacing = -4; RED.letterSpacing = -4; for (var i:uint = 0; i 10; i++) trace(i); } I have to move the variable i outside the initializer: private static var i:uint; { BLACK.letterSpacing = -4; RED.letterSpacing = -4; for (i = 0; i 10; i++) trace(i); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to smooth bitmap?
Alternatively, just copy the bitmap and smooth it: http://code.awenmedia.com/node/27 HTH, Ian On Sat, Apr 11, 2009 at 3:16 PM, Pavel Repkin pavel.rep...@gmail.com wrote: Hey! I have a bitmap image loaded from external site (Facebook user avatar). Its size is 50x50 pixels and it looks very pixelated when the Flash Stage size changes. The image would look much better if it was smoothed. But, smoothing does not work for images loaded from external domains. MovieClip.forceSmoothing = true just does not work. However if the image resides on the same server as the script, smoothing works like a charm. Do you know how can I smooth the bitmap? Is it possible? AS 2.0, FP 9.0 Pasha. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] tubeloc as3 youtube in flash
Hey all, has anyone messed with the chromeless youtube player in flash? the best way I can find to do this is the tubeloc package, I have successfully built the as3 flash package with ant and the flex builder sdk, but It doesnt seem to actually load the movie, nor does it provide an fla for the main swf. Anyone have some advice or a tutorial to use? -- Preston Parris ppar...@modevisual.com cell: 704.450.9299 www.modevisual.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tubeloc as3 youtube in flash
Hi, You may have to run this from a web-browser rather than from the computer desktop / Flex debugger. I compiled MainChromeless.mxml from FlashDevelop and running it loads a GUI up, but for the youtube player to be loaded in I had to run TubeLoc.html from a webserver running on my PC e.g. with http://devserver/tubeloc/index.html url rather than opening it up from explorer: file:///J:/devserver/tubeloc/TubeLoc.html In my /tubeloc folder are the contents of the as3/lib directory from the zip + the compiled swf TubeLoc.swf output from FlashDevelop. You may have to load the lot up onto your webspace if you don't have a localhost webserver. HTH Glen Preston Parris wrote: Hey all, has anyone messed with the chromeless youtube player in flash? the best way I can find to do this is the tubeloc package, I have successfully built the as3 flash package with ant and the flex builder sdk, but It doesnt seem to actually load the movie, nor does it provide an fla for the main swf. Anyone have some advice or a tutorial to use? -- Glen Pike 01326 218440 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] re: projector
I have a project you can rent / borrow if you want to contact me off list. It's a Sony 3LCD and in fairly new condition (I use it for my touch-screen projects). Dominic ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders