[Flashcoders] Basic idea to use xml in flash
Hello All members hope you are fine. I have a problem that I am novice in the world of flash but not so much but I think that you are all too much seniors from me in flash knowledge I want too much from flash please guide me and tell me a better way to have a nice grip on actionscripting, I'll be grateful to all of you. God bless you all. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Re: Newbie AS3 question
yes, this is true in ActionScript referencing or instantiating a singleton class via a static getInstance method, is a different matter to all methods of a class being static The former is calling an instance method and the latter is calling a static method. Instance methods have access to instance data that is persisted as long as the instance exists, static methods have access only to static data and that data passed in to the method call. Is this not true in ActionScript? Important - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education Training. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] setInterval() and the trouble
I imagine you're calling clearInterval with the appropriate interval ID upon each quiz question submittal, and then afterwards recalling setInterval for the new question? How does it fail the second time? Does it just never call it again, or does it call the function at a different interval? Liam On 10/29/05, Weyert de Boer [EMAIL PROTECTED] wrote: Hmm, I am currently working on the good version of the quiz only I have a question how I should implementate some part. The quiz should ask yes/no questions and the user should only have three to six seconds to answer the question. If the user fails to answer the question within this time, the answer should be fault. Currently I used a setInterval() with 3000ms only I never get stuff with intervals right. Always it goes all fine the first question, but the second it fals. Does anyone know a good way to implementate this? Maybe through event delegation instead of a interval callback method? Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Re: Newbie AS3 question
No need to get hyper about this. The matter stays that this used to be essential in AS1, thus probably why people still like to implicate him in their code. But I agree that putting this in an AS2 Class should be used only when necessary. You do know that it (this.) is being added for you at compile time in AS2, right? Who cares? All that means is that there is no semantic difference between the two. There is a difference for AS3 ! (and this is the correct behaviour) http://livedocs.macromedia.com/labs/1/flex/langref/statements.html#this To call a function defined in a dynamic class, you must use this to invoke the function in the proper scope zwetan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] How to make a doughnut?
After putting a couple of hours on the problem, I am still in a daze on how would one go about making a doughnut shape (circle with cut-out in the center) using the drawing API. I'm not talking about drawing a circle using: lineStyle(BIGNUMBERHERE, color, alpha); I'd like to put in a gradient fill into a doughnut shape. And it has to be a doughnut, not a simulation of it (ie. not by drawing 2 circles over each other and keeping the center cirlce the same as the background color). Real dunkin' doughnut! Any ideas? Thanks for your time. Regards, Navneet ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to make a doughnut?
Here's one I just made (and tested) from a draw circle prototype that then draws another circle in reverse (before the endfill is applied -- necessary to get a cutout): // r1 = radius of outer circle // r2 = radius of inner circle (cutout) // x, y = center of donut MovieClip.prototype.drawDonut = function (r1, r2, x, y) { var TO_RADIANS:Number = Math.PI/180; this.moveTo(0, 0); this.lineTo(r1, 0); // draw the 30-degree segments var a:Number = 0.268; // tan(15) for (var i=0; i 12; i++) { var endx = r1*Math.cos((i+1)*30*TO_RADIANS); var endy = r1*Math.sin((i+1)*30*TO_RADIANS); var ax = endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS); var ay = endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS); this.curveTo(ax, ay, endx, endy); } // cut out middle (go in reverse) this.moveTo(0, 0); this.lineTo(r2, 0); for (var i=12; i 0; i--) { var endx = r2*Math.cos((i-1)*30*TO_RADIANS); var endy = r2*Math.sin((i-1)*30*TO_RADIANS); var ax = endx+r2*(0-a)*Math.cos(((i-1)*30-90)*TO_RADIANS); var ay = endy+r2*(0-a)*Math.sin(((i-1)*30-90)*TO_RADIANS); this.curveTo(ax, ay, endx, endy); } this._x = x; this._y = y; } // example usage: createEmptyMovieClip(d, 1); d.beginFill(0xaa, 60); d.drawDonut(100, 50, 200, 200); d.endFill(); Helen Navneet Behal wrote: After putting a couple of hours on the problem, I am still in a daze on how would one go about making a doughnut shape (circle with cut-out in the center) using the drawing API. I'm not talking about drawing a circle using: lineStyle(BIGNUMBERHERE, color, alpha); I'd like to put in a gradient fill into a doughnut shape. And it has to be a doughnut, not a simulation of it (ie. not by drawing 2 circles over each other and keeping the center cirlce the same as the background color). Real dunkin' doughnut! Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Re: Newbie AS3 question
In the book of C.Moock, he recommends the redundant use of [this] Sorry, I'm a newbie too but it seems to be a good practice to specify clearly the scope you refer to. It's clearly specified in chapter 6 to be aware about the scope. Essential ActionScript 2.0 O'Reilly Media, Inc, 2004, ISBN 0-596-00652-7 Greetings N -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zwetan Sent: samedi 29 octobre 2005 15:03 To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Re: Newbie AS3 question No need to get hyper about this. The matter stays that this used to be essential in AS1, thus probably why people still like to implicate him in their code. But I agree that putting this in an AS2 Class should be used only when necessary. You do know that it (this.) is being added for you at compile time in AS2, right? Who cares? All that means is that there is no semantic difference between the two. There is a difference for AS3 ! (and this is the correct behaviour) http://livedocs.macromedia.com/labs/1/flex/langref/statements.html#this To call a function defined in a dynamic class, you must use this to invoke the function in the proper scope zwetan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
As the coffee kicks in, that also looks like Composition, not Singleton. Like, you have a Singleton class instantiating instances and returning them of other classes from within itself. - Original Message - From: JesterXL [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 10:19 AM Subject: Re: [Flashcoders] Newbie AS3 question It does a little. Why can't can't you just extend the base CurrencyFormatter class and do the same thing for the formatValue function? Rather than return the correct one for getInstance(), just utilize the particular format class you want? Like, do: var val = UKCurrencyFormatter.getFormat(); and: var val = USCurrencyFormatter.getFormat(); ? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 10:31 PM Subject: Re: [Flashcoders] Newbie AS3 question Sure, Here's a slightly more complete implementation of that last example: public class CurrencyFormatter { private static formatter:CurrencyFormatter; public function getInstance():CurrencyFormatter { // use ExternalInterface or IP lookup or whatever to determine locale if (locale == UK) { formatter = new UKCurrencyFormatter(); } else { formatter = new USCurrencyFormatter(); } return formatter; } class USCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return $ + String(val); } } class UKCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return £ + String(val); } } } Let me know if that explains it a bit better. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: Can you elaborate? Why wouldn't the static class work in that case? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:54 PM Subject: Re: [Flashcoders] Newbie AS3 question ok, That's just a static class. Like I said, there's a subtle but important difference between singleton and a static class. Here's another example. You have a requirement to provide a currency formatter. One way to do this is to create a singleton that returns a different currency formatter depending on which locale you are in. So in the class you would have something like this (Omitting method declarations for simplicty): public class CurrencyFormatter { class USCurrencyFormatter extends CurrencyFormatter { } class UKCurrencyFormatter extends CurrencyFormatter { } } Now if I call CurrencyFormatter.getInstance() it gives me the correct formatter for my locale. With your static class approach you have to check in every method what the locale is and handle it accordingly. That's fine for one or two locales, but if you want to handle 20, it gets pretty ugly. You can solve the problem in other ways of course, but it does demonstrate the difference between static classes and the singleton pattern. The singleton pattern offers you a lot more possibilities. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: To clarify: class ServerConnection { private static var url; private static var port; private static var socket; public static function connect(p_url, p_port) { url = p_url; port = p_port; socket = new Socket(); socket.connect(url, port); } public static function getData() { // Simple function that gets something from the server. } } Then to use: ServerConnection.connect(myURL, myPort); - Original Message - From: JesterXL [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:25 PM Subject: Re: [Flashcoders] Newbie AS3 question Naw, I don't know the exact way Singleton is implemented, hence my long battle with finding clarification. It could of been solved in 10 seconds over a beer, but email sux. I figured Math.abs was the Singleton pattern, and ARP, me, Sho, Steven Webster, and everyone else apparently has their own version of Controller as well. I figured I knew enough to use it. For instance, your example makes perfect sense and I can see why you'd want to do it that way. I, on the other hand would just put an if then statement in the connect method or whatever to ensure we're connected before making a method call, else throw an exception. Are they both the Singleton pattern? Does it matter? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 7:14 PM Subject: Re: [Flashcoders] Newbie AS3 question Hmmm From your explanation, I think either I don't understand what happens in AS, or you're misunderstanding the use of the singleton
RE: [Flashcoders] Basic idea to use xml in flash
Wassem - what is it in particular you want help with. The subject of your mail would suggest you need something to do with XML - is this correct ? Pete -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Waseem Shahzad Sent: 29 October 2005 11:24 To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Basic idea to use xml in flash Hello All members hope you are fine. I have a problem that I am novice in the world of flash but not so much but I think that you are all too much seniors from me in flash knowledge I want too much from flash please guide me and tell me a better way to have a nice grip on actionscripting, I'll be grateful to all of you. God bless you all. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] setInterval() and the trouble
At first glance it looks like you have a potential continuous loop issue? stopwatchComplete() questionComplete() stopwatchComplete() and so on if (id = questions.length) Second is I don't see where id is defined in questionComplete() did you mean to type this instead: if ( questionId = questions.length ) JOR ___ === James O'Reilly === === SynergyMedia, Inc. === www.synergymedia.net Weyert de Boer wrote: Hi Liam, First of all I always have had trouble with those methods, never got it right. Always failed, I don't they dont like! I imagine you're calling clearInterval with the appropriate interval ID upon each quiz question submittal, and then afterwards recalling setInterval for the new question? How does it fail the second time? Does it just never call it again, or does it call the function at a different interval? Well, I happen to have a resource xml file which get loaded prioer of each group of questions, once this group is readed a method in the root timeline gets triggered which will determine what to do. This method will also trigger the method buildQuestion() when required, this method will create a new instance of question-movieclip. After this part is done the function doStopwatch() is called: function doStopwatch() { // 1second = 1000ms _root.stopwatchIntervalId = setInterval( _root.stopwatchComplete, 3000 ); } function stopwatchComplete() { clearInterval( _root.stopwatchIntervalId ); // trigger the question completed method _root.questionComplete( _root.question.id, _root.question.type ); } function questionComplete( questionId, questionType ) { if ( id = questions.length ) { // out of questions _root.stopwatchComplete(); } else { // next quesiton buildQuestion( questionId + 1 ); } } IF you have a better solution please let me know! I feel so stupid that I don't get thing timer stuff working. Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
but using Composition and a Singleton arent mutually exclusive. Composition is a very broad style of OO architecture, used widely throughout a lot of patterns. You *might* call his example a Singleton Factory, but that probably confuses the issue as its not creating multiple instances of a concrete subclass, just creating one instance at runtime depending on particular external factors. I think his example is a good one, it keeps the dependency on locale knowledge safely contained in one place, and as Spike says, if you start moving up to 20 or so locales to support, you arent going to want to have a massive switch / if else statement everytime you want some locale dependent currency formatting. all the client code ever needs to do is ask the CurrencyFormatter for its instance and for that instance to format the number. martin JesterXL wrote: As the coffee kicks in, that also looks like Composition, not Singleton. Like, you have a Singleton class instantiating instances and returning them of other classes from within itself. - Original Message - From: JesterXL [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 10:19 AM Subject: Re: [Flashcoders] Newbie AS3 question It does a little. Why can't can't you just extend the base CurrencyFormatter class and do the same thing for the formatValue function? Rather than return the correct one for getInstance(), just utilize the particular format class you want? Like, do: var val = UKCurrencyFormatter.getFormat(); and: var val = USCurrencyFormatter.getFormat(); ? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 10:31 PM Subject: Re: [Flashcoders] Newbie AS3 question Sure, Here's a slightly more complete implementation of that last example: public class CurrencyFormatter { private static formatter:CurrencyFormatter; public function getInstance():CurrencyFormatter { // use ExternalInterface or IP lookup or whatever to determine locale if (locale == UK) { formatter = new UKCurrencyFormatter(); } else { formatter = new USCurrencyFormatter(); } return formatter; } class USCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return $ + String(val); } } class UKCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return £ + String(val); } } } Let me know if that explains it a bit better. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: Can you elaborate? Why wouldn't the static class work in that case? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:54 PM Subject: Re: [Flashcoders] Newbie AS3 question ok, That's just a static class. Like I said, there's a subtle but important difference between singleton and a static class. Here's another example. You have a requirement to provide a currency formatter. One way to do this is to create a singleton that returns a different currency formatter depending on which locale you are in. So in the class you would have something like this (Omitting method declarations for simplicty): public class CurrencyFormatter { class USCurrencyFormatter extends CurrencyFormatter { } class UKCurrencyFormatter extends CurrencyFormatter { } } Now if I call CurrencyFormatter.getInstance() it gives me the correct formatter for my locale. With your static class approach you have to check in every method what the locale is and handle it accordingly. That's fine for one or two locales, but if you want to handle 20, it gets pretty ugly. You can solve the problem in other ways of course, but it does demonstrate the difference between static classes and the singleton pattern. The singleton pattern offers you a lot more possibilities. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: To clarify: class ServerConnection { private static var url; private static var port; private static var socket; public static function connect(p_url, p_port) { url = p_url; port = p_port; socket = new Socket(); socket.connect(url, port); } public static function getData() { // Simple function that gets something from the server. } } Then to use: ServerConnection.connect(myURL, myPort); - Original Message - From: JesterXL [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:25 PM Subject: Re: [Flashcoders] Newbie AS3 question Naw, I don't know the exact way Singleton is implemented, hence my long battle with finding clarification. It could of been solved in 10 seconds over a beer, but email sux. I figured Math.abs was the Singleton pattern, and ARP, me, Sho, Steven Webster, and everyone else apparently has their own version of
Re: [Flashcoders] Newbie AS3 question
You're welcome! This has been an interesting thread and I've learned a bit more about ActionScript in the process :-) Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: That makes perfect sense and is a good reason. So, from this 2nd conversation, I've gleaned something else to add to the list: - getInstance() is a unspoken standard that implies the class is a Singleton used in other languages other than ActionScript - getInstance() treats a class as a true class without static properties, thus making it easier to go from Singleton to a true class without having to change a bunch of code, because all it really does is make 1, and only 1, instance of itself. The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:05 PM Subject: Re: [Flashcoders] Newbie AS3 question It's not necessarily any better from an implementation point of view. You can often do the same thing with a static class as you can with a singleton. The big benefit comes if you need to change from singleton/static to different instances for each invocation. If you have followed the static class approach you have static method calls all through your code that you will need to change if the class now needs to be non-static. If you have followed the singleton approach, you only need to change the line of code that retrieves the instance inside the singleton. That's a pretty big benefit IMO. To get back to where we started all this, the original statement that brought all this up was your suggestion that Foo.someMethod() was identical to Foo.getInstance().someMethod() Whether one is better than another is something that can be debated to death, and often is on Java mailing lists, but hopefully you'll at least agree that they are indeed doing different things. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: I would have 20 static classes, not 20 if/then/switch statements. You'd have that same if/then statement in the getInstance() function, though, to know which formatter to return. Again, I'm having a hard time seeing why getInstance is more appopriate than just making static classes, and how this applys to the Singleton pattern. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Stephen Milligan Do you do the Badger? http://www.yellowbadger.com Do you cfeclipse? http://www.cfeclipse.org ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Newbie AS3 question
I'm not picking any sides, The Idea of a getInstance method (Singleton), as you guys have been saying, is to have a static way to get a non-static instance of a class. Also, that way of working makes it easier for the creator of that class to know his class will only get instantiated once. There are other advantages like the presence of a constructor and probably many other things that you guys have also mentioned. All this to say absolutely nothing:) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JesterXL Sent: October 29, 2005 12:14 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question That makes perfect sense and is a good reason. So, from this 2nd conversation, I've gleaned something else to add to the list: - getInstance() is a unspoken standard that implies the class is a Singleton used in other languages other than ActionScript - getInstance() treats a class as a true class without static properties, thus making it easier to go from Singleton to a true class without having to change a bunch of code, because all it really does is make 1, and only 1, instance of itself. The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:05 PM Subject: Re: [Flashcoders] Newbie AS3 question It's not necessarily any better from an implementation point of view. You can often do the same thing with a static class as you can with a singleton. The big benefit comes if you need to change from singleton/static to different instances for each invocation. If you have followed the static class approach you have static method calls all through your code that you will need to change if the class now needs to be non-static. If you have followed the singleton approach, you only need to change the line of code that retrieves the instance inside the singleton. That's a pretty big benefit IMO. To get back to where we started all this, the original statement that brought all this up was your suggestion that Foo.someMethod() was identical to Foo.getInstance().someMethod() Whether one is better than another is something that can be debated to death, and often is on Java mailing lists, but hopefully you'll at least agree that they are indeed doing different things. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: I would have 20 static classes, not 20 if/then/switch statements. You'd have that same if/then statement in the getInstance() function, though, to know which formatter to return. Again, I'm having a hard time seeing why getInstance is more appopriate than just making static classes, and how this applys to the Singleton pattern. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] scrolling problem
Can someone help me with this code? I'm trying to figure out how to scroll an MC up and down based on the position of a scrollbar. What am I doing wrong with this code? I'm finding the ratio between how tall the content is (currentChild) and how tall the scrollbar is: scrollRatio = currentChild._height/scrollBar._height; Then changing the position of the content depending on where the scrollBar.slider is: currentChild._y = (scrollBar._height - scrollBar.slider._y)*scrollRatio; The result of this is the content is not visible until the scrollbar slider is most of the way down it's length, and then the content doesn't scroll far enough. As you can see I've currently got the slider clip as a child of the scrollBar clip - should I bring it out to the same level? Anyone got any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Newbie AS3 question
(*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spike Sent: October 29, 2005 12:25 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question You're welcome! This has been an interesting thread and I've learned a bit more about ActionScript in the process :-) Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: That makes perfect sense and is a good reason. So, from this 2nd conversation, I've gleaned something else to add to the list: - getInstance() is a unspoken standard that implies the class is a Singleton used in other languages other than ActionScript - getInstance() treats a class as a true class without static properties, thus making it easier to go from Singleton to a true class without having to change a bunch of code, because all it really does is make 1, and only 1, instance of itself. The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:05 PM Subject: Re: [Flashcoders] Newbie AS3 question It's not necessarily any better from an implementation point of view. You can often do the same thing with a static class as you can with a singleton. The big benefit comes if you need to change from singleton/static to different instances for each invocation. If you have followed the static class approach you have static method calls all through your code that you will need to change if the class now needs to be non-static. If you have followed the singleton approach, you only need to change the line of code that retrieves the instance inside the singleton. That's a pretty big benefit IMO. To get back to where we started all this, the original statement that brought all this up was your suggestion that Foo.someMethod() was identical to Foo.getInstance().someMethod() Whether one is better than another is something that can be debated to death, and often is on Java mailing lists, but hopefully you'll at least agree that they are indeed doing different things. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: I would have 20 static classes, not 20 if/then/switch statements. You'd have that same if/then statement in the getInstance() function, though, to know which formatter to return. Again, I'm having a hard time seeing why getInstance is more appopriate than just making static classes, and how this applys to the Singleton pattern. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Stephen Milligan Do you do the Badger? http://www.yellowbadger.com Do you cfeclipse? http://www.cfeclipse.org ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] scrolling problem
Frédéric v. Bochmann wrote: As you can see I've currently got the slider clip as a child of the scrollBar clip - should I bring it out to the same level? On that matter, I would say, look carefully at your line of code that follows: (scrollBar._height - scrollBar.slider._y) If the slider is scrolled higher than _y = 0 or that the slider goes lower than scrollBar._height your slider will influence the scrollBar._height value. This can be quite dangerous for weird acting script, but if your sure your slider won't ever influence it's containers height, your Ok. I have the slider being constrained by the startDrag function to be within the scrollBar clip at all times, so it should be ok. What I might suggest you would be to use the scrollBar.scrollTrack._height that might be existent or not in your scrollBar movieclip. Yes, it is, I'll try that. Now for your script, I don't usually go that way of doing it so here is how I'd probably do it myself: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; currentChild._y = - scrollRatio * currentChild._height; I'm not 100% sure but I think this should work. Notice the negative value for the currentChild._y. Thanks, I'll see how that behaves. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
JesterXL wrote: I didn't know what a Singleton was until AS2 was well underway. I didn't know that it was called a Singleton until Moocks book :) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Newbie AS3 question
In AS1, I would write this a bit like that: MyClass = function () { this.someProperty = whatever; } MyClass.instance = null; MyClass.getInstance = function () { if(myClass.instance == null) { MyClass.instance = new MyClass(); } return MyClass.instance; } MyClass.prototope.someProperty; MyClass.prototype.instanceMethod = function () { trace(value of my property: +this.someProperty); } That should give the same result and can be considered as a Singleton I think. Now, I might be wrong but it sure seems to do the same thing. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JesterXL Sent: October 29, 2005 12:48 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question I didn't know what a Singleton was until AS2 was well underway. - Original Message - From: Frédéric v. Bochmann [EMAIL PROTECTED] To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:32 PM Subject: RE: [Flashcoders] Newbie AS3 question (*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spike Sent: October 29, 2005 12:25 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question You're welcome! This has been an interesting thread and I've learned a bit more about ActionScript in the process :-) Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: That makes perfect sense and is a good reason. So, from this 2nd conversation, I've gleaned something else to add to the list: - getInstance() is a unspoken standard that implies the class is a Singleton used in other languages other than ActionScript - getInstance() treats a class as a true class without static properties, thus making it easier to go from Singleton to a true class without having to change a bunch of code, because all it really does is make 1, and only 1, instance of itself. The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:05 PM Subject: Re: [Flashcoders] Newbie AS3 question It's not necessarily any better from an implementation point of view. You can often do the same thing with a static class as you can with a singleton. The big benefit comes if you need to change from singleton/static to different instances for each invocation. If you have followed the static class approach you have static method calls all through your code that you will need to change if the class now needs to be non-static. If you have followed the singleton approach, you only need to change the line of code that retrieves the instance inside the singleton. That's a pretty big benefit IMO. To get back to where we started all this, the original statement that brought all this up was your suggestion that Foo.someMethod() was identical to Foo.getInstance().someMethod() Whether one is better than another is something that can be debated to death, and often is on Java mailing lists, but hopefully you'll at least agree that they are indeed doing different things. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: I would have 20 static classes, not 20 if/then/switch statements. You'd have that same if/then statement in the getInstance() function, though, to know which formatter to return. Again, I'm having a hard time seeing why getInstance is more appopriate than just making static classes, and how this applys to the Singleton pattern. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Stephen Milligan Do you do the Badger? http://www.yellowbadger.com Do you cfeclipse? http://www.cfeclipse.org ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list
Re: [Flashcoders] Newbie AS3 question
Well, actually there is a difference. In AS3, class constructors can not be Private. In AS2 they can. So in AS2 you can do this: class MySingleton { private function MySingleton() { } public static function getInstance() { // bah blah.. } } Which is not allowed in AS3. regards, Muzak - Original Message - From: Frédéric v. Bochmann [EMAIL PROTECTED] To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 6:32 PM Subject: RE: [Flashcoders] Newbie AS3 question (*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Newbie AS3 question
Woah, I never noticed you can private your constructor!! Lol -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Muzak Sent: October 29, 2005 1:15 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question Well, actually there is a difference. In AS3, class constructors can not be Private. In AS2 they can. So in AS2 you can do this: class MySingleton { private function MySingleton() { } public static function getInstance() { // bah blah.. } } Which is not allowed in AS3. regards, Muzak - Original Message - From: Frédéric v. Bochmann [EMAIL PROTECTED] To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 6:32 PM Subject: RE: [Flashcoders] Newbie AS3 question (*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to make a doughnut?
Too cumbersome to make a simple donut, isn't it :) But thanks for the suggestion JOR.. Helen came up with a pretty elegant one. Regards, Navneet - Original Message - From: JOR [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 8:16 PM Subject: Re: [Flashcoders] How to make a doughnut? How about making the doughnut shape as a movieclip and dynamically applying it as a mask layer to a gradient filled cirle you create at run-time? You could even draw the mask layer at run-time instead of using a pre-drawn one. JOR ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] scrolling problem
Now for your script, I don't usually go that way of doing it so here is how I'd probably do it myself: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; currentChild._y = - scrollRatio * currentChild._height; I'm not 100% sure but I think this should work. Notice the negative value for the currentChild._y. Thanks, I'll see how that behaves. Well, it's giving me more consistant results across my different clips, but it's scrolling too far, leaving whitespace at the bottom. Any ideas? Logically, I think the scrollRatio must be too high, because it's scrolling further than it should. I've added an offset because the top of the scrolling area is not the top of the screen. var offset = 108; var scrollRatio = scrollBar.slider._y / scrollBar.track._height; currentChild._y = (- scrollRatio * currentChild._height) + offset; I'll write some code to make the offset dynamic later. To see the script in action, go here - http://fari.kentandangela.com and browse to Gallery - Woodcarvings. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
Had I been formerly trained in programming, I'm sure I would of known what a Singleton was years ago, and called it such before AS1 was called AS1. However, since I had to learn how to code as well as advanced programming concepts at the same time, coupled by the fact ActionScript evolves so fast, thats why. - Original Message - From: Frédéric v. Bochmann [EMAIL PROTECTED] To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 1:18 PM Subject: RE: [Flashcoders] Newbie AS3 question True, nobody called that a Singleton until half way threw AS2. I think I still don't use that word often enough. I often use something like a global object to manage... and that often suffices for people to understand how the implementation might have been done. What's interesting with all this evolution of AS, is that, as it evolves real OOP terms are being used more and more in our everyday Flash vocabulary and that hence makes us look up those terms or simply make us remember of those terms which brings us to better implement our code. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JesterXL Sent: October 29, 2005 12:48 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question I didn't know what a Singleton was until AS2 was well underway. - Original Message - From: Frédéric v. Bochmann [EMAIL PROTECTED] To: 'Flashcoders mailing list' flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:32 PM Subject: RE: [Flashcoders] Newbie AS3 question (*Just looking back at the title of this Thread*) Just in case someone's wonders; creating a Singleton is nothing new in ActionScript, it can be done in AS1, AS2 or AS3. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Spike Sent: October 29, 2005 12:25 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Newbie AS3 question You're welcome! This has been an interesting thread and I've learned a bit more about ActionScript in the process :-) Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: That makes perfect sense and is a good reason. So, from this 2nd conversation, I've gleaned something else to add to the list: - getInstance() is a unspoken standard that implies the class is a Singleton used in other languages other than ActionScript - getInstance() treats a class as a true class without static properties, thus making it easier to go from Singleton to a true class without having to change a bunch of code, because all it really does is make 1, and only 1, instance of itself. The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 12:05 PM Subject: Re: [Flashcoders] Newbie AS3 question It's not necessarily any better from an implementation point of view. You can often do the same thing with a static class as you can with a singleton. The big benefit comes if you need to change from singleton/static to different instances for each invocation. If you have followed the static class approach you have static method calls all through your code that you will need to change if the class now needs to be non-static. If you have followed the singleton approach, you only need to change the line of code that retrieves the instance inside the singleton. That's a pretty big benefit IMO. To get back to where we started all this, the original statement that brought all this up was your suggestion that Foo.someMethod() was identical to Foo.getInstance().someMethod() Whether one is better than another is something that can be debated to death, and often is on Java mailing lists, but hopefully you'll at least agree that they are indeed doing different things. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: I would have 20 static classes, not 20 if/then/switch statements. You'd have that same if/then statement in the getInstance() function, though, to know which formatter to return. Again, I'm having a hard time seeing why getInstance is more appopriate than just making static classes, and how this applys to the Singleton pattern. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Stephen Milligan Do you do the Badger? http://www.yellowbadger.com Do you cfeclipse? http://www.cfeclipse.org
RE: [Flashcoders] scrolling problem
I forgot something...true. Change it to something like: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; var heightToScroll = currentChild._height - currentChildContainerMask._height; if(heightToScroll 0) { heightToScroll = 0; } currentChild._y = - scrollRatio * heightToScroll; Where currentChildContainerMask._ height is the height of the Mask that is masking your currentChild, or simply the height of the outline that is representing the visible area of your currentChild as its being scrolled. So basically heightToScroll is equal to the height of your currentChild that is invisible to the user, it's the part you want to be able to scroll for. Hope that helps :) Fredz./ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Humphrey Sent: October 29, 2005 1:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] scrolling problem Now for your script, I don't usually go that way of doing it so here is how I'd probably do it myself: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; currentChild._y = - scrollRatio * currentChild._height; I'm not 100% sure but I think this should work. Notice the negative value for the currentChild._y. Thanks, I'll see how that behaves. Well, it's giving me more consistant results across my different clips, but it's scrolling too far, leaving whitespace at the bottom. Any ideas? Logically, I think the scrollRatio must be too high, because it's scrolling further than it should. I've added an offset because the top of the scrolling area is not the top of the screen. var offset = 108; var scrollRatio = scrollBar.slider._y / scrollBar.track._height; currentChild._y = (- scrollRatio * currentChild._height) + offset; I'll write some code to make the offset dynamic later. To see the script in action, go here - http://fari.kentandangela.com and browse to Gallery - Woodcarvings. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] File under BIZARRE: FIXED
well, i use xp, firefox1.0.7/IE6, 8.5debug and i got the freezing. moving my trackpad didnt unfreeze it but i don't have a mouse hooked up. On 10/28/05, Rich Rodecker [EMAIL PROTECTED] wrote: i dont know about the bug but you should look into flashObject for the detection: http://blog.deconcept.com/flashobject/ On 10/28/05, Buck Ruckman [EMAIL PROTECTED] wrote: Sorry for hijacking the list with this problem today, folks. When we installed the Flash 8 Player on the broken machines, the problem was solved. Conclusion: my game aggravated a bug in Flash Player 7 in IE. Does that sound accurate? - Ryan Creighton (PS if that DOES sound accurate, can someone please point me to the most recent and tastiest Flash 8 detection script so's i can force all of my users to experience the joys of a working game? Thanks!!) _ Take charge with a pop-up guard built on patented Microsoft(r) SmartScreen Technology http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to make a doughnut?
Solution is quite simple ;-) Flash drawing / fill methods use XOR logic. Here's what you want (swf and code): http://gousable.com/flash/temp/doughnut1.html frcfc Navneet Behal wrote: After putting a couple of hours on the problem, I am still in a daze on how would one go about making a doughnut shape (circle with cut-out in the center) using the drawing API. I'm not talking about drawing a circle using: lineStyle(BIGNUMBERHERE, color, alpha); I'd like to put in a gradient fill into a doughnut shape. And it has to be a doughnut, not a simulation of it (ie. not by drawing 2 circles over each other and keeping the center cirlce the same as the background color). Real dunkin' doughnut! Any ideas? -- Best regards, Gregorymailto:[EMAIL PROTECTED] http://GOusable.com Flash components development. Usability services. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] scrolling problem
Frédéric v. Bochmann wrote: I forgot something...true. Change it to something like: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; var heightToScroll = currentChild._height - currentChildContainerMask._height; if(heightToScroll 0) { heightToScroll = 0; } currentChild._y = - scrollRatio * heightToScroll; Where currentChildContainerMask._ height is the height of the Mask that is masking your currentChild, or simply the height of the outline that is representing the visible area of your currentChild as its being scrolled. So basically heightToScroll is equal to the height of your currentChild that is invisible to the user, it's the part you want to be able to scroll for. Hope that helps :) Fredz./ Cool, that's working properly now. var offset = 108; var scrollRatio = scrollBar.slider._y / (scrollBar.track._height-30); var heightToScroll = currentChild._height - whichMask._height; if(heightToScroll 0) { heightToScroll = 0; } currentChild._y = (- scrollRatio * heightToScroll) +offset; the (scrollBar.track._height-30) is because the slider is 30 tall, and so it never goes beyond scrollBar.track._height-30. The slider is non-proportional at the moment. I was thinking it wasn't working, until I realised that I was cheating with the height of the mask, and hiding it behind a solid white block at the bottom of the screen! guilty look Once I've got that sorted, I just need to make the slider move when I click on the arrows. What is the best way to do that? Make the arrows move the slider, and then update the content as before? Thanks for all your help : ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] scrolling problem
Happy to hear you solved your problems, including the height of your slider was essential too :) Happy you spotted that one yourself! :D Now the arrow, what you're saying is the simplest way. Something that might be interesting for you to try to implement is to have the scrollContent update its position in an onEnterFrame instead of using an onMouseMove, if that is what you're doing at the moment. Using onEnterFrame will obviously include a little delay in your scrolled content, but it will lighten up your CPU usage if what you are scrolling is huge and heavy (Don't forget to call onEnterFrame() just before assigning it back to null). So what I would say is create a function called updateContent which will have the math's you already have. And make sure to set the onEnterFrame when the user is scrolling and assign it back to null when the user is finished scrolling. When you use the arrows, simply move the slider by the height of your slider or so, with some validations and call the updateContent method :) You're on the right path :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Humphrey Sent: October 29, 2005 2:05 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] scrolling problem Frédéric v. Bochmann wrote: I forgot something...true. Change it to something like: var scrollRatio = scrollBar.slider._y / scrollBar.scrollTrack._height; var heightToScroll = currentChild._height - currentChildContainerMask._height; if(heightToScroll 0) { heightToScroll = 0; } currentChild._y = - scrollRatio * heightToScroll; Where currentChildContainerMask._ height is the height of the Mask that is masking your currentChild, or simply the height of the outline that is representing the visible area of your currentChild as its being scrolled. So basically heightToScroll is equal to the height of your currentChild that is invisible to the user, it's the part you want to be able to scroll for. Hope that helps :) Fredz./ Cool, that's working properly now. var offset = 108; var scrollRatio = scrollBar.slider._y / (scrollBar.track._height-30); var heightToScroll = currentChild._height - whichMask._height; if(heightToScroll 0) { heightToScroll = 0; } currentChild._y = (- scrollRatio * heightToScroll) +offset; the (scrollBar.track._height-30) is because the slider is 30 tall, and so it never goes beyond scrollBar.track._height-30. The slider is non-proportional at the moment. I was thinking it wasn't working, until I realised that I was cheating with the height of the mask, and hiding it behind a solid white block at the bottom of the screen! guilty look Once I've got that sorted, I just need to make the slider move when I click on the arrows. What is the best way to do that? Make the arrows move the slider, and then update the content as before? Thanks for all your help : ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Obfuscation... Was: SWF Decompilers
I had an idea. Not sure if it's a good one. Flash is pretty good with optimizing all local var names to shorter ones like _1 and _2 which does make decompiled code a bit tougher to read. What if I took it just a step further and in one or two of my main classes I added something like this: /** * Fake function to deter decompiling * Function not actually used by class. **/ public var handleComputations () { // Maybe 10 or 20 lines of nonsensical but compileable // code using the local vars so that variable // names appear to be used inside this function but // this function isn't actually ever called by the class. // Maybe use uncommon routines with some bit shifts // and complex mathmatical equations to make it look scary. } Overall it might make the swf 1KB or so bigger but might be worth it if it added a frustrating day or two to a decompiler especially if they don't figure out right away that the function is never called. Any thoughts? JOR ___ === James O'Reilly === === SynergyMedia, Inc. === www.synergymedia.net Mike Duguid wrote: yep still works On 10/28/05, Gregory [EMAIL PROTECTED] wrote: Question: BTW, anyone knows if __bytecode__() is supported in Flash 8 (I'm still using MX 2004 Pro)? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Newbie AS3 question
The idea is to use it (this) when you have two variables with the same name, usually to distinguish between the class member and a locally declared variable. You must know that :) The compiler won't know to use this or not in those cases, so it is important to use it in those contexts. Actually, the compiler *does* know, it always adds this. to references without explicitly stated scope. Which brings us full circle, all the way back to maintainability. Now, if you have a class, and all of the member functions and variables are referenceless (using assumed scope without the this reference), and all of a sudden, in the middle of a method, you have a this reference because of a potential scope conflict, what does a developer looking at your code 2 years after you've left the job think about it? Does he remove the single this reference, to make it more readable and consistent, thus breaking the method and blowing up the whole project, all without knowing how or why? Martin piped up with I would refactor the method to make it more readable... immediately, which, in this case, would've broken the method (if he removed the reference) and possibly the whole class, which is exactly how these sort of expensive, time consuming, and difficult to troubleshoot problems come up. On the other hand, if the original developer used the this reference every time, it would already be consistent, readable, and explicit about scope. The other question is, would Martin (not to pick on Martin, but he was vocal about it, so I use him as an example) take a class that stated scope explicitly and remove all the this references, possibly breaking the class in the process? It sounds like it, from his post. The question is, is that a good practice or a bad practice, and does that make him a good developer, or a bad one, given the potential for expensive and time consuming breakage caused solely by his dislike for the keyword this? In my opinion (and in the opinion of many much more competent developers than myself), it is always good to be explicit about scope, because it removes any ambiguity from the code, drastically reducing the possibility of expensive and time consuming breakage during maintenance. One more thing worth mentioning, and I don't say this to be rude or as a slight to anyone on this list, but the opinion that the this reference is bad and should be avoided seems to be unilaterally coming from people who learned programming in Flash, while the opinion that scope should be stated explicitly seems to be coming from people with more formal training in software development and experience in (non-Flash) real world development. Personally, I have to give more weight to the opinions of people with more formal training and more varied real-world experience, because there are some things you just can't learn in a year or two of using Flash for web development. There is a reason that experienced developers like to type those extra 5 characters, and it is to save time, money, and the embarrasment of explaining to your boss that you deleted something without fully understanding the implications. ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
The thought of changing multiple lines of code to go from static to non would really suck; that drives the point home for me. Thanks for taking the time to explain it Spike! That's that whole maintainability thing, which, in commercial software, is usually just as or even more important than efficiency and optimization. Incidentally, the way I handled that particular example was by making a single dynamic class that can be instantiated as a particular locale, or can change locales with a single method call, with a common set of functions and loadable locale defenitions, which was instantiated in a singleton enviornment class. That way, there is only ever one application enviornment, but potentially several different locales that can be used to format dates and numbers through a common interface. It was way easier than making 276 static classes for all the locales I had to support. ;-) ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Newbie AS3 question
You do know that it (this.) is being added for you at compile time in AS2, right? Who cares? All that means is that there is no semantic difference between the two. Not quite. What it means is that the this is assumed, which is not always what you want. And if you need the reference sometimes and other times it is extraneous, why not use it all the time for the sake of consistency? ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Newbie AS3 question
Still weirding me out. To me part of the appeal of working with movieclips is their inherent hierarchy, which makes a kind of basic sense that's easy to grasp. To a Flash developer who understands Flash and has been working with it for a long time, that's true. To anyone coming from another language or platform, it makes no sense at all. It is also extremely limiting, and more flexxibility at the cost of an extra line of code is a beautiful trade off in my book. I'm guessing part of why we're waiting til Flash 9 for this stuff is because it doesn't make immediate sense in a Flash IDE context yet. A movie clip is still a movie clip, but now, instead of being the basic unit of Flash, there are smaller units, such as sprites, displayobjects, etc. More granualrity means more control, but it also means a few extra lines of code. ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Xml parsing object
Does anyone got some nice object/method that transforms a xml data from a xml object into a nice object graph? I would like to ask (trying to avoid reinventing the wheel) before I am starting writing my own solution for parsing xml data into a structure for easier reference. Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Re: Newbie AS3 question
Hey ryanm, Imagine this: class MyClass { private var myName:String; public function MyClass(myName:String) { this.myName = myName } } Or: class MyClass { public function MyClass(myEventDispatcher) { var myListener = new Object(); myListener.controler = this; myListener.click = function (eventObj) { this.controler.onMyClick(eventObj); } myEventDispatcher.addEventListener(click, myListener); } public function onMyClick (eventObj) { } } Naturally you can use the Delegate object instead of creating an anonymous function, but the fact states that those are moments you absolutely need to use this and good practice is about using them when you need them / When you want to write them everywhere, it's really the programmers choice to write it as he wishes but he should think of future programmers that might go into that code, they might not want to scroll horizontally that much to read the code, it just makes lines shorter and easier to read, if well written. Now you're saying that the compiler adds this everywhere or almost... Well this is more like the pre-compiler's job, and this is why it actually exists. The idea is to write human readable ECMA script that isn't too cluttered, that the pre-compiler can arrange for the compiler to compile. If we didn't have the pre-compiler we'd be writing a lot of code with a lot of this everywhere and we wouldn't be able to forget to put a semi-column at the end of each line :P (a bit like PHP) On the other side, in AS1 when creating your classes it is about 100% necessary to specify this in front of instance properties or methods. Things have changed in AS2 and their closer to what standard OOP programming should look like. If you look in the world of JAVA, you won't find extensive usage of the this statement like you seem to be saying. But it is really the programmer's discretion to use this as he wishes when he doesn't HAVE to use it; nobody should blame someone for using this anytime except if it does something that is not meant to be. When programmers modify code, removing the this statements everywhere when going threw somebody's code like your saying, they should be aware of what this might involve, and it's not the fault of the programmer that put all those this statements, it's the fault of the one that removed them I'd say. Common sense! So I wouldn't really be annoyed by reading your code that has this, everywhere it can be used at. It's ok and so be it. All that to say, if your going to be putting this in front of every class member in AS2 and in AS3 you'll be missing the neat advantage of simplicity. I think it's a question of trusting how Flash will get compiled and how it will run it! Trust ECMA script and know what you're coding, if it's AS1, use lots of this; if your in pure AS2, lighten the number of characters in your file if you may!:) Let's not even mention AS3, since it's even more a question of cleaning up your code and making it human readable and OO. Using this everywhere would ruin the fun of writing AS2 and AS3. And yes there are cases in AS2 where your class method might need this in front of all methods and members it uses; this is mostly the case if you're redirecting methods to other classes with their prototype, thus returning to the world of AS1. Cheers, Fredz./ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryanm Sent: October 29, 2005 3:39 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Re: Newbie AS3 question The idea is to use it (this) when you have two variables with the same name, usually to distinguish between the class member and a locally declared variable. You must know that :) The compiler won't know to use this or not in those cases, so it is important to use it in those contexts. Actually, the compiler *does* know, it always adds this. to references without explicitly stated scope. Which brings us full circle, all the way back to maintainability. Now, if you have a class, and all of the member functions and variables are referenceless (using assumed scope without the this reference), and all of a sudden, in the middle of a method, you have a this reference because of a potential scope conflict, what does a developer looking at your code 2 years after you've left the job think about it? Does he remove the single this reference, to make it more readable and consistent, thus breaking the method and blowing up the whole project, all without knowing how or why? Martin piped up with I would refactor the method to make it more readable... immediately, which, in this case, would've broken the method (if he removed the reference) and possibly the whole class, which is exactly how these sort of expensive, time consuming, and difficult to troubleshoot problems come up. On the other hand, if the original developer used the this reference every time, it would already be consistent, readable, and explicit
Re: [Flashcoders] Re: Newbie AS3 question
All that to say, if your going to be putting this in front of every class member in AS2 and in AS3 you'll be missing the neat advantage of simplicity. As it were, the classes I write are rarely self-referential. Properties such as position, visibility, etc, are usually handled elsewhere or by other means rather than directly referring to itself, so you won't find this in my code a lot either. When it does appear it is the rare exception, not the rule, but by the same token, you also won't find referenceless method calls either. I very, very rarely put something like this._visible=false; in a constructor, and usually only because it's a quickie, one-off project that won't need to be maintained, and even if maintenance is required, there is usually only one class to deal with and everything is right there. But when I do something like that, I always use this, just so that it's clear what I'm referring to. You also rarely find _parent references in my code, because usually when I need a reference to the parent, I pass that reference in at creation time and store it as a member variable in the class. If it's not important enough to be a member of the class, then it probably isn't necessary, and if it's necessary, it's important enough to be a member. So really, this is the only ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Newbie AS3 question
Of course there exists edge cases where that isnt feasible, but most programs dont implement DES algorithms (to relate this to an earlier post) and a lot of legacy code i have worked with has benefitted from being re-factored. I actually do have classes with methods so large that I had to make a base class containing only that method and then extend it (because of the size limit imposed by Flash), but as was mentioned, they are mostly encryption or compression classes, and are special cases. ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Newbie AS3 question
ryanm wrote: You do know that it (this.) is being added for you at compile time in AS2, right? Who cares? All that means is that there is no semantic difference between the two. Not quite. What it means is that the this is assumed, which is not always what you want. You can force class scope by including this, but there's no way to do the opposite. Local (or class) scope always obscures global scope, that's just a fact of life. The only exception is built-in function like trace and eval, which normally obscure everything else. That's probably part of the reason AS3 is more heavily based around namespaces - you can more clearly state what scope you want if everything resides in a unique namespace. That takes us back to the point about whether you should include this everywhere - doing so is akin to including the fully qualified name of every class instead of just importing the package. Which is easier to read? - Robert ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Re: Re: Newbie AS3 question
Yes, but how do you know order of construction of static clases, if you have more each one init depends on other? JesterXL [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If you utilize a static function, it would be called when the class itself is created in ActionScript, before frame 1 even runs: class Test { static var inited = InitThisTest(); } Why wouldn't that solve it? - Original Message - From: A.Cicak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 6:59 AM Subject: [Flashcoders] Re: Newbie AS3 question Problem with JasterXL's class is initialization. For example if you had to initialize something in that class you should make static method called InitCurrencyFormatter(). But when to call it? If other classes are using CurrencyFormatter than you should ensure to call InitCurrencyFormatter() before construction of any class which uses it is called. But what if InitCurrencyFormatter also depends on some other class which is made just with static methods (like JasterXL's). In that case that other class would have to have InitOtherClass() and it also should be called before other objects are constructed and before InitCurrencyFormatter. Now imagine 20 classes like that and thousands of lines of code depending on them, it would be almost impossible to keep track when to initialize any of these classes, and it would be very error prone (you change order of execution and you start using uninitialized objects). If you make these classes singletons you don't have that problem, because when you call getInstance() if object was not initialized getInstance will call new and that will call its constructor ( which now replaces InitCurrencyFormatter, InitOtherClass, etc..) and it will ensure that all objects are initialized at time of their use, and you do not have to worry about order of execution. Spike [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sure, Here's a slightly more complete implementation of that last example: public class CurrencyFormatter { private static formatter:CurrencyFormatter; public function getInstance():CurrencyFormatter { // use ExternalInterface or IP lookup or whatever to determine locale if (locale == UK) { formatter = new UKCurrencyFormatter(); } else { formatter = new USCurrencyFormatter(); } return formatter; } class USCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return $ + String(val); } } class UKCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return £ + String(val); } } } Let me know if that explains it a bit better. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: Can you elaborate? Why wouldn't the static class work in that case? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:54 PM Subject: Re: [Flashcoders] Newbie AS3 question ok, That's just a static class. Like I said, there's a subtle but important difference between singleton and a static class. Here's another example. You have a requirement to provide a currency formatter. One way to do this is to create a singleton that returns a different currency formatter depending on which locale you are in. So in the class you would have something like this (Omitting method declarations for simplicty): public class CurrencyFormatter { class USCurrencyFormatter extends CurrencyFormatter { } class UKCurrencyFormatter extends CurrencyFormatter { } } Now if I call CurrencyFormatter.getInstance() it gives me the correct formatter for my locale. With your static class approach you have to check in every method what the locale is and handle it accordingly. That's fine for one or two locales, but if you want to handle 20, it gets pretty ugly. You can solve the problem in other ways of course, but it does demonstrate the difference between static classes and the singleton pattern. The singleton pattern offers you a lot more possibilities. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: To clarify: class ServerConnection { private static var url; private static var port; private static var socket; public static function connect(p_url, p_port) { url = p_url; port = p_port; socket = new Socket(); socket.connect(url, port); } public static function getData() { // Simple function that gets something from the server. } } Then to use: ServerConnection.connect(myURL, myPort); - Original Message - From: JesterXL [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:25 PM Subject: Re: [Flashcoders] Newbie AS3 question Naw, I don't know the exact way Singleton is implemented, hence my long battle with finding
RE: [Flashcoders] How to make a doughnut?
cut the ring with a 1 pixel line, then it's like a c with a pixel opening. You could do this with the drawing api, but if the split shows too badly you might need to patch it -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Navneet Behal Sent: Saturday, October 29, 2005 9:54 AM To: Flashcoders mailing list Subject: [Flashcoders] How to make a doughnut? After putting a couple of hours on the problem, I am still in a daze on how would one go about making a doughnut shape (circle with cut-out in the center) using the drawing API. I'm not talking about drawing a circle using: lineStyle(BIGNUMBERHERE, color, alpha); I'd like to put in a gradient fill into a doughnut shape. And it has to be a doughnut, not a simulation of it (ie. not by drawing 2 circles over each other and keeping the center cirlce the same as the background color). Real dunkin' doughnut! Any ideas? Thanks for your time. Regards, Navneet ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Re: Newbie AS3 question
this can also be used to refer an instance's member variable explicitly. Since scoping rules allow for a local variable (in a method) to be named the same as an instance member variable, this is required to differentiate between the two. (Sorry about the html mail) Scott -Original Message- From: [EMAIL PROTECTED] on behalf of A.Cicak Sent: Fri 28/10/2005 6:32 PM To: flashcoders@chattyfig.figleaf.com Cc: Subject: [Flashcoders] Re: Newbie AS3 question Well, I dont agree, this keyword refers to current class, so its only more typing to include it, and making code less readable. Only reason keyword this exists is if you want to pass reference to current object somewhere, in which case you must use this. To me using this in your code makes you look like wannabe-programmer, :) But I gues its matter of taste. btw, old VB does not have this keyword, and if you were reffering to VB(.NET), it is more OOP and more complex than AS3, so I gues programmers in VB.NET (if there are some, since C# is there) are not wannabe-programmers :) ryanm [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] What I don't get is why it needs this.addChild instead of just addChild. I've been sick of the keyword this for a long time and have since avoided it in AS2. Any reason that it needs to be back in for AS3? Maybe because it's one of the most useful scope references ever invented? The fundamental concept that you seem to miss is that addChild is meaningless by itself, it is a method of an object (in proper OOP development), and if you just say addChild, who is adding the child? You need a reference. You could do it like this if you like: class Game extends MovieClip { var world:MovieClip; var bg:MovieClip; function Game(){ var GameReference:Game = this; world = new MovieClip(); GameReference.addChild( world ); bg = new MovieClip(); world.addChild( bg ); } } The point is, you shouldn't use functions that aren't attached to objects, it's bad form, and it's thoroughlly confusing to people who later have to maintain your code. Besides, it makes you look like one of those wannabe-programmer VB guys. ;-) ryanm ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Open Source Flash MMORPG
I've ben working on-and-off, though mostly off, on a MMORPG/Roguelike hybrid for a long time now, and would really like to get a team working with me so that I have some impetus to actually get serious on it. I will be open sourcing all the code base (both the AS and backend), and, once at the prototype stage, hope to form a company to run some servers hosting enhanced versions of the game. I'll be happy to share more information with people with serious interest in the project -- just email me. I'd welcome any comments about remote collaboration on coding Flash projects, but they should probably go here on this list, as they are widely applicable. For more information on roguelikes, if they are unfamiliar: www.nethack.org http://roguelikes.sauceforge.net/pub/index.html -Mark Hawley -- John Mark Hawley The Nilbog Group 773.968.4980 (cell) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Re: Newbie AS3 question
The order is based on inheritance, or #initclip order, which is based on which classes is nested where. #initclip won't work, though, if you're class doesn't extend MovieClip, and if you don't extend something, you have to rely on the compiler. As such, you'll have to utilize an instance, at least via a depend variable inside the class: private var depend:OtherClassINeed; I can see what you mean, though, how that gives very little control, and isn't really flexible. - Original Message - From: A.Cicak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 5:31 PM Subject: [Flashcoders] Re: Re: Newbie AS3 question Yes, but how do you know order of construction of static clases, if you have more each one init depends on other? JesterXL [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If you utilize a static function, it would be called when the class itself is created in ActionScript, before frame 1 even runs: class Test { static var inited = InitThisTest(); } Why wouldn't that solve it? - Original Message - From: A.Cicak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 6:59 AM Subject: [Flashcoders] Re: Newbie AS3 question Problem with JasterXL's class is initialization. For example if you had to initialize something in that class you should make static method called InitCurrencyFormatter(). But when to call it? If other classes are using CurrencyFormatter than you should ensure to call InitCurrencyFormatter() before construction of any class which uses it is called. But what if InitCurrencyFormatter also depends on some other class which is made just with static methods (like JasterXL's). In that case that other class would have to have InitOtherClass() and it also should be called before other objects are constructed and before InitCurrencyFormatter. Now imagine 20 classes like that and thousands of lines of code depending on them, it would be almost impossible to keep track when to initialize any of these classes, and it would be very error prone (you change order of execution and you start using uninitialized objects). If you make these classes singletons you don't have that problem, because when you call getInstance() if object was not initialized getInstance will call new and that will call its constructor ( which now replaces InitCurrencyFormatter, InitOtherClass, etc..) and it will ensure that all objects are initialized at time of their use, and you do not have to worry about order of execution. Spike [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sure, Here's a slightly more complete implementation of that last example: public class CurrencyFormatter { private static formatter:CurrencyFormatter; public function getInstance():CurrencyFormatter { // use ExternalInterface or IP lookup or whatever to determine locale if (locale == UK) { formatter = new UKCurrencyFormatter(); } else { formatter = new USCurrencyFormatter(); } return formatter; } class USCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return $ + String(val); } } class UKCurrencyFormatter extends CurrencyFormatter { public formatValue(val:Number) { // very simplistic formatting return £ + String(val); } } } Let me know if that explains it a bit better. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: Can you elaborate? Why wouldn't the static class work in that case? - Original Message - From: Spike [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Friday, October 28, 2005 9:54 PM Subject: Re: [Flashcoders] Newbie AS3 question ok, That's just a static class. Like I said, there's a subtle but important difference between singleton and a static class. Here's another example. You have a requirement to provide a currency formatter. One way to do this is to create a singleton that returns a different currency formatter depending on which locale you are in. So in the class you would have something like this (Omitting method declarations for simplicty): public class CurrencyFormatter { class USCurrencyFormatter extends CurrencyFormatter { } class UKCurrencyFormatter extends CurrencyFormatter { } } Now if I call CurrencyFormatter.getInstance() it gives me the correct formatter for my locale. With your static class approach you have to check in every method what the locale is and handle it accordingly. That's fine for one or two locales, but if you want to handle 20, it gets pretty ugly. You can solve the problem in other ways of course, but it does demonstrate the difference between static classes and the singleton pattern. The singleton pattern offers you a lot more possibilities. Spike On 10/29/05, JesterXL [EMAIL PROTECTED] wrote: To clarify: class ServerConnection { private static var url; private static var port;
Re: [Flashcoders] How to make a doughnut?
Ah.. reading the code again along with your post I realize the AOL Keyword is BEFORE the end fill is applied which is necessary to make the cut-out. Got it... thanks again. Regards, Navneet - Original Message - From: Helen Triolo [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Saturday, October 29, 2005 7:56 PM Subject: Re: [Flashcoders] How to make a doughnut? Here's one I just made (and tested) from a draw circle prototype that then draws another circle in reverse (before the endfill is applied -- necessary to get a cutout): snip Helen -- ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Xml parsing object
Check out Sephiroth's XML2Object class : http://www.sephiroth.it/file_detail.php?id=129 very nice and easy to use. Weyert de Boer wrote: Does anyone got some nice object/method that transforms a xml data from a xml object into a nice object graph? I would like to ask (trying to avoid reinventing the wheel) before I am starting writing my own solution for parsing xml data into a structure for easier reference. Yours, Weyert de Boer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Xml parsing object
Thanks! I will have a look :-) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to make a doughnut?
That's a very long keyword. But yes, that's crucial. I decided to write it up so I wouldn't forget again that it's only the mask that requires a reverse cutout: http://flash-creations.com/notes/dynamic_drawingapi.php#cutout Helen Navneet Behal wrote: Ah.. reading the code again along with your post I realize the AOL Keyword is BEFORE the end fill is applied which is necessary to make the cut-out. Got it... thanks again. Regards, Navneet ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] setInterval() and the trouble
use setTimeout now and you dont need to worry about interval ids. e.dolecki On Oct 29, 2005, at 11:21 AM, Weyert de Boer wrote: JOR wrote: At first glance it looks like you have a potential continuous loop issue? stopwatchComplete() questionComplete() stopwatchComplete() and so on if (id = questions.length) Second is I don't see where id is defined in questionComplete() did you mean to type this instead: The id should ofcourse matched the correct name of the parameter. If you know a better way please let me know! if ( questionId = questions.length ) Aha, good one I will try ;-) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Flash and ASP/MSSQL
Hello everyone, This is a question about Flash in an ASP form which communicates with an MSSQL db. I'm not really sure how to phrase the question, so I'm afraid that I'll just have to explain the story. Imagine an ASP page about faulty garments. Let's just say that if you had a hole in your T-shirt, you could visit this page to report it. The page would have normal HTML fields for name and email, and it would also have a SWF with a picture of a T-shirt. The disgruntled hole-y user clicks on the T-shirt to leave an X representing where the hole is. The form information (including that of the hole location, in the SWF) is then submitted using a normal HTML submit button and stored in the MSSQL db. I spose my question is, is this scenario possible? Is it only possible to store user-submitted information (in this case, the X,Y coordinates of the hole) by clicking on a Send button WITHIN flash, or is there another way? I'd like to avoid making a user explicitly submit the SWF information AS WELL AS the form information. Any ideas and comments much appreciated, Thanks muchly, Amanda. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash and ASP/MSSQL
You would need to call a javascript function from AS when the user clicks the inside swf and set the value of a hidden form field.. then the user can click the HTML send button and send everything. On Oct 30, 2005, at 12:38 AM, Amanda Kuek wrote: Hello everyone, This is a question about Flash in an ASP form which communicates with an MSSQL db. I'm not really sure how to phrase the question, so I'm afraid that I'll just have to explain the story. Imagine an ASP page about faulty garments. Let's just say that if you had a hole in your T-shirt, you could visit this page to report it. The page would have normal HTML fields for name and email, and it would also have a SWF with a picture of a T-shirt. The disgruntled hole-y user clicks on the T-shirt to leave an X representing where the hole is. The form information (including that of the hole location, in the SWF) is then submitted using a normal HTML submit button and stored in the MSSQL db. I spose my question is, is this scenario possible? Is it only possible to store user-submitted information (in this case, the X,Y coordinates of the hole) by clicking on a Send button WITHIN flash, or is there another way? I'd like to avoid making a user explicitly submit the SWF information AS WELL AS the form information. Any ideas and comments much appreciated, Thanks muchly, Amanda. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders