RE: [Flashcoders] re: quick actionscript question
What I'm saying is that you can't fix it from the AS--you have to re-encode the FLVs with keyframes on every frame. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of eric walton 9 / edub9 Edub9 Sent: Wednesday, November 15, 2006 2:41 PM To: Flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] re: quick actionscript question Mike, Not really getting you, the external .as file controls everything so how would we correct it from the as file? Thanks again, Eric The problem is in how the FLVs are encoded. You have to encode with keyframes on every frame. Once that's done, they should scroll fine (although backwards is generaly chunkier than forwards). ¯ Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of eric walton 9 / edub9 Edub9 Sent: Tuesday, November 14, 2006 10:38 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] quick actionscript question Hello anyone know the actionscript for a button that will control a video fast forward and rewind button that forwards and rewinds in a smooth transition? I want to use it with an existing scrubber that is working. The buttons are working but at present they only go back or foreard based on 1 or 2 second increments. Here is what i have at present: // my custom nav buttons are below ff_button.onRelease = function (){ myDisplay.jumpToVideoPosition(myDisplay.currentVideoPosition + 1); } rev_button.onRelease = function (){ myDisplay.jumpToVideoPosition(myDisplay.currentVideoPosition - 1); } Any ideas? Eric ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] quick actionscript question
The problem is in how the FLVs are encoded. You have to encode with keyframes on every frame. Once that's done, they should scroll fine (although backwards is generaly chunkier than forwards). ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of eric walton 9 / edub9 Edub9 Sent: Tuesday, November 14, 2006 10:38 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] quick actionscript question Hello anyone know the actionscript for a button that will control a video fast forward and rewind button that forwards and rewinds in a smooth transition? I want to use it with an existing scrubber that is working. The buttons are working but at present they only go back or foreard based on 1 or 2 second increments. Here is what i have at present: // my custom nav buttons are below ff_button.onRelease = function (){ myDisplay.jumpToVideoPosition(myDisplay.currentVideoPosition + 1); } rev_button.onRelease = function (){ myDisplay.jumpToVideoPosition(myDisplay.currentVideoPosition - 1); } Any ideas? Eric -- To view more about The Artwork of Eric Walton 9 / Edub9 please go to the following address: www.hollywoodfineart.com www.myspace.com/ericwalton9_edub9 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Letting go of AS2 for AS3
In the Flash 9 Public Alpha, it's under Publish Settings Flash ActionScript Settings Document class ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Lori Hutchek Sent: Tuesday, November 14, 2006 11:24 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Letting go of AS2 for AS3 Okay im in the middle of reading AS3 Cookbook, and Essential AS3. And i'm having some trouble grasping the concept of the main class file {as in the root package for the program you are constructing}, both books talk about this. But are they talking about constructing applications using MTASC/mxmlc compilers or is there a way using the Flash 9 IDE to create a main class file that the IDE needs to look for. I know u can write code on the timeline, of course, but just wondering if there some other way which they are elluding to, and me being slow am just not gettin'... Thanks! Lori- ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] HELP!!! Eventdispatcher and firefox bug????
Ot sounds like it has to do with asynchronous events happening in different orders. Try this--when the XML loads, set a loaded flag on the dispatcher to true and then dispatch a load event. Your listeners should: 1) Check if loaded is true. 2) If so, proceed. 3) If not, listen for the load event. I'll bet what's happening now is that your listeners don't start listening until after the XML has already been loaded--hence they never receive the event. (That said, I could be way off.) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 6:00 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] HELP!!! Eventdispatcher and firefox bug I've come across something for the first time... at first I thought it was my code but... My application loads xml, then dispatches a build event to another class which attaches clips from my library. The application ALWAYS works if i launch the swf directly. The application also ALWYAS works if I launch using a browser, but ONLY IE!!! If I use Firefox(I'm using version 1.50.8). and have FP v 9.016 installed..it sometimes works (I can't give a percentage)...but what usually happens is I can trace right up to my 'build' method in the class receving the 'build' event and then nothing!! Clearing the cache DOES NOT HELP! The build method doesnt get called! Again...this is only an issue in Firefox PLEASE HELP! arghh! [e] jbach at bitstream.ca [c] 416.668.0034 [w] www.bitstream.ca ...all improvisation is life in search of a style. - Bruce Mau,'LifeStyle' ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] functions outside a class
If these are functions that don't reference a particular instance (i.e., don't use the this keyword), then it's better to make a static utilities class (similar to, e.g., Flash's Math class): class utils.controls.MyFunctions { // Think of a better name public static function functionA():Void { // ... } public static function functionB():Void { // ... } } // In your class: import utils.controls.MyFunctions; class utils.controls.ClassA { public function someFunction():Void { // ... MyFunctions.functionA(); MyFunctions.functionB(); } } ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Helmut Granda Sent: Friday, November 10, 2006 11:30 AM To: Flashcoders mailing list Subject: [Flashcoders] functions outside a class I have several classes that will use a function. for scope reasons i have placed the function in a different file but i would like to be able to access that file from within the classes. If the function has been declared outside the class, what is the best way to accces those functions? sample: utils.controls: classA classB utils/functions: functionA functionB main timeline: include functionA include functionB now I would like to access functionA or functionB within the class... TIA -- ...helmut ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Test if using ActionScript 2.0
If you were using AS3.0 you could use the flash.display.LoaderInfo.actionScriptversion property. Wait--no, that only distinguishes 1.0 and 2.0 from 3.0. You could use the swfVersion property, though. Why exactly do you need to detect this? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Jeff Fox Sent: Thursday, November 09, 2006 9:37 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Test if using ActionScript 2.0 I want to create a test to see if a loaded SWF is compiled in ActionScript 1 or 2. I'm assuming I can use an old Flash detection trick and call a method that's only supported in ActionScript 2, just not sure which one to call exactly. Will that work? Anyone have any ideas or examples? -Jeff -- Jeff Fox [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Grabbing data directly from the HTML page
I was playing around with the idea of passing data from an HTML page directly into a Flash movie via Javascript/SWFObject. One thing I wanted to try was sending the text that SWFObject replaces into the Flash movie. In Firefox this was pretty simple. E.g., if SWFObject was replacing the contents of div id=flash-content.../div, then all that was needed was something in the Javascript code like: var swfObj = new SWFObject(parameters); swfObj.addVariable(HTML_flashContent, escape('div id=flash-content' + document.getElementById(flash-content).innerHTML.toString() + /div)); Then, in Flash, the root variable HTML_flashContent can be parsed into an XML object. This has obvious benefits for search engine optimization, as well as making it so a Flash and non-Flash version of a page can be the exact same file. Unfortunately, though, Internet Explorer and Safari return SGML, not XHTML, for the innerHTML property (e.g., the above div tag gets converted to DIV id=flash-content.../DIV in IE). I made a quick-and-dirty SGML to XHTML conversion tool to get around this, and it seems to work so far. My question is, has anybody else made an SGML to XHTML conversion tool in ActionScript, or should I continue to refine mine and offer it for public use when done? ― T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Ave. Ste. B Los Angeles, California 90039 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Grabbing data directly from the HTML page
That sounds *much* nicer--how do you grab the whole XHTML page in Javascript? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ryan Potter Sent: Thursday, November 09, 2006 11:39 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Grabbing data directly from the HTML page Not sure how complicated your html page is, but I have been playing with the same idea but going at it a different way. I just loaded the entire page in as xml. As long as the page is valid xhtml it works great. I realize it doesn't exactly answer your sgml question, but it should get you the same effect and it doesn't rewrite your code. Then you can either go directly to the node or use xpath to navigate to it. Just a thought. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: Thursday, November 09, 2006 12:24 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Grabbing data directly from the HTML page I was playing around with the idea of passing data from an HTML page directly into a Flash movie via Javascript/SWFObject. One thing I wanted to try was sending the text that SWFObject replaces into the Flash movie. In Firefox this was pretty simple. E.g., if SWFObject was replacing the contents of div id=flash-content.../div, then all that was needed was something in the Javascript code like: var swfObj = new SWFObject(parameters); swfObj.addVariable(HTML_flashContent, escape('div id=flash-content' + document.getElementById(flash-content).innerHTML.toString() + /div)); Then, in Flash, the root variable HTML_flashContent can be parsed into an XML object. This has obvious benefits for search engine optimization, as well as making it so a Flash and non-Flash version of a page can be the exact same file. Unfortunately, though, Internet Explorer and Safari return SGML, not XHTML, for the innerHTML property (e.g., the above div tag gets converted to DIV id=flash-content.../DIV in IE). I made a quick-and-dirty SGML to XHTML conversion tool to get around this, and it seems to work so far. My question is, has anybody else made an SGML to XHTML conversion tool in ActionScript, or should I continue to refine mine and offer it for public use when done? ― T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Ave. Ste. B Los Angeles, California 90039 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Grabbing data directly from the HTML page
Ah, that works. The only thing is that it requires a double load of the page and the data isn't instantly available (although, with browser-caching, it should load in very quickly). Not huge concerns, but the double load could skew metrics. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of John VanHorn Sent: Thursday, November 09, 2006 12:13 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Grabbing data directly from the HTML page i think you misunderstood the suggestion. you can load the page in as xml in flash, just like loading in any other xml. i would change your swfObject javascript to pass in the location of the page: ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Noob, basic questions on actionscript, with methodology suggestions
You have to use a function because the loading is asynchronous. It doesn't stop program flow while it's loading; it continues with the program and calls a handler (onLoad) once the load is complete. I'm not sure this is the proper forum for n00b questions ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Noob, basic questions on actionscript, withmethodology suggestions
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Scott Haneda Sent: Thursday, November 09, 2006 1:59 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Noob, basic questions on actionscript, withmethodology suggestions Thanks, and if my XML looks like this: Load in this XML file: camps sport=Tennis state name=California cc=3 url=a/ state name=Oregon cc=13 url=b/ state name=Washington cc=2 url=c/ /camps What would be the best way to get myself a set of accessible variables in which I can call out a state name, and get the two remaining parameters? Which version of ActionScript are you using? In 2.0: function getCCAndURL(xml:XML, stateName:String):Object { for (var node:XMLNode = xml.firstChild.firstChild; node != null; node = node.nextSibling) { if (node.nodeName == state node.attributes.name == stateName) { return {cc: node.attributes.cc, url:node.attributes.url}; } } return {cc: null, url: null}; } In 3.0: // Throws an error if more than one state node has the same name. function getCCAndURL(xml:XML, stateName:String):Object { var state:XMLList = xml.state.(@name == stateName); return {cc: [EMAIL PROTECTED], url: [EMAIL PROTECTED]; } Ain't e4x grand? ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Noob, basic questions on actionscript, withmethodology suggestions
Think of it this way: When you call XML.load(), the XML object doesn't say, Right away, sir, there you go! It says, Okay, let me pencil that in for later and I'll get to it when I can. Once you call XML.load(), you shouldn't use the XML object again until XML.onLoad() is called (which is the XML object's way of telling you that it finally got around to it). (ActionScript 3.0 is a bit nicer with its URLLoader class that dispatches multiple types of events instead of calling a single callback function, but that's another topic.) -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Grabbing data directly from the HTML page
Ah, fixing it on the Javascript side! That makes a lot more sense. (And there's no double-load.) Thanks--I'll give this a try. (It's kind of hard to read, though ... but I guess that can be good with Javascript) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Marcelo Volmaro Sent: Thursday, November 09, 2006 12:07 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Grabbing data directly from the HTML page Use the code below. I did it for my implementation of a flash replacer, and works like a charm. input: an html node (node = document.getElementById(nodename)) output: a perfectly valid XML reconstruction of the tree below the node. Works on all browsers. parseTree = function ($node) { if ($node == null) return ''; if ($node.nodeType == null) return ''; var $result = ''; var $chn = $node.childNodes; if ($chn != null) { var $lchnl = $chn.length; if ($lchnl 0) { var $zchild; var $ynodeNamesWeIgnore = 'accessKey|coords|noWrap|dataFormatAs|disabled|dataSrc|object|dataFld|la ng uage|compact|contentEditable|inherit|tabIndex|align|clear|shape|charset| ur n|rel|rev|dir|css'; for (var $j = 0; $j $lchnl; $j++) { $zchild = $chn[$j]; switch ($zchild.nodeType) { case 3: var $val = $zchild.nodeValue.replace(/[\t\n\r\f]*/g, ''); if ($val.replace(/ */g, '') != '') { $result += '![CDATA['+$val+']]'; } break; case 1: var $tag_name = $zchild.nodeName.toLowerCase(); $result += '' + $tag_name; var $wnattr = $zchild.attributes; if ($wnattr != null) { var $xnal = $wnattr.length; if ($xnal) { for (var $i = 0; $i $xnal; $i++) { var $qnodeName = $wnattr.item($i).nodeName; if (($wnattr.item($i).value != 'null') ($ynodeNamesWeIgnore.indexOf($qnodeName) == -1)) { $result += ' ' + $wnattr.item($i).nodeName.toLowerCase() + '=' +$wnattr.item($i).value +''; } } } } if ($zchild.canHaveChildren || $zchild.hasChildNodes()){ $result += ''; $result += parseTree($zchild); $result += '/'+$tag_name+''; } else { $result += ' /'; } } } } } return $result; } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Need help from PHP coder
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Scott Haneda Sent: Thursday, November 09, 2006 5:26 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Need help from PHP coder I don't think you need any special php function: I don't know anything about flash, but I would guess XML.send() takes a file name, or server path as a argument, so put this in that file: $fp=fopen(myxml.xml,wb); fwrite($fp,$HTTP_RAW_POST_DATA); fclose($fp); echo Done saving; Yup. You have to make sure of a certain setting in php.ini, though. I can't remember which one it is, but you can probably find out at: http://php.net ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Freelancer Class
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Dennis Roche Sent: Tuesday, November 07, 2006 10:47 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Freelancer Class I prefer the the double underscore naming scheme to differentiate a local/arugment variable from a class variable. It helps when you want to create get/set functions and reminds you that it is a private variable and should not accessed directly. class Student { private var __name:String; public function Student(name:String) { __name = name; } } Me, too (well, single underscore), but we were talking about setting properties, not variables. You might want to set a property in a field because it has some kind of verification or formatting functionality. For example: class mypackage.MyClass { /** * Class constructor. * * @param nameName for this instance. * @see #name */ public function MyClass(name:String) { this.name = name; } /** * An upper-case string which is the name for this instance. * * pValues are automatically converted to upper-case. May be * [EMAIL PROTECTED] null}./p */ public function get name():String { return _name; } public function set name(value:String):Void { if (value instanceof String) { _name = value.toUpperCase(); } else { _name = null; } } private var _name:String = null; } ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] EventDispatcher and onEnterFrame.... problems
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Wednesday, November 08, 2006 10:24 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] EventDispatcher and onEnterFrame problems Inside an onEnterFrame function you have to use this when referring to things in the class (if the class extends MovieClip, which I hope it does because only MovieClips can have onEnterFrame as far as I know). class MyClass { var foo:Boolean; function MyClass() { this.onEnterFrame = function() { this.foo = !this.foo; this.traceFoo(); } } function traceFoo() { trace(foo); } } But you could just write it this way: class MyClass extends MovieClip { private var foo:Boolean = false; public function MyClass() { } public function traceFoo() { trace(foo); } private function onEnterFrame():Void { foo = !foo; traceFoo(); } } Or even like this: class MyClass extends MovieClip { private var foo:Boolean = false; public function MyClass() { onEnterFrame = toggleAndTraceFoo; } public function traceFoo() { trace(foo); } private function toggleAndTraceFoo():Void { foo = !foo; traceFoo(); } } (Me, I prefer to use an event dispatcher that sends enterFrame events, but I'll admit that that's often overkill.) ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Writing code for big teams
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Michael Nisi Sent: Wednesday, November 08, 2006 11:38 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Writing code for big teams Same here. Can't imagine to develop without testing anymore. Test while you code, not afterwards. It let's you design your objects in a transparent way. Yes. I highly recommend this book: http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201 485672/sr=8-1/qid=1163021817/ref=pd_bbs_sr_1/002-6548398-2158405?ie=UTF8 s=books It really opened my eyes to the utility of unit-testing, and how paying some time up front can allow your code to be more stable and more flexible down the road. (Yes, the examples are in Java, but it's extremely similar to AS.) ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Freelancer Class
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Tuesday, November 07, 2006 12:05 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] Freelancer Class I don't know if it's a remnant. You may be doing property initialization and need to nail down scope: class Student { private var name:String function Student( name:String ) { this.name = name; } } That's just bad coding. Don't use class variable names as argument names. It's not like you don't have a choice about it. ;) I don't think it's bad coding. Documentation generated from this signature might be a bit clearer than documentation generated from a signature where the argument was, e.g., nameValue, since it would be more immediately obvious that the argument name corresponds to the property name. That said, the code itself is clearer the other way. Six of one and half a dozen of the other. (Programming is so often like that.) -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Freelancer Class
They (now Adobe) have pretty much done an about-face on this issue. The ActionScript 3.0 documentation (http://livedocs.macromedia.com/flex/2/langref/ ) is excellent. And they do use the argument name = property name syntax in constructors. For example, http://livedocs.macromedia.com/flex/2/langref/Error.html Error(message:String = , id:int = 0) Creates a new Error object. (Well, the id argument corresponds to the errorID property--so I guess they went both ways on this one!) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Tuesday, November 07, 2006 1:34 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] Freelancer Class Pretty much. You either muddy up your code or your docs. I opt to muddy up docs over code, just like Macromedia. ;) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Copy Constructor
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Saturday, November 04, 2006 2:39 AM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor Couldn't quite figure out your code Mike so have just rewritten the copy function based on what you said: Well, that was the most important part. I am however curious to understand the BoardStatus class you wrote. You declared a variable of type BoardStatus within BoardStatus. Can you explain what you are doing here please. This was an example of an enumeration class. As I recall, your code had been storing the status of each Connect-4 square (red, black, or empty) as a number (0, 1, or 2). The problem with this is that it's easy to slip it a bad number (e.g., 3, 4, 5, etc.). One solution is to create an enumeration class. An enumeration class has a private constructor and a finite number of instances, generally static constants (or pseudo-constants) associated with the class. Thus, it is impossible to assign an invalid value to anything that requires a variable of that class type. Example (somewhat modified from my previous example): class connect4.SquareStatus { private function SquareStatus() { } public static var BLACK:SquareStatus = new SquareStatus(); public static var EMPTY:SquareStatus = new SquareStatus(); public static var RED:SquareStatus = new SquareStatus(); } // Elsewhere: var status:SquareStatus; // It is impossible to set this variable to anything but null, undefined, or a valid SquareStatus value. status = SquareStatus.RED; Incidentally, you could skip the EMPTY value and just have null signify an empty square. In AS3.0, this becomes trickier, since there are no private constructors. Anyone know if there is a recommended way to get around this? (On the plus side, you can make the class final and the static values constant, which is a major shortcoming in AS2.0.) -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP advice for game
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Cédric Néhémie Sent: Sunday, November 05, 2006 5:52 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP advice for game You may prefer a more common syntax for the singleton access method, like getInstance for example. In ActionScript (as opposed to Java), I think it's better to use a property: class Singleton { private function Singleton() { } public static function get instance():Singleton { if (_instance == undefined) { _instance = new Singleton(); } return _instance; } private static var _instance:Singleton; } // Elsewhere: Singleton.instance; // Returns the only instance of Singleton. Personally I would prefer an EventDispatcher rather than the Observer Yes. EventDispatcher is everywhere in AS3.0, so might as well start using it now. pattern, creating events like onWindChange, onRainChange, etc..., and a WeatherEvent object carrying the new weather values. Generally in the code that Macromedia/Adobe writes, event names dont have on as part of the name, but a function responding to them might, e.g.: WeatherManager.instance.addEventListener(windChange, Delegate.create(this, onWindChange)); Or, in AS3.0: WeatherManager.instance.addEventListener(windChange, onWindChange); -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Have I got this OOP business right?
Looks pretty good to me! You might consider having the display classes dispatch an event instead of calling a single function when they close--then you can extend behavior more easily in the future, if several things need to happen based on the same event. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Haydn Sent: Sunday, November 05, 2006 11:31 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Have I got this OOP business right? Hi, I've got a simple little game that I'm trying to make with AS2, but I'm not sure that I'm doing it right. Here's what I've got so far. I've used a 'document class' as described here: http://www.bit-101.com/blog/?p=857 Here's the code in the .fla: Game.create(this); In Game.as: class Game extends MovieClip { private var splash:Splash; private var preload:Preload; private var mainMenu:MainMenu; private function Game() { showSplash(); } public static function create(target:MovieClip):Void { target.__proto__ = Game.prototype; Function(Game).apply(target, null); } public function showSplash():Void { Splash.create(this, splash, getNextHighestDepth()); splash.setEndFunction(this, showPreload); } public function showPreload():Void { Preload.create(this, preload, getNextHighestDepth(), this); preload.setEndFunction(this, showMainMenu) } public function showMainMenu():Void { MainMenu.create(this, mainMenu, getNextHighestDepth()); // etc. } } The Splash, Preload and MainMenu classes each have a static function called create that attaches an instance of their symbol to the stage. The two setEndFunction functions tell Splash and Preload what call when they've finished doing their thing. Is this a reasonable way of going about things, or am I just making life hard for myself? Thanks, Haydn. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] preventing scientific notation
AS3.0 has Number.toFixed(): http://livedocs.macromedia.com/flex/2/langref/Number.html#toFixed() Of course, that probably doesn't help you ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Hans Wichman Sent: Monday, November 06, 2006 9:42 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] preventing scientific notation Hi Chris, thanks for your reply. According to the manual flash should be able to handle numbers up to 1.79769313486232e+308? Mine is 1e+21 so it seems i should have a little way to go before i max out:). Threading the number as a string isnt possible, since the webservice interface requires Int64. If i cast the number i get from the service to a string, my string reads 1e+21 Any ideas? JC On 11/6/06, Chris Benjaminsen [EMAIL PROTECTED] wrote: Hi Hans The numbers you are trying to store are way to large for Flash to handle as a number. If you however just thread the numbers as strings it should work perfectly. /Chris Hans Wichman wrote: Hi list, i need to talk to webservices which pass me back very large db id's, which im using again to request more info. However when i do (for example): var b:Number = 10; trace (b); it prints 1e+21 Now when I use this value as an argument to this webservice it seems to fail. When I use a tool like wsstudio2 and copy and paste the long version, it works fine. Any ideas on how to fix this? greetz JC ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OT conver java code to flash
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Chris Benjaminsen Sent: Friday, November 03, 2006 5:42 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] OT conver java code to flash Hi Paul Actually Math.random always return a positive number between 0 and 1 [...] Strictly speaking, it returns a *nonnegative* number from 0 (inclusive) to 1 (exclusive). I.e, once in a blue moon it might actually return 0, but it will never return 1; 0.9 (or something like that) is as close as it gets. The distinction doesn't matter much in practice, but ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Copy Constructor
I don't see anything wrong after a (very) cursory glance. One red flag, though, is that you are making your variables public. This means there could be code elsewhere that sets them to be identical to each other. Because of issues like this, I think it's a good practice never to make variables public (except in some cases, like static pseudo-constants in AS2.0; but AS3.0 has real constants, so this problem goes away). There are two things you could do with an array: 1) make it read-only, offering a defensive copy with a getter; 2) provide methods for accessing and updating its data: 1) public function get board():Array { return _board.concat(); } private var _board:Array; 2) public function getBoardStatus(x:Number; y:Number):Number { return _board[x][y]; } public function setBoardStatus(x:Number; y:Number, value:Number):Void { _board[x][y] = value; } Actually, looking at it further, Board should probably be a class composed by Connect4State. Oh, damn, and I realized why you are having that problem! See copy function below (it's because you are copying an array of arrays): class connect4.BoardStatus { private function BoardStatus() { } public static var BLACK:BoardStatus = new BoardStatus(); public static var EMPTY:BoardStatus = new BoardStatus(); public static var RED:BoardStatus = new BoardStatus(); } class connect4.Board { public function Board(source:Board) { if (source instanceof Board) { copy(source); } else { // Default initialization; } } public function copy(source:Board):Void { _status = new Array(); for (var i:Number = 0; i source._status.length; ++i) { _status[i] = source._status[i].concat(); } } public function getStatus(row:Number, col:Number):BoardStatus { return _status[row][col]; } public function setStatus(row:Number, col:Number, value:BoardStatus):Void { _status[row][col] = value; } private var _status:Array; } class connect4.GameState { public function GameState(source:GameState) { if (source instanceof GameState) { copy(source); } else { _board = new Board(); // Initialize other fields. } } public function get board():Board { return _board; } // Other properties. public function copy(source:GameState):Void { _board = new Board(source._board); // Copy other fields. } private var _board:Board; // Other private fields. } ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Friday, November 03, 2006 10:44 AM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor I think the problem may be that I am recursively creating the copies. Here are the two classes in full if anyone would be kind enough to see if they can help. Been on this all day and have made no progress http://www.mediakitchen.co.uk/Connect4Engine.as http://www.mediakitchen.co.uk/Connect4State.as Thanks Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven Sent: 03 November 2006 17:55 To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor Seem to be having problems with this still. It seems like every time I change a value in the main constructor objects array, it also changes the array values in the copies. Are these copies essentially just pointers to the same array? Basically the reason I need copies is so it can simulate future moves in the game by updating a copy of the game state arrays. So essentially I need to create copies of these arrays that I can manipulate without these manipulations affecting the arrays they were copied from. I hope that makes sense Thanks Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: 02 November 2006 22:53 To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor I might do it like this: class mypackage.Connect4State extends Object { public function Connect4State(state:Connect4State) { super(); if (state instanceof Connect4State) { copy(state); } else { board = new Array(); score = new Array(); // Default initialization code. } } public function copy(state:Connect4State):Void
RE: [Flashcoders] Flash Print Function and Callbacks ?
Pretty sure you can't. Just noticed something odd whil looking at the documentation on AS3.0's ProntJob class (http://livedocs.macromedia.com/flex/2/langref/)--it extends EventDispatcher, yet it doesn't have any documented events. Vot der hey? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Stephen Ford Sent: Wednesday, November 01, 2006 9:57 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Flash Print Function and Callbacks ? Does anyone know if Flash's built in Print command has anyway of providing a callback once a print job has been executed ?? I need to set a clips visibility to false while the printing takes place, then set it back to visible once the print executes ?? Is this possible ?? Thanks, Stephen. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Copy Constructor
I might do it like this: class mypackage.Connect4State extends Object { public function Connect4State(state:Connect4State) { super(); if (state instanceof Connect4State) { copy(state); } else { board = new Array(); score = new Array(); // Default initialization code. } } public function copy(state:Connect4State):Void { board = state.board.concat(); score = state.score.concat(); } public var board:Array; public var score:Array; } Then you could call the construct with or without a parameter. (Actually, I would never use public variables, but that's another topic) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Thursday, November 02, 2006 2:31 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor Perhaps it is easier if I explain what I need: I am rewriting some Java code into AS2. Basically I have a class called Connect4State class Connect4State { public function Connect4State() { // - // Initialize the board array // -- board = new Array(); code goes here // -- // Initialize the score array // -- score = new Array(); code goes here } public var board:Array; // A 7 by 6 two dimensional array of integers representing the state of game public var score:Array; // A 2 dimensional array of integers representing the score for the players } The Java code has a function called a Copy Constructor that enables you to create new objects that are copies of existing objects. The copy constructor for Connect4State just copies the contents of each member variable. It is necessary to have a copy constructor for Connect4State because the AI algorithms use temporary state objects a great deal This is the copy constructor code translated to AS2 public function Connect4State(state:Connect4State) { // -- // Copy the board // -- board = new Array(); for (var i:Number = 0; i 7; i++) { board[i] = new Array(); for (j:Number = 0; j 6; j++) { board[i][j] = state.board[i][j]; } } // --- // Copy the scores // --- for (var i:Number = 0; i 2; i++) { score = new Array(); for (var j:Number = 0; j winPlaces; j++) { score[i][j] = state.score[i][j]; numPieces = state.numPieces; } } } AS2 seems not to like this as I get the following error A class must have only one constructor. public function Connect4State(state:Connect4State) Anyone suggest an alternative to this Copy Constructor? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven Sent: 02 November 2006 20:01 To: 'Flashcoders mailing list' Subject: [Flashcoders] Copy Constructor Hi there Is there an equivalent of the Java Copy constructor in Flash AS2? Thanks Paul ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Copy Constructor
Maybe I'm not quite getting the concept, but a copy constructor should be a constructor that copies data from another object to the object being created, right? And (I think) the original poster wanted to know how to overload constructors in ActionScript so as to have a default (argument-less) constructor and a copy constructor. But you can't overload functions in ActionScript. You only get one form for each method/constructor. But you can make the argument(s) optional, which is what I did in my example, posted earlier. In AS3.0, I think the constructor might look more like this: // ... function ClassName(source:* = null) { super(); // ... if (source is ClassName) { copy(ClassName(source)) } else { // Default initialization. } } public function copy(source:ClassName):void { // Copy data from source to this object. } /... Example of code using this class: var a:ClassName = new ClassName(); // Default initialization. // Code that modifies a. var b:ClassName = new ClassName(a); // Creates a copy of a. Another possibility is to create a clone() method: // ... public function clone():ClassName { var cloneObj:ClassName = new ClassName(); cloneObj.copy(this); return cloneObj; } // ... ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Thursday, November 02, 2006 2:53 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] Copy Constructor How about this? class Test { var foo:String; var bar:String; function Test(initObj:Object) { for (var a:String in initObj) { this[a] = initObj[a]; } } public function get data():Object { var obj:Object = {}; obj.foo = foo; obj.bar = bar; return obj; } public function copyConstructor():Test { return new Test(data); } } // import Test; test1 = new Test(); test1.foo = Hello; test1.bar = World; test2 = test1.copyConstructor(); trace(test2.foo); trace(test2.bar); -- Hello -- World ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Copy Constructor
A call to super() is not required unless you are passing arguments to the superclass' constructor. Nor is it required that you specify that you are extending Object. (If you don't specify a superclass, it assumes Object.) I just do it that way because I'm anal about my code. ;) Calling super() calls the constructor of the superclass (i.e, parent class). One instance where you might need it is if the constructor signatures do not match, e.g.: class SuperClass extends Object { public function SuperClass(superValue:Number) { _superField = superValue; } public function get superField():Number { return _superField; } private var _superField:Number; } class SubClass extends SuperClass { public function SuperClass(superValue:Number, subValue:Number) { super(superValue); _subField = subValue; } public function get subField():Number { return _subField; } private var _subField:Number; } The super keyword can also be used to access fields and methods of the superclass, e.g. where methods have been overridden in the subclass, e.g.: public function toString():String { return super.toString() + extra subclass info; } ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Thursday, November 02, 2006 4:03 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor Thanks a million Mike, that works perfectly. I now have a chance of getting this game up and running by the morning. One question though. I commented out the super(); after reading the following: The super() call in the constructor class is not required because Flash handles this for you in AS2, and it is handled properly. In AS1 you had to call super() to make sure the superclass' constructor was called. The order for class initialization tended to be a bit odd. That is not the case in AS2. I am fairly new to AS2 so I do not really understand what super() does but its all working fine so far as far as I can see. Can you comment on whether the super() is required? Thanks Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: 02 November 2006 22:53 To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor I might do it like this: class mypackage.Connect4State extends Object { public function Connect4State(state:Connect4State) { super(); if (state instanceof Connect4State) { copy(state); } else { board = new Array(); score = new Array(); // Default initialization code. } } public function copy(state:Connect4State):Void { board = state.board.concat(); score = state.score.concat(); } public var board:Array; public var score:Array; } Then you could call the construct with or without a parameter. (Actually, I would never use public variables, but that's another topic) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Thursday, November 02, 2006 2:31 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Copy Constructor Perhaps it is easier if I explain what I need: I am rewriting some Java code into AS2. Basically I have a class called Connect4State class Connect4State { public function Connect4State() { // - // Initialize the board array // -- board = new Array(); code goes here // -- // Initialize the score array // -- score = new Array(); code goes here } public var board:Array; // A 7 by 6 two dimensional array of integers representing the state of game public var score:Array; // A 2 dimensional array of integers representing the score for the players } The Java code has a function called a Copy Constructor that enables you to create new objects that are copies of existing objects. The copy constructor for Connect4State just copies the contents of each member variable. It is necessary to have a copy constructor for Connect4State because the AI algorithms use temporary state objects a great deal This is the copy constructor code translated to AS2 public function Connect4State(state:Connect4State) { // -- // Copy the board
RE: [Flashcoders] terminating hotspots etc
Well, the easiest way to shut off all hotspots (and it's kind of a hack, but a pretty useful one) is to throw a big, invisible button with property useHandCursor set to false over everything. That won't work for motion, though. For motion the most elegant solution is probably to use a singleton EventDispatcher to control everything: // MotionDispatcher class import mx.events.EventDispatcher; [Event(start)] [Event(stop)] function mypackage.MotionController extends EventDispatcher { private function MotionDispatcher() { super(); } public static function get instance():MotionController { if (_instance == undefined) { _instance = new MotionController(); } return _instance; } public function get stopped():Boolean { return _stopped; } public function set stopped(value:Boolean):Void { if (_stopped != Boolean(value)) { _stopped = Boolean(value); dispatchEvent({type: _stopped ? stop : start, target: this}); } } private static var _instance:MotionController; private var _stopped:Boolean = false; } // In a motion-controlled movieclip with a timeline animation: import mx.utils.Delegate; MotionController.instance.addEventListener(start, Delegate.create(this, play)); MotionController.instance.addEventListener(stop, Delegate.create(this, stop)); // To stop all controlled animations: MotionController.instance.stopped = true; // To restart all controlled animations: MotionController.instance.stopped = false; ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of :: joshua Sent: Thursday, November 02, 2006 4:27 PM To: Flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] terminating hotspots etc hey everyone. ok heres the situation: i have a flash site that I would like to terminate all functionality to when a help panel comes up. essentially shutting off all hotspots and motion mc's. would there happen to be an easy way to make this happen... im afraid i know the answer to this[hoping i'm wrong]...but that's why i'm turning to you all... cheers. joshua ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OT conver java code to flash
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Thursday, November 02, 2006 3:15 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] OT conver java code to flash Thanks Jim It is AS2, and the context is below. Btw what is the difference between Math.rand() and Math.random()? There is no Math.rand(). There was a top-level function, random(), which returned integers (I think), but it is deprecated. Just use Math.random(): var MAX:Number = [some positive integer value]; var randomInt:Number = Math.floor(MAX * Math.random()); // Sets it to some number from 0 to MAX - 1. ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Create zip file through flash
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Claus Wahlers Sent: Wednesday, November 01, 2006 6:49 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Create zip file through flash He's talking about zipping up files on the local filesystem. Flash 9 can do that? Flash 9 has native filesystem access which would allow compressing files on your hard drive? Flash Player 9 can zip up files pretty easily, but of course can't access the local filesystem. Sorry for the noise. Don't apologize--I found the unzip class interesting! ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Q:Coding : from Procedural to Class based code?
Well, as an initial stab, you could do something like this: package radialnav class RadialManager extends MovieClip center:Point [read-only] createItem(symbolName:String, tweenSettings:TweenSettings):RadialItem tweenIn():Void tweenOut():Void class RadialItem extends MovieClip manager:RadialManager [read/write] tweenSetting:TweenSettings [read-only] tweenIn():Void tweenOut():Void class TweenSettings extends Object durationIn:Number [read/write] durationOut:Number [read/write] easeType:String [read/write] nodes:Array [read/write] radius:Number [read/write] copy(source:TweenSettings):Void ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, November 01, 2006 12:10 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Q:Coding : from Procedural to Class based code? Hi I have a project that I'd like to convert to class based code but would appreciate some advice on the best approach. Basically I have a routine which attaches a number of library items to the stage and, on either a rollover or press event, tweens these items(images) out in a radial fashion. They optionally return to their initial (overlapping) state. Pretty simple stuff. All of the tweening properties (number nodes, circle radius, duration out, duration in, ease type, etc) are predefined and passed in as a single object. My question is: What is the best way to convert this into a Class? Should I simply have a 'create' method in my class that takes the place of my original method? When attaching large numbers of library items, isn't there a 'speed hit'? Should the tweening objects(basically containers for tween properties) have their own class as well? What's should the getters/setters return/set? Any feedback greatly appreciated! Jim Bachalo [e] jbach at bitstream.ca [c] 416.668.0034 [w] www.bitstream.ca ...all improvisation is life in search of a style. - Bruce Mau,'LifeStyle' ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS 3 - event args
Yeah, the simplest way is to create an index field on the buttons themselves, and then access that in the listener with event.target.index. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of dnk Sent: Tuesday, October 31, 2006 6:59 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS 3 - event args Mike Chambers wrote: 2 other options: Just have one event handler per button. or use an anonymous function myButton.addEventListener(MouseEvent.CLICK, function(){doSomething(1);}); private function doSomething(index:int):void { trace(index); } (I havent tested the code above, so there might be some syntax errors). Personally, I would always have one event listener per button as I feel it make it a little easier to read the code. mike chambers [EMAIL PROTECTED] Hey - the anon function seems to be the way that resembles what I used to do. The only reason I do not have a unique one per button is say for example I have 25 buttons and I loop through to create the instances and the event listeners - then have a function that performs the same actions (with a different index number). Then I only have to write out 1 function for the 25 button instances. Unless there is a way to do it with a loop, I would then have to write out 25 unique functions to handle the button events - correct? That is if I was going to do it your preferred way with unique button functions Dustin ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] playing audio filetypes other than mp3?
You can use ByteArray in Flash 9 to load any kind of binary data. While you could use this to create image-rendering plugins using BitmapData (or even video-rendering, although I question performance), there's no corresponding SoundData class, is there? So I think, at least as far as sound goes, you're kind of stuck with MP3. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Josh Santangelo Sent: Wednesday, November 01, 2006 3:54 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] playing audio filetypes other than mp3? I'm wondering if anyone's managed to play filetypes other than MP3 in Flash. Obviously you can't just load them up, but I'm envisioning loading them into a hidden instance of the QuickTime plugin, and then using JavaScript to bridge the two so that you can control the playback from Flash. Anyone seen/done anything similar? -josh ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS 3 - event args
One way would be to create a subclass of Event that stores the parameters. In this case, though, I wouldn't even do that. You can just use event.target to determine which button was pressed: function onPressed(event:Event):void { var button:Button = Button(event.target); // Do stuff with button. } If you need to specifically use an index number, I'd attach that to the button instances themselves. Then you could retrieve that via event.target. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of dnk Sent: Friday, October 27, 2006 7:59 PM To: Flashcoders mailing list Subject: [Flashcoders] AS 3 - event args Hi there. I am just beginning my adventure into AS 3, and came upon something. In AS 2 I used to use a custom delegate class to deal with scope issues, but also be able to pass args (in an array, single string, etc) to my event functions. So for example, I might have something in AS 2: // snipped fro ma method for (var j:Number = 0; j 5; j++) { this._targetMc[dtBtn + j].onPress = MyDelegate.create(this, onPressed, j); } // event method function onPressed(i:Number) { trace(i); } So the custom class would allow this to work in my classes. Now in AS 3 as I have read, the basic delegate class is no longer needed as the scope issues are dealt with now. So how would I go about accomplishing the same thing in AS 3? passing an arg to an event method? Thanks! Dustin ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS 3 - event args
Here's an example: ---mypackage/IndexButton.as--- package mypackage { public class IndexButton extends Button { function IndexButton() { super(); } public function get index():uint { return _index; } public function set index(value:uint):void { _index = value; } protected var _index:uint; } } ---in some other class--- //... protected function init():void { for each (var button:IndexButton in this) { button.addEventListener(release, onButtonPressed); } } protected function onButtonPressed(event:Event):void { if (event.target is IndexButton) { var index:uint = IndexButton(event.target).index; // Do something with index. } } //... ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Bbt Lists Sent: Monday, October 30, 2006 4:44 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS 3 - event args Mike Keesey wrote: One way would be to create a subclass of Event that stores the parameters. In this case, though, I wouldn't even do that. You can just use event.target to determine which button was pressed: function onPressed(event:Event):void { var button:Button = Button(event.target); // Do stuff with button. } If you need to specifically use an index number, I'd attach that to the button instances themselves. Then you could retrieve that via event.target. ― Mike Keesey With the way I do intend to use it, I would have to pass an index as that index provides the basis for many actions within the onPressed function. And I am not sure what you mean by attaching the button instance itself... how would one go about that? -- dnk ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS 3 - event args
Err, that last function should probably be called onButtonRelease ... but you get the idea ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: Monday, October 30, 2006 5:04 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] AS 3 - event args Here's an example: ---mypackage/IndexButton.as--- package mypackage { public class IndexButton extends Button { function IndexButton() { super(); } public function get index():uint { return _index; } public function set index(value:uint):void { _index = value; } protected var _index:uint; } } ---in some other class--- //... protected function init():void { for each (var button:IndexButton in this) { button.addEventListener(release, onButtonPressed); } } protected function onButtonPressed(event:Event):void { if (event.target is IndexButton) { var index:uint = IndexButton(event.target).index; // Do something with index. } } //... ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Bbt Lists Sent: Monday, October 30, 2006 4:44 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS 3 - event args Mike Keesey wrote: One way would be to create a subclass of Event that stores the parameters. In this case, though, I wouldn't even do that. You can just use event.target to determine which button was pressed: function onPressed(event:Event):void { var button:Button = Button(event.target); // Do stuff with button. } If you need to specifically use an index number, I'd attach that to the button instances themselves. Then you could retrieve that via event.target. ― Mike Keesey With the way I do intend to use it, I would have to pass an index as that index provides the basis for many actions within the onPressed function. And I am not sure what you mean by attaching the button instance itself... how would one go about that? -- dnk ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Q:passing a variable as argument with getURL(javascript:testfunc(arg));
Use this: var arg:String = myvar; getURL(javascript:testfunc(' + arg + ')); // Note: arg's value cannot have apostrophes in it. Or, better yet, look into the flash.external.ExternalInterface class. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, October 24, 2006 9:55 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Q:passing a variable as argument with getURL(javascript:testfunc(arg)); Hi I'm having a problem using getURL to pass a variable argument to a javascript function this works(notice 'arg' is a string) getURL(javascript:testfunc('arg')); this DOESN'T work: var arg='myvar' getURL(javascript:testfunc(arg)); Any suggestions??? [e] jbach at bitstream.ca [c] 416.668.0034 [w] www.bitstream.ca ...all improvisation is life in search of a style. - Bruce Mau,'LifeStyle' ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Moving to AS2, array always undefined
I prefer underscores for fields, too, but I'd still use the belowmentioned constructor argument syntax if I wanted to set a property corresponding to a field so as to take advantage of any format-checking in the property setter: class PolarCoordinate extends Object { public function PolarCoordinate(radius:Number, theta:Number) { super(); this.radius = radius; this.theta = theta; } public function get radius():Number { return _radius; } public function set radius(value:Number):Void { if (isNaN(value) || !isFinite(value)) { // Default to 0. _radius = 0; } else { _radius = value; } } public function get theta():Number { return _theta; } public function set theta(value:Number):Void { if (isNaN(value) || !isFinite(value)) { // Default to 0. _theta = 0; } else { // Normalize: 0 ≤ θ 2π while (value 0) { value += Math.PI * 2; } while (value = Math.PI * 2) { value -= Math.PI * 2; } _theta = value; } } private var _radius:Number; private var _theta:Number; } �D Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of JOR Sent: Thursday, October 12, 2006 7:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Moving to AS2, array always undefined No, it isn't wrong which was entire the point of my earlier response. I gave essentially the same example as you. In fact, you've included it quoted at the bottom of your response which I left intact. However, just because it is correct doesn't mean I prefer it over other conventions. I prefer to use underscores with my field names. -- james Ash Warren wrote: In practice, you're right and I try not to name any parameters the same as a field name to avoid this confusion. Don't tell anyone, but sometimes I don't even use this. :) So this is wrong? function MyClass (myParam1:Number, myParam2:String) { this.myParam1 = myParam1; this.myParam2 = myParam2; } For me this method seems much easier to read and it even refers to naming parameters this way in the adobe best-practices article. Why try and come up with 2 names for the same thing, when one will suffice just fine? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JOR Sent: Tuesday, October 10, 2006 5:52 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Moving to AS2, array always undefined A bad practice most likely, but not technically wrong. I do see it in text books from time to time. I was just mentioning it as a case where this *would* be needed as opposed to speaking in absolutes. In practice, you're right and I try not to name any parameters the same as a field name to avoid this confusion. Don't tell anyone, but sometimes I don't even use this. :) James O'Reilly - Consultant Adobe Certified Flash Expert http://www.jamesor.com Design . Code . Train Steven Sacks | BLITZ wrote: Correct me if I'm wrong, but it looks like your rationale is entirely based on an argument name being identical to a class variable name. I might be looking at this too simply, but shouldn't you just use a different argument name if it clashes with a class variable name? -Steven -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of JOR Sent: Tuesday, October 10, 2006 1:19 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Moving to AS2, array always undefined Actually, the need is dependent on the implementation. It was my understanding that AS first looks to the local scope for the existence of a variable then works up to find it. By using this you were explicitly telling flash that the var isn't local to the function but rather belongs to the object cutting out a step for the VM. Therefore, something like the following becomes possible and the use of this becomes necessary: class MyConstructor { private var target:MovieClip; public function MyConstructor (target:MovieClip) { this.target = target; } } Because you can not do this: class MyConstructor { private var target:MovieClip; public function MyConstructor (target:MovieClip) { target = target; // ? } } However, depending on your naming conventions you might not have to use this if you did something like the following
RE: [Flashcoders] Error check for parseXML()
Good point. One optional tweak: var xml:XML = new XML(); xml.ignoreWhite = true; xml.parseXML(someTextVar); xml.onLoad = function(success:Boolean):Void { if (this.status == 0) { trace(Success!); } else { trace(Error in XML! Code: + this.status); } } The scope should probably be this instead of xml in this case. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ray Chuan Sent: Saturday, October 07, 2006 2:21 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Error check for parseXML() Hi, you should put the conditional in a callback, because when execution reaches the conditional xml parsing might not have finished parsing. var xml:XML = new XML(); xml.ignoreWhite = true; xml.parseXML(someTextVar); xml.onLoad = function(success:Boolean):Void { if (xml.status == 0) { trace(Success!); } else { trace(Error in XML! Code: + xml.status); } } Note that the success argument can be ignored if you're using functions like parseXML(), because it's got to do with the success of loading a document using XML.load() or XML.sendAndLoad(). On 10/7/06, Mike Keesey [EMAIL PROTECTED] wrote: Use the XML.status field. var xml:XML = new XML(); xml.ignoreWhite = true; xml.parseXML(someTextVar); if (xml.status == 0) { trace(Success!); } else { trace(Error in XML! Code: + xml.status); } ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: Friday, October 06, 2006 6:50 AM To: Flashcoders mailing list Subject: [Flashcoders] Error check for parseXML() Hi list... According to the help docs, public parseXML(value:String) : Void doesn't return an integer or anything to indicate successful parsing of the xml. How can I be certain that I've passed in some error free xml and it was able to parse? Thanks, - Michael M. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Cheers, Ray Chuan ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Error check for parseXML()
Use the XML.status field. var xml:XML = new XML(); xml.ignoreWhite = true; xml.parseXML(someTextVar); if (xml.status == 0) { trace(Success!); } else { trace(Error in XML! Code: + xml.status); } ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: Friday, October 06, 2006 6:50 AM To: Flashcoders mailing list Subject: [Flashcoders] Error check for parseXML() Hi list... According to the help docs, public parseXML(value:String) : Void doesn't return an integer or anything to indicate successful parsing of the xml. How can I be certain that I've passed in some error free xml and it was able to parse? Thanks, - Michael M. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] when classes die...
The term is a destructor; and, no, ActionScript doesn't have destructors, only constructors. The closest it comes is MovieClip.onUnload()--if your class is a subclass of MovieClip, then you can just override that. If not, one common practice is to make a function called destroy(): public function destroy():Void { // Perform clean-up. delete this; } Then replace all instances of delete instanceOfYourClass; with instanceOfYourClass.destroy(). ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of grimmwerks Sent: Monday, October 02, 2006 6:34 PM To: Flashcoders mailing list Subject: [Flashcoders] when classes die... Ok, I've got an app that uses a static variable; I've got 'templates' that use x instances of this class. When the user loads in a new template when a previous template has already existed, I get some 'leftover' variables. Is there a function that is called when a class is 'killed', ie the opposite of when a class is birthed with 'new'? -- ---[ http://www.grimmwerks.com ---[ [EMAIL PROTECTED] ---[ [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] when classes die...
Will that be called if you use unloadMovie() or if the playhead moves to a frame without the instance? MovieClip.onUnload is put there specifically for this kind of purpose. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Johannes Nel Sent: Tuesday, October 03, 2006 11:14 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] when classes die... for movieclips i tend to override removemovieclip myself. just a personal pref i suppose :) On 10/3/06, Mike Keesey [EMAIL PROTECTED] wrote: The term is a destructor; and, no, ActionScript doesn't have destructors, only constructors. The closest it comes is MovieClip.onUnload()--if your class is a subclass of MovieClip, then you can just override that. If not, one common practice is to make a function called destroy(): public function destroy():Void { // Perform clean-up. delete this; } Then replace all instances of delete instanceOfYourClass; with instanceOfYourClass.destroy(). ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of grimmwerks Sent: Monday, October 02, 2006 6:34 PM To: Flashcoders mailing list Subject: [Flashcoders] when classes die... Ok, I've got an app that uses a static variable; I've got 'templates' that use x instances of this class. When the user loads in a new template when a previous template has already existed, I get some 'leftover' variables. Is there a function that is called when a class is 'killed', ie the opposite of when a class is birthed with 'new'? -- ---[ http://www.grimmwerks.com ---[ [EMAIL PROTECTED] ---[ [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- j:pn http://www.lennel.org ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] when classes die...
Well, I'll be darned. var a:Object = new Object(); var b:Object = a; a.toString = function():String { return object; } trace(a + , + b); delete a; trace(a + , + b); Output: object, object undefined, object Is there any difference at all between deleting a variable and setting it to undefined? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Peter Hall Sent: Tuesday, October 03, 2006 3:55 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] when classes die... public function destroy():Void { // Perform clean-up. delete this; } This code is garbage. The delete operator operates on variables and not on values. So delete this will just delete a variable called this within the scope of that function. To remove an object from memory, you have to remove all references to it. And you can do that by using delete on each one of those references, or by setting those variables to some other value. Peter ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Implicit setters and exceptions in AS2.0
I think that's very well-put. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of David Bellerive Sent: Thursday, September 28, 2006 8:22 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Implicit setters and exceptions in AS2.0 Last week, I sent a message to the FlashCoders list asking if validating the values passed to setter methods (in custom classes) was a good practice. After reading on how exceptions work in Java, here's the solution I've decided to use in my setter methods in AS2.0. If the client (the programmer using my custom class) breaks his part of the contract by supplying my setter method with an illegal value, I display an alert in the output window using the trace statement and abort the implicit setter method without assigning the illegal value that was passed to the method. On the other hand, if the implicit setter method is the one breaking the contract (it can't complete it's task for whatever reason), I throw and exception. I've decided to use this method because AS2.0 doesn't support checked and unchecked exceptions like Java. In AS2.0, all exceptions are unchecked, meaning the client isn't forced to catch any exceptions. But when an exception goes uncaught, the function call stack completely aborts. So, using this method, when the client is responsible for breaking the contract (like passing an illegal value to the setter method), he is alerted via the output window in the Flash IDE. This way, he isn't forced to respond to low-risk errors and the function call stack won't abort under any circumstance. However, the client cannot react to this error at runtime. However, when the setter method is the one responsible for breaking the contract, an exception is thrown and the client has to catch it to prevent the function call stack from aborting completely. If the client doesn't catch the exception, the function call stack is emptied and the program probably won't work as expected. However, if the exception is caught (and it should), the client has the possibilty to react to it at runtime. In conclusion, when the error comes from the client only alert the client. When the error comes from the method, throw an exception. Any thoughts or comments on this ? __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] log or sin or what?
According the the name, it should be some kind of a quadratic equation (ax^2 + bx + c = 0). You could get something looking a lot like this with the sine or cosine functions, though. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of til Sent: Thursday, September 28, 2006 4:24 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] log or sin or what? Does anyone know what formula yields a curve that looks sorta like this? http://hosted.zeh.com.br/mctween/examples/tracer.swf?mode=easeinoutquad ~Til ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] How do you manage your classes?
Lately I actually copy all packages to a folder within my project's folder. Why? Suppose you have a package and you use it on project A. Later, you use it on project B, and realize there are some issues, so you change some of the code. Project B finishes. Then, later on, you find you have to go back to project A with some tweaks and republish it. Because of changes in the package, there may be problems--at best you will still have to spend time regression testing. Copying your packages to a project-local folder means that you have a secure snapshot of the package. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Dan Rogers Sent: Monday, September 25, 2006 4:36 PM To: Flashcoders mailing list Subject: [Flashcoders] How do you manage your classes? Flashcoders, I've been wondering how other flash developers deal with AS2/AS3 class management on both a project-based and common library level, while addressing the need to package up source code for a given project to deliver to a team member or client. I've used version control before, as well as doing the common classpath thing for shared classes... but when it's time to deliver the source code to someone, I would have to go in and hunt for all the classes I used on a project and copy them to the FLA directory (and recreate the com.package... structure as well). Sometimes it seems faster to simply create the AS files along with the FLA (in a single package), and copy over utility files as needed. But then you get into duplicate classes scattered over multiple projects. Can anyone provide any insight to a system that works well for them? For example, does anyone run custom shell scripts (such as rsync) that sync the current project with the main classpath directory? Thanks, -Danro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Delegating Events and AS2
Whoops! -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: Tuesday, September 26, 2006 2:23 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Delegating Events and AS2 [...] Or, if using AS3.0, I think you can wrap a flash.events.EventDispatcher object (Decorator Design Pattern): [...] private function _dispatcher:EventDispatcher; } Obviously, that should be: private var _dispatcher:EventDispatcher; ― Mike Keesey (Note: I haven't actually tried AS3.0, so someone let me know if I messed anything up.) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Sean Scott Sent: Tuesday, September 26, 2006 12:09 PM To: Flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Delegating Events and AS2 Hi All!, wondering if someone can point me in the right direction. I am trying to find a ASBoradcast / Event Dispatcher light model for my app. Basically i have a number of MCs that will have to either react to events being broadcast or broadcast their own. I have Essential AS2 by Colin Moock. Trying to find something i can import and maybe pass scope to it, vs have my main class extend it. I've googled, searched the archived and exausted my more talented flash developer friends. Thanks, Sean ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Implicit Setters: Is validation considered a goodor bad OOP practice ?
This is generally the route I take. The only thing is that it may halt application flow in unforeseen circumstances, so 1) unit test and beta test really well and 2) try as much as possible to catch errors in code that sets the property. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of slangeberg Sent: Monday, September 25, 2006 8:46 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Implicit Setters: Is validation considered a goodor bad OOP practice ? so if it's a bad input, it cannot tell the object that is modifying the setter property that something went wrong. Not sure if it's the best practice, but if someone passes in a bad input to your setter, in AS3 you can throw errors, such as: public function set volume( val:Number ) { if ( val == bad_news ) { throw new Error( Volume Class - set volume(): Bad value passed in [ + val+ ] ); } } Scott On 9/25/06, Nicolas Cannasse [EMAIL PROTECTED] wrote: 3) Validate the value and it it's an undesired value, throw an error ? Here, the component prevents the user from assigning and undesired value like NaN or undefined and the user is alerted of the failure at runtime provided that he used a try catch statement. What do you guys think ? (3) definitly. It's called defensive programming. Try to have your API as much checked (type-wise and logical-wise) as possible. This will enforce your internal logic constraints and prevent faultly programs. For instance any other component of your application (an UI for example) will except your volume to be positive and not NaN so you cannot allow such values to be set. And you shouldn't ignore this error also since silently ignoring errors will make you and others lose hours of debugging when something goes wrong damn ! why this f... volume does not get set answer : because it's NaN Nicolas ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- : : ) Scott ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Mute Flash Application, mac.
I think you can control all of the sound in a Flash movie like so: var globalSound:Sound = new Sound(_root); // Mute. globalSound.setVolume(0); // Restore. globalSound.setVolume(100); ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Working on Flash 6 player but not on Flash 8
The earlier post (by Jake Prime) is probably the explanation. But also, random() is deprecated; instead of random(x), you should use Math.floor(Math.random() * x). ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Berkay Unal Sent: Thursday, September 21, 2006 8:04 AM To: [FlashCoders] Subject: [Flashcoders] Working on Flash 6 player but not on Flash 8 Hi Coders, Can someone please tell me whats the problem with this code . it's working on fl6 but not fl8 . Thanks Code: -- counter++; // hiding the first dot dot._visible = false; // particle generator // setting of the shape and velocity for each new dot this[dot+counter].gotoAndStop(shape); this[dot+counter].speedx = (random(speed*10)/10)-(random(speed*10)/10); this[dot+counter].speedy = (random(speed*10)/10)-(random(speed*10)/10); // FX scaling and fading for every dots for (i=counter; icounter-maxdot; i--) { this[dot+i]._x = this[dot+i]._x+this[dot+i].speedx+Math.cos((counter+i)/frequency)*am pl itude+forcex/friction; this[dot+i]._y = this[dot+i]._y+this[dot+i].speedy+Math.sin((counter+i)/frequency)*am pl itude+forcey/friction; //friction this[dot+i].speedx = this[dot+i].speedx/friction; this[dot+i].speedy = this[dot+(i)].speedy/friction; if (fxscale == true) { this[dot+i]._xscale = (maxdot-(counter-i))*(100/maxdot)*scale; this[dot+i]._yscale = (maxdot-(counter-i))*(100/maxdot)*scale; } else { this[dot+i]._xscale = 100*scale; this[dot+i]._yscale = 100*scale; } if (fxfade == true) { this[dot+i]._alpha = (maxdot-(counter-i))*(100/maxdot); } else { this[dot+i]._alpha = 100; } } // removing old dots if (counter=maxdot) { eleman = counter-maxdot; removeMovieClip(this[dot+eleman]); } // managing maxdots changes : destroying unused dots maxdotdif = maxdot-maxdot0; if (maxdotdif0) { for (i=counter-maxdot; i=counter-maxdot0-1; i--) { removeMovieClip(this[dot+i]); } } trace(a); maxdot0 = maxdot; -- Berkay UNAL [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Algorithm to find center of an irregular shape
Look into MovieClip.getBounds() and MovieClip.getRect(). For example, you could use: import flash.geom.Point; // ... function getCenter(shape:MovieClip):Point { var bounds:Object = shape.getBounds(this); var center:Point = new Point(); center.x = (bounds.xMax - bounds.xMin) / 2; center.y = (bounds.yMax - bounds.yMin) / 2; return center; } (Assuming that the scope of this function is a movie clip timeline or a subclass of MovieClip.) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of matt stuehler Sent: Thursday, September 21, 2006 9:58 AM To: Flashcoders mailing list Subject: [Flashcoders] Algorithm to find center of an irregular shape All, I'm not too handy with geometry, so I'm not even sure this is possible, but I'm looking for an algorithm that will determine the center of an irregular shape. I'm not even sure there is a meaningful definition of a center, but I'd like to at least find a point that is within the area of the shape. (I realize that with certain shapes, like a donut, this might be an intractible problem), so even some rough approximation would help. In this particular application, the shapes are the areas between the lines created when graphing several time series on a chart (e.g., the price of several stocks, graphed over time) Many thanks in advance for any advice or insights! Cheers, Matt Stuehler ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] HTTP post request in the background
onResponseComplete is probably being called before onMailDataResponseComplete (damn that's a long name! onMailComplete would suffice, no?), and thus unloading the whole SWF as it loads a new HTML page. Try moving this line: formData.sendAndLoad(http://www.salescloser.com/XMLAddContact.aspx;, response); ... to the very end of your processForm() function. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Bill Abel Sent: Thursday, September 21, 2006 10:20 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] HTTP post request in the background I'm still having one problem. When I test this movie from within Flash, it sends both LoadVars, but when I try it from the .swf on the web server, it only sends to the .php script. Anyone see the problem? import mx.utils.Delegate; function onResponseComplete(success:Boolean):Void { getURL(http://www.hallmanhill.com/information/thankyou.html;); trace(posted data); } function onMailDataResponseComplete(success:Boolean):Void { trace(sent email); } function processForm() { var response = new LoadVars(); var formData:LoadVars = new LoadVars(); formData.firstname = firstname_tb.text; formData.lastname = lastname_tb.text; formData.address = address_tb.text; formData.city = city_tb.text; formData.state = state_tb.text; formData.zip = zip_tb.text; formData.homephone1 = areacode; formData.homephone2 = prefix; formData.homephone3 = linenumber; formData.email = email_tb.text; response.onLoad = Delegate.create(this, onResponseComplete); formData.sendAndLoad(http://www.salescloser.com/ XMLAddContact.aspx, response); trace(formData); var mailData = new LoadVars(); var mailDataResponse = new LoadVars(); mailData = formData; mailDataResponse.onLoad = Delegate.create(this, onMailDataResponseComplete); mailData.sendAndLoad(http://test.slaughtergroup.com/mail.php;, mailDataResponse, POST); trace(mailData); } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] HTTP post request in the background
Actually, scratch that -- move the whole formData deal to its own function, and call that from onMailComplete(). IOW, do the calls sequentially, not simultaneously. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: Thursday, September 21, 2006 11:07 AM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] HTTP post request in the background onResponseComplete is probably being called before onMailDataResponseComplete (damn that's a long name! onMailComplete would suffice, no?), and thus unloading the whole SWF as it loads a new HTML page. Try moving this line: formData.sendAndLoad(http://www.salescloser.com/XMLAddContact.aspx;, response); ... to the very end of your processForm() function. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Bill Abel Sent: Thursday, September 21, 2006 10:20 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] HTTP post request in the background I'm still having one problem. When I test this movie from within Flash, it sends both LoadVars, but when I try it from the .swf on the web server, it only sends to the .php script. Anyone see the problem? import mx.utils.Delegate; function onResponseComplete(success:Boolean):Void { getURL(http://www.hallmanhill.com/information/thankyou.html;); trace(posted data); } function onMailDataResponseComplete(success:Boolean):Void { trace(sent email); } function processForm() { var response = new LoadVars(); var formData:LoadVars = new LoadVars(); formData.firstname = firstname_tb.text; formData.lastname = lastname_tb.text; formData.address = address_tb.text; formData.city = city_tb.text; formData.state = state_tb.text; formData.zip = zip_tb.text; formData.homephone1 = areacode; formData.homephone2 = prefix; formData.homephone3 = linenumber; formData.email = email_tb.text; response.onLoad = Delegate.create(this, onResponseComplete); formData.sendAndLoad(http://www.salescloser.com/ XMLAddContact.aspx, response); trace(formData); var mailData = new LoadVars(); var mailDataResponse = new LoadVars(); mailData = formData; mailDataResponse.onLoad = Delegate.create(this, onMailDataResponseComplete); mailData.sendAndLoad(http://test.slaughtergroup.com/mail.php;, mailDataResponse, POST); trace(mailData); } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Working on Flash 6 player but not on Flash 8
Well, random() has two meanings then, and the Math.random() function is more generally useful than random() (for example, if you need a random floating-point number). That said, I'd love a Math.randomInt() function. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Thursday, September 21, 2006 12:22 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] Working on Flash 6 player but not on Flash 8 instead of random(x), you should use Math.floor(Math.random() * x). Which makes me wonder why random() is deprecated. They really think that Math.floor(Math.random() * x) is better than random()? Ridiculous! The sign of a great API is its simplicity. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] HTTP post request in the background
You should use something along these lines: import mx.utils.Delegate; function onResponseComplete(success:Boolean):Void { // Do something in response. } var request:LoadVars = new LoadVars(); // Set up variables in request. var response = new LoadVars(); response.onLoad = Delegate.create(this, onResponseComplete); request.sendAndLoad(url, response); ― Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Find item in array
My guess would be that postincrement it takes longer because it needs to store and return the original value, while preincrement only needs to return the result after performing the operation. But that's only a guess. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Tuesday, September 19, 2006 1:45 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Find item in array As to why exactly --i -(-1) runs faster in a while loop than i--, well, it can't be the same exact pcode or it wouldn't be faster so it must be less pcode. I didn't bother to verify it myself because at the time, somebody did for me. It's explained somewhere in the archives. If you dig, you'll find it, and you'll find my name somewhere in there along with it since I was part of the discussion on most occasions that it came up. I do like mustard, now, by the way. :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Associate clip with class
One technique I've been trying lately is to assert linkage of class names. First I create a static function that asserts that a symbol is linked to a certain class. It returns the symbol ID if so, and throws an error if not: class com.exopolis.exosite.errors.SymbolError extends Error { //... public static function assertRegistered(linkageID:String, classFunc:Function, className:String):String { if (!Object.registerClass(linkageID, classFunc)) { throw new SymbolError(linkageID, className); } return linkageID; } } Then in any MovieClip subclass, I can do something like this: import com.exopolis.exosite.errors.SymbolError; class mypackage.MyComponent extends MovieClip { //... public static var LINKAGE_ID:String = SymbolError.assertRegistered(MyComponent, MyComponent, MyComponent); } That way, the symbol is automatically registered to the class, and if there is no such symbol, an error is thrown (which does not disrupt any other processes). -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] specifying type of an array contents?
One technique I often use is to create the array as a private member of a class and guard it against including invalid classes. For example: import mypackage.Item; class mypackage.ItemList extends Object { public function ItemList() { super(); _items = new Array(); } public function get itemCount():Number { return _items.length; } public function addItem(item:Item):Void { if (!(item instanceof Item)) { throw new Error(Invalid item: + item); } _items.push(item); } public function getItem(index:Number):Item { var item:Item = Item(_items[index]); return (item == undefined) ? null : item; } public function removeItem(item:Item):Void { for (var i:Number = _items.length; i 0; --i) { if (_items[i - 1] == item) { _items.splice(i - 1, 1); } } } public function removeItemAt(index:Number):Void { _items.splice(index, 1); } public function toString():String { return [type ItemList(items= + _items.join(, ) + )] ; } private var _items; } It is cumbersome to do this for all types, but it's handy for many occasions. (I do really miss C++ templates, though) ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of dc Sent: Saturday, September 16, 2006 7:36 PM To: Flashcoders mailing list Subject: [Flashcoders] specifying type of an array contents? is there a way to tell flash what types an array contains? eg given this: var btnClipArray:Array; --- later: for (var btn in btnClipArray) { btn.removeMovieClip(); } flash defaults to thiking the array contains only strings, so the movieclip methods throw a compile error. of course, i can cast or otherwise hack, but it would be nice not to... var btnClipArray:Array:MovieClip; ? /dc --- David DC Collier mailto:[EMAIL PROTECTED] +81 (0)80 6521 9559 skype: callto://d3ntaku --- Pikkle 株式会社 http://www.pikkle.com --- ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] htmlText javascript link being ignored in Safari
I can think of a reason: SAFARI SUCKS!!! Sorry, I can't be more helpful; just had to get that out there. ;) Okay, I'll try to be a little helpful--have you tried putting an alert() call in your JS function to see if Safari's calling it at all? Or, better yet, try calling the function from an HTML link (a href=# onclick=openVidPlayer...). This may help narrow down where the failure is occuring. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Marlon Harrison Sent: Monday, September 18, 2006 2:36 PM To: Flashcoders mailing list Subject: [Flashcoders] htmlText javascript link being ignored in Safari I have a dynamic text field where I create an html link based on a couple of pieces of data. Here's an example of the code for the link: var aTag:String = p class = 'landing'a href=\javascript:openVidPlayer('/vidplayer.html?video=+sel.v_id+cate go ry=+sel.cat+');\ target = '_parent'+sel.ttl+/a/p; My problem is that the popup works fine in Windows IE, Mac/Win Firefox just fine. It won't work in Safari. It shows as link, but when you click, nothing happens. Can anyone think of a reason why this wouldn't work? ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3 : chr() == String.fromCharCode()?
Sorry, yes, String.fromCharCode() replaced chr() a while ago. *checks* Yes, since Flash 5. Check the Deprecated section in the ActionScript side panel. Functions like chr() and ord() were in Flash 4, back before ActionScript (or was it just called Actions back then?) followed ECMA standards. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of julien castelain Sent: Friday, September 15, 2006 1:17 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] AS3 : chr() == String.fromCharCode()? ok mike, so what :) i read that in the docs too. however you still didn't reply to the question take it easy ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3 : chr() == String.fromCharCode()?
Not to be too harsh, but that's been deprecated since, what, Flash 5? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of julien castelain Sent: Wednesday, September 13, 2006 10:45 PM To: flashcoders list Subject: [Flashcoders] AS3 : chr() == String.fromCharCode()? hi list, i saw in the AS2 to AS3 migration guide ( http://livedocs.macromedia.com/flex/2/langref/migration.html) that chr() has been removed ... is String.fromCharCode() the way to do things now? thanks ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] does actionscript have something like sql's IN orLIKE ?
Why not just: public static function contains(str:String, val:String):Boolean { return str.indexOf(val) = 0; } ? A tad more concise (you don't need the ? true : false part), and avoids the problem your function has that if str is null or undefined, it returns true. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Jim Kremens Sent: Tuesday, September 12, 2006 11:25 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] does actionscript have something like sql's IN orLIKE ? Hi, Try this for checking if one string contains another: public static function contains(str:String, val:String):Boolean { return str.indexOf(val) != -1 ? true : false; } Also, try to avoid attaching your functions directly to buttons, as it makes scoping tricky: this.opened_btn.onRelease=function(){ Check out the Proxy class here for a better way to handle that: http://www.person13.com/articles/proxy/Proxy.htm Hope that helps, Jim Kremens ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] classes vs external .as files
Far more errors can be caught compile-time using classes than using timeline script. Rather than finding out halfway into a project that you've mistyped a variable's name in several places, you find out the first time you try to compile. Classes also make for easier unit testing. I think it's generally better to extend the MovieClip class and register the symbol to the class than to create classes that refer to movie clips and assign them via timeline code. The latter approach faces more problems when the movie structure changes. In some ways it's also good to keep in line with what Adobe is doing. Are they making classes? Yes. Are they making scripts to be included from the timeline? No. There is only one instance where I currently use an included timeline script instead of a class, and that is for SWFObject's expressinstall.as, which needs to work in Flash Player 6r65. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Meinte van't Kruis Sent: Monday, September 11, 2006 1:33 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] classes vs external .as files it's more of a taste thing i guess, and this question kinda revolves around 'oop vs procedural' etc. These discussions have been 'waged' alot of times, and often result in language religion wars ;) Personally, if code is readable and makes sense, it's allright by me. Meinte On 9/11/06, Adrian Ionut Beschea [EMAIL PROTECTED] wrote: Hello, I've just had a debate with a colleague of mine about the some of the as 2.0 best practice. We both like to separate design from code, but we have slightly different ways of doing it. This is what he does : He leaves design elements on stage and includes and external .as file to handle the logic. #include 'script.as' I like to think in terms of oop. So instead of including a script, I write something use: SampleClass.main(this) main is something like this : public static function main(target_mc:MovieClip) { instance = new SampleClass(target_mc); } What do you guys think ? Which method is more of your taste and why ? - How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] XML id attribute shortcut not working?
No prob! You could also use the associative array syntax: _xml[idMap][myID] Altering the class is more elegant (and something Macromedia should have done in the first place, of course), but if someone else has to compile it, you may want to use the associative array cheat and mark it with a KLUDGE comment. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Rifled Cloaca Sent: Thursday, September 07, 2006 3:59 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] XML id attribute shortcut not working? All, It seems to be due to a bug in the base XML class definition. If you want to use idMap in Flash 8, you'll need to edit your XML.as class to add the attrib. Thanks again! On 9/7/06, Rifled Cloaca [EMAIL PROTECTED] wrote: Thanks, It works by itself, but if I try to use it in a class with an XML object in it, I get: There is no property with the name 'idMap'. It's defined as type XML. What's up? Thanks! On 9/7/06, Mike Keesey [EMAIL PROTECTED] wrote: Use the XML.idMap property. ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Rifled Cloaca Sent: Thursday, September 07, 2006 3:27 PM To: Flashcoders mailing list Subject: [Flashcoders] XML id attribute shortcut not working? All, I have a large XML document with unique ID attributes that I'd like to access via the ID shortcut, like so: trace(myXML[3]); returns: myxmlnode id=3... It works fine when I publish to Flash 6, but publishing to anything greater returns undefined. Any thoughts? Thanks in advance! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] weird class could not be loaded.
What's the path? Is the class name actually myClass? ― Mike Keesey -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Christian Pugliese Sent: Tuesday, September 05, 2006 2:31 PM To: Flashcoders mailing list Subject: [Flashcoders] weird class could not be loaded. Ok, this is driving me nuts... Everything is working and ok: path, declaration, the fla compiles alright... but when i check the syntax on the .as where i'm importing the class, i get the following error: - The class or interface 'myClass' could not be loaded. again, the classpath and declaration is ok... anybody already got something like this?? is this a bug? is this an ufo? cheers ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Singleton not always Singleton?
Boy, is my face red! But I have seen bad package-naming conventions used before, so hopefully the post wasn't completely useless for eveyone out there. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adrian Park Sent: Sunday, August 27, 2006 4:34 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Singleton not always Singleton? It *is* for Shell Petroleum :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Singleton not always Singleton?
PET PEEVE ALERT class com.shell.util.IntroAnimProxy Unless you are actually doing Shell Petroleum's website at http://shell.com, this isn't a proper name for the package. The com convention is a strategy to keep package paths from overlapping on different projects: if you're doing a website, you take the domain and reverse it--voila, you have a path that nobody else will ever use, and you don't ever have to worry about conflicts. (Assuming everyone sticks by the convention, of course.) I've even seen people make classes like com.MyClass, as if com stood for component or something. (It stands for commercial.) If you're not working on a website project, then you have a couple of options: 1) Make a new package for the project in your own domain's package. (e.g., net.mywebsite.mynewproject) or your client's domain package. Even if it's not going on the web, you can still guarantee it won't conflict with any other packages. 2) Make a package that doesn't start with any top-level domain strings (com, org, net, country codes, etc.) I'll own that in this instance you'll only really have a problem if, some day, you *do* work on http://shell.com, but still (And if this *is* for Shell Petroleum, then I'll shut up now.) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrés González Aragón Sent: Friday, August 25, 2006 9:29 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Singleton not always Singleton? The problem i can see is tha in the singleton pattern constructor must be private. May be triin with something like this : class com.shell.util.IntroAnimProxy { private static var _instance:IntroAnimProxy; public static function get instance():IntroAnimProxy { if( _instance == null ) _instance = new IntroAnimProxy(); return _instance; } private function IntroAnimProxy() { trace(IntroAnimProxy); } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flash/Actionscript Coding conventions
It ends when you make your own damn third-party tools! ;) Seriously, though, I don't find that I have to comment out huge swaths of class functions at a time very often. Even if I did have to comment out several functions, they might not be next to each other, anyway. And, as I said before, commenting out a single function is *easier* when each one is preceded by a block comment--one keystroke of backspace or delete (unless it's the very last function). Finally, nothing about Javadoc precludes you from using block comments inside function bodies. Have you actually tried Javadoc or is this dislike preemptive? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Thursday, August 24, 2006 9:58 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Flash/Actionscript Coding conventions So you're saying I need to use a third party tool to overcome an issue created by another third party tool? Where does it end? WHERE...DOES...IT...END? :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] retrieving vars using query string
You can just set your FlashVars on the first frame on the main timeline. (And make sure you delete them when done testing.) I don't know of a better way. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Thursday, August 24, 2006 4:07 PM To: Flashcoders mailing list Subject: [Flashcoders] retrieving vars using query string Hi All, I'm using the BrowserStateManager class to set the state of my app using parameters in the query string. this makes it very hard to debug however, so i was wondering how i can still pass vars to the app even though i'm i'm not running the app in a browser as i debug it (debugging using the dredded debugger that comes with flash)... any ideas appreciated cheers b ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] UML Diagrams
Just curious, What do people on this use to create UML diagrams? Do you use a WYSIWYG diagram-creating tool (preferrably which can output skeletal AS class code)? Or do you use something that scans preexisting AS classes and generates UML diagrams (or a UML-related XML format, like UXF). I've experimented with a few such programs. I'd really like to find something (or a combo solution) that can work both ways. -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Protect model setters from being called by any classexcept Controller
In AS3.0 I think it can be package-private, but until then One way is to have the Model class satisfy an interface that lacks the property (of course, in AS2.0, all interfaces lack properties...), and then only expose the model class as the interface elsewhere. interface IModel { function anybodyCanUseThis():Void; } class Model extends Object implements IModel { public function Model() { super(); } public function get prop():Object { return _prop; } public function set prop(p:Object):Void { _prop = p; } public function anybodyCanUseThis():Void { trace(anybodyCanUseThis()); } private var _prop:Object; } class Control extends Object { public function Control() { super(); _model = new Model(); } public function get model():IModel { return _model; } private function doSomethingWithModel():Void { _model.prop = Here we can access the property.; } private var _model:Model; } class SomeOtherClass extends Object { public function SomeOtherClass() { super(); _control = new Control(); _control.model.anybodyCanUseThis(); _control.model.prop = This line will cause a compiler error.; } private var _control:Control; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Thursday, August 24, 2006 6:37 PM To: Flashcoders mailing list Subject: [Flashcoders] Protect model setters from being called by any classexcept Controller Hi, I have a model class that has a bunch of getters and setters. Example: private var _prop:Object; function get prop():Object { return _prop; } function set prop(p:Object) { _prop = p; } I have a controller class that instantiates that model. I'm wondering if there is some way to prevent any other class from using the setter methods of the model except the controller class. They still should be able to access the getters. I want to prevent future developers from being able to access the model setters from anywhere except the controller in order to enforce proper MVC patterns. Thanks! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Protect model setters from being called by anyclassexcept Controller
Wait--that doesn't expose the getters. H... Okay, substitute the interface with a superclass (say, AbstractModel) that has the getters, but not the setters. Then expose the Model object as AbstractModel everywhere except inside the Control class. I've never tried that, but I think it should work. A bit weird, though. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Keesey Sent: Thursday, August 24, 2006 6:46 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Protect model setters from being called by anyclassexcept Controller In AS3.0 I think it can be package-private, but until then One way is to have the Model class satisfy an interface that lacks the property (of course, in AS2.0, all interfaces lack properties...), and then only expose the model class as the interface elsewhere. interface IModel { function anybodyCanUseThis():Void; } class Model extends Object implements IModel { public function Model() { super(); } public function get prop():Object { return _prop; } public function set prop(p:Object):Void { _prop = p; } public function anybodyCanUseThis():Void { trace(anybodyCanUseThis()); } private var _prop:Object; } class Control extends Object { public function Control() { super(); _model = new Model(); } public function get model():IModel { return _model; } private function doSomethingWithModel():Void { _model.prop = Here we can access the property.; } private var _model:Model; } class SomeOtherClass extends Object { public function SomeOtherClass() { super(); _control = new Control(); _control.model.anybodyCanUseThis(); _control.model.prop = This line will cause a compiler error.; } private var _control:Control; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Thursday, August 24, 2006 6:37 PM To: Flashcoders mailing list Subject: [Flashcoders] Protect model setters from being called by any classexcept Controller Hi, I have a model class that has a bunch of getters and setters. Example: private var _prop:Object; function get prop():Object { return _prop; } function set prop(p:Object) { _prop = p; } I have a controller class that instantiates that model. I'm wondering if there is some way to prevent any other class from using the setter methods of the model except the controller class. They still should be able to access the getters. I want to prevent future developers from being able to access the model setters from anywhere except the controller in order to enforce proper MVC patterns. Thanks! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Dynamically Upcast to a class in the _global tree?
What would be the point of that? The only point of upcasting is to have things compile with strict typing, and the compiler can't tell what the class is if it's dynamically determined. Are you talking about dynamic *instantiation*? Then you could use something like this: // Import all classes that may be needed. import mygroup.mypackage.mysubpackage.MyClass; // Set up variables. var packagePath:String = mygroup.mypackage.mysubpackage; var className:String = MyClass; // Get the class' constructor function. var classFunc:Function = getClass(packagePath, className); // Instantiate a test object. var test:Object = new classFunc(); // Test the instantiation; should output result of MyClass.toString(). trace(test); /** * Returns a class' constructor function, given the package path * and the class' name. * * pClasses must be imported or they will not be found. * * @param packagePath path of the package, e.g. [EMAIL PROTECTED] flash.geom} * @param className name of the class, e.g. [EMAIL PROTECTED] Point} * @return constructor function, or [EMAIL PROTECTED] undefined} */ function getClass(packagePath:String, className:String):Function { var package:Object = getPackage(packagePath); return package[className]; } /** * Returns a class package, given its path. * * @param packagePath path of the package, e.g. [EMAIL PROTECTED] flash.geom} * @return class package ([EMAIL PROTECTED] Object} instance), or * [EMAIL PROTECTED] undefined} * @see#getClass */ function getPackage(path:String):Object { var package:Object = _global; var pathArray:Array = path.split(.); for (var i:Number = 0; i pathArray.length; ++i) { package = package[pathArray[i]]; } return package; } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of aaron smith Sent: Wednesday, August 23, 2006 8:27 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Dynamically Upcast to a class in the _global tree? no that is just the usual way of doing it.. I need to be able to dynamically upcast.. like: vart = new _global['somepackage']['someClass'](); something like that.. i can't remeber how to do that.. with prototypes or _global.. On 8/23/06, Hans Wichman [EMAIL PROTECTED] wrote: Hi, not sure if this is what you mean but: import com.somepackage.HomeView; var bv:BasicView = getSomeBasicView(); var newHomeViewHomeView =HomeView( bv ); grtz JC On 8/23/06, aaron smith [EMAIL PROTECTED] wrote: How do I cast to something that is in the _global tree. by that i mean. cast referencing like this: _global.com.somepackage.SomeClass( var ) or is the _prototype chain? I can't remember... the situation is this, I have a BasicView class. that needs to dynamically be upcast to other views that would potentially extend it, say a HomeView that extends BasicView.. say like this: var bv:BasicView = getSomeBasicView(); var newHomeView:_global.com.somepackage.HomeView = _global.com.somepackage.HomeView( bv ); I'm pretty sure it's possible, don't remember how to do it... thanks.. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flash/Actionscript Coding conventions
Putting a block comment before a function is standard, though (Javadoc). Putting one *inside* a function is awful, though, I agree. /** * This is a perfectly fine Javadoc comment * * @param bar some parameter */ public function foo(bar:Object):Void { /* Using a block comment here is totally bogus. */ // Line comments, though, are great! } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Wednesday, August 23, 2006 10:21 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Flash/Actionscript Coding conventions I have an issue with coders who put block comments in the middle of their code, such as: /*** ** SOME COMMENTS **/ function foo() { trace(hello world); } Or even worse: /*** ** SOME COMMENTS **/ function foo() { /* some comments inside the code */ trace(hello world); } People who comment like that are my bane and here is why. Commenting like that in your code makes it completely impossible to easily and completely comment out blocks of code using /* */ because they have their */ inside their comments. Believe it or not, this is a very important tool in debugging. So, please do everyone a favor and only use block comments before and after your code and use line comments // for all comments inside your code. :) Thanks, Steven ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flash/Actionscript Coding conventions
-Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Wednesday, August 23, 2006 11:19 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Flash/Actionscript Coding conventions Putting a block comment before a function is standard All standards are is somebody's way of saying I code like this and so should you. Fair enough; it is *a* standard. But it is widely used, informative, and, perhaps most importantly, there is software out there that can automatically generate documentation from it. And by the way, nobody reads those documents anyway. I do. It's far easier to read one sentence of English than scan ten lines of cryptic code. // // This is much better commenting // It's easier to read than all those asterisks // IMNSHO / Oh I used about 6 asterisks in my example. I don't like huge lines of them, either. -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Flash/Actionscript Coding conventions
So you never look at the Flash help code? You just open the .as files and trawl through them? And to the point about Javadoc, I'm not going to ruin my code and handicap my debugging ability to satisfy some poorly thought out requirement of a 3rd party tool. They require you to use block commenting in your code to automatically write documentation and that's counterproductive to actual coding. It should work hand in hand with not diametrically opposed to the coding process. If they were smart about it, they would support line commenting with non-asterisk delimiters. Say //! !//, or //| |// or //[ ]//, etc. Exclamations, pipes, and brackets are all better choices because they do not conflict with anything. I am totally confused by your raging asteriskism. What do asterisks conflict with that those do not? What's wrong with asterisks? I actually like having block comments before functions because it makes it ridiculously easy to comment out a function. Just remove the last / (assuming there's a block comment after the function as well; if not you have to add a */). Makes it very easy to do Move Method refactorings and suchlike. I'm not going to make my process suffer nor am I going to litter my code with ugly asterisks just to document my work when I can spend that energy writing cleaner, easier to read code with light commenting in the code itself. :) I still don't understand how Javadoc makes your process suffer. -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] vars with $
I have seen others do it, or mark parameters with a p_. I prefer not to mark parameters in any special way. I mark private variables with _, so those are already distinct. And if I have a function that's so long that I can't see the top from somewhere in the body, it's well past time to cut it down into more manageable chunks. Plus, using $ makes it more confusing when switching between PHP or Perl (or another language that uses $ to mark all variables) and ActionScript. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Lee Sent: Friday, August 18, 2006 1:38 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] vars with $ I've used it to indicate arguments in a function to clarify the origin of the variable, like this: function myFunc($arg1,$arg2){ trace($arg1+ : +$arg2); } I don't know where I picked that up, but for me it makes the code easier to read since you know immediately they are arguments. I've seen people use the underscore for the same purpose, but that can confuse things since ActionScript uses that for some native properties (_x,_y). Does anyone else do this, or am I just in my own little universe? ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] init TextFormat prop in a class
Quoting Mendelsohn, Michael [EMAIL PROTECTED]: Hi list... Why is it that when I try to init a prop for my class, I get this error: A class's instance variables may only be initialized to compile-time constant expressions. What exactly does that mean? class test{ private var tf:TextFormat = new TextFormat(); function test(){ trace(hello); } } new TextFormat() is not a constant expression, like null or 3 or Math.PI or 2 * Math.PI or 'string text'. Each time you use those expressions it evaluates to the same value, but each time you use new TextFormat() it creates a new object. You have to instantiate nonconstant fields in the constructor: class Test { private var _tf:TextFormat; public function Test(){ super(); _tf = new TextFormat(); trace(hello); } } (The super(); is not strictly necessary; I'm just anal.) -- Mike Keesey ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com