Re: [Flashcoders] Error 1120?
Try : public class MathUtil { - James On Jan 9, 2008, at 10:00 PM, Dwayne Neckles wrote: thanks so much for help me out but its not working still here is the updated code.. ** inside fla import com.bigspaceship.util.math.MathUtil; var num:Number = MathUtil.getRandom(4,100); trace(num) * Class file below package com.bigspaceship.util.math{ class MathUtil { static var min_num:Number; static var max_num:Number; static var num1:Number; static var num2:Number; public static function getRandom(min_num, max_num) { //return min_num + Math.floor(Math.random() * (max_num + 1 - min_num)); } public static function getRandomFloat(min_num, max_num) { //return (min_num + Math.random() * (max_num - min_num)); } public static function getCenterPoint(num1,num2) { //return (num1 - num2 )/ 2; } } } Date: Wed, 9 Jan 2008 18:35:18 -0800 From: [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Error 1120? You're attempting to access instance vars in a static method. Make min_num and max_num static. Also, you don't need to put a constructor in a static class. Also, you should follow common practice and put public before static when declaring functions and variables. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _ Watch “Cause Effect,” a show about real people making a real difference. http://im.live.com/Messenger/IM/MTV/? source=text_watchcause___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders James Booth [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Re: Handle Leaks in Flash, anyone can help?
Varun, To make sure that any listener are properly removed and the way I usually handle EventDispatcher, is to first create a private variable for the delegate. private var onStatus_func : Function; Then in an init function or elsewhere prior to adding the listeners: onStatus_func = Delegate.create (this, updateStatus); then, adding the listener: myClass.addEventListener (onStatus, onStatus_func); you would then remove it as: myClass.removeEventListener (onStatus, onStatus_func); This is one of the few ways that will properly remove the eventListener. I tend to keep them in a destroy function to make it easy. If you are throwing the delegate in as such: myClass.addEventListener (onStatus, Delegate.create (this, updateStatus)); myClass.removeEventListener (onStatus, Delegate.create (this, updateStatus)); This will not work. It's how the function is referenced. I've done simple tests with components to verify that it doesn't work. Hope that helps. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ngo Sent: Tuesday, July 10, 2007 7:53 AM To: flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Re: Handle Leaks in Flash, anyone can help? Removing the MovieClips or objects does not remove the listeners to that object. You would have to explicitly remove the listeners first then remove your MovieClip/object. Otherwise, the reference to the listener will still exist, thus not get picked up by garbage collection. This could be another cause of your leak issue. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Varun Soundararajan Sent: Tuesday, July 10, 2007 2:10 AM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Re: Handle Leaks in Flash, anyone can help? Hi James, you are right, I use a lot of EventDispatcher in the code. Most of the components throw events which are listened by other components in the scene. I have lot of components, more commonly, Tree, Scrollpanes, list box,etc etc.. in my XML if I command the object to be deleted, it gets deleted. If it were a movieclip in a scrollpane. i do : scrollpane.content.unloadMovie(); scrollpane.content.removeMovieClip(); and then i unload and remove the scrollpane itself. if say, the XML commands the object to be created, i would also add eventHandlers for the object I created.. eg: object.addActionListener(enter,Delegate.create(this,enterActionHandler)); I dont remember adding a removeActionListener method when the object is deleted (the deletion command is sent through the XML, which makes the VM to delete the object)..I will do that ASAP and see how that helps.. This is a good lead.. Are there anything else associated with Action Listeners/Event Dipatchers that I missed out? One more thing, New listeners are NOT added to the existing object during 1 minute intervals, I add listeners only when I create a new object, in other words, if the server through the XML commands the client to create an object. Is there some profiler that will help know if any event that was dispatched has not been caught by any component/object? Thanks Varun On 7/10/07, James Booth [EMAIL PROTECTED] wrote: Are you using EventDispatcher at all? If so, are you adding listeners at each interval? Make sure they're added and removed properly or they'll get lost and mount up. It's hard to help without seeing any code. Can you give a brief example of the code that runs at each interval? - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Varun Soundararajan Sent: Monday, July 09, 2007 2:51 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Re: Handle Leaks in Flash, anyone can help? Hi, can anyone give some hints on how to proceed? On 7/9/07, Varun Soundararajan [EMAIL PROTECTED] wrote: Hi Flash Champs, I need help regarding handle leak issue. I have a Flash movie that parses XML from the server every 1 minute. The XML file that the SWF parses in every 1 minute interval is around 100- 200 KB. I m seeing that IE starts leaking handles (not sure if that is related to XML parsing, but the XML every one minute can trigger a change in the content of the movie (ie., what objects should be visible or if a new object needs to be created etc) ). When I profiled IE process, I see a lot of token handle leaks (more than 2000 handles leaks per day) ( My understanding on Token Handles: It is a handle to a security credential. Usually when IE connects to a server it tries to send the credentials of the logged in user. These credentials are seen as tokens in windows.) Are there any documented issues regarding this? If I keep IE open for a few days (2-3 days), Flash will cause IE to either crash, or make the system unstable.. I have disabled all Toolbars (except Adobe PDF toolbar).. I use
RE: [Flashcoders] Re: Handle Leaks in Flash, anyone can help?
Are you using EventDispatcher at all? If so, are you adding listeners at each interval? Make sure they're added and removed properly or they'll get lost and mount up. It's hard to help without seeing any code. Can you give a brief example of the code that runs at each interval? - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Varun Soundararajan Sent: Monday, July 09, 2007 2:51 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Re: Handle Leaks in Flash, anyone can help? Hi, can anyone give some hints on how to proceed? On 7/9/07, Varun Soundararajan [EMAIL PROTECTED] wrote: Hi Flash Champs, I need help regarding handle leak issue. I have a Flash movie that parses XML from the server every 1 minute. The XML file that the SWF parses in every 1 minute interval is around 100- 200 KB. I m seeing that IE starts leaking handles (not sure if that is related to XML parsing, but the XML every one minute can trigger a change in the content of the movie (ie., what objects should be visible or if a new object needs to be created etc) ). When I profiled IE process, I see a lot of token handle leaks (more than 2000 handles leaks per day) ( My understanding on Token Handles: It is a handle to a security credential. Usually when IE connects to a server it tries to send the credentials of the logged in user. These credentials are seen as tokens in windows.) Are there any documented issues regarding this? If I keep IE open for a few days (2-3 days), Flash will cause IE to either crash, or make the system unstable.. I have disabled all Toolbars (except Adobe PDF toolbar).. I use HTTP to request XML data from Server (I think thats the only non-remoting way to obtain data from server in Flash). There is JSP Session ID based authentication to connect to server before running the SWF. Does that have something to do with this? When I login to the server with credentials, but dont launch the Flash movie, I dont have Handle Leaks, that has led me to the conclusion that something in the flash movie could be the trouble maker. How do I go ahead debugging? Thanks in advance. Some details about the Flash Movie: There are several Actionscript Verison 2 components in the movie all instances of which are created at runtime using actionscript. all of my code is in Actionscript 2 There is quite some XML parsing. There are not much animations in the movie (the movie more has to do with parsing the XML and representing it in the screen). Please feel free to ask more details that are needed.. Regards Varun -- Regards --Varun S http://mailvarun.blogspot.com /* This mail was sent using 100% recycled electrons */ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Getting a press for regular key...
Could it be the case of your variable? KEY_a versus Key_a -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eric dolecki Sent: Thursday, November 02, 2006 8:51 AM To: Flashcoders mailing list Subject: [Flashcoders] Getting a press for regular key... I have this: var KEY_a:Number = 97; function myOnKeyDown():Void { trace( Key.isDown(Key_a)); }; var keyListener:Object = new Object(); keyListener.onKeyDown = myOnKeyDown; Key.addListener( keyListener ); When I press the a key - I get a false. What is the proper shortcut code in the myOnKeyDown to properly get the trace to return True? - e. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Getting a press for regular key...
Actually, on top of that, I think isDown checks the Key Code which would be 65. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Booth Sent: Thursday, November 02, 2006 4:15 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Getting a press for regular key... Could it be the case of your variable? KEY_a versus Key_a -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of eric dolecki Sent: Thursday, November 02, 2006 8:51 AM To: Flashcoders mailing list Subject: [Flashcoders] Getting a press for regular key... I have this: var KEY_a:Number = 97; function myOnKeyDown():Void { trace( Key.isDown(Key_a)); }; var keyListener:Object = new Object(); keyListener.onKeyDown = myOnKeyDown; Key.addListener( keyListener ); When I press the a key - I get a false. What is the proper shortcut code in the myOnKeyDown to properly get the trace to return True? - e. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] printable certificates for flash 7
Look into Flash Remoting. This is how I've done it in the past. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Gay Sent: Tuesday, September 19, 2006 4:42 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] printable certificates for flash 7 I've been out of flash development for a little while and I recognize that this may be under the radar of many on the list. Should I switch to the newbie list to find an answer regarding this? Thanks, -Jim On Sep 19, 2006, at 11:16, Jim Gay wrote: I'm getting ready to do a project where I need to create a printable certificate with dynamic info (such as a name pulled from a database) for users with Flash player 7. Does anyone have any recommendations on the best way to handle it. Can I do so relatively easily without the need for something like Flash Comm. Server? Tips or tutorials would be greatly appreciated. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Not seeing video on stage
Make sure your Video Player Component has an instance name and is referenced properly. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Helen Triolo Sent: Tuesday, August 22, 2006 11:59 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Not seeing video on stage Does it work if you put an Embedded Video instance called vid on stage instead? I don't think you can instantiate one like you're doing (but I could be wrong). Helen -- http://flash-creations.com http://i-technica.com Mendelsohn, Michael wrote: Hi list... I'm not sure why I can't see my loaded flv on the stage. I can hear them, I just can't see them. I have a class that runs the show as follows. Thanks, - Michael M. import flash.external.*; class welcomeWebpage { public var nc:NetConnection; public var ns:NetStream; public var vid:Video; public var ui:MovieClip; public static var currentCategory:String; public static var inst:welcomeWebpage = undefined; private function welcomeWebpage() { // singleton } public static function getInstance():welcomeWebpage { if (inst == undefined) { inst = new welcomeWebpage(); } return inst; } public function init():Void { // create netConnection to import external flv files (sitting next to swf) nc = new NetConnection(); nc.connect(null); ns = new NetStream(nc); vid = new Video(); } public function playVid(theVid) { //start to load, then play, the appropriate video.. vid.attachVideo(ns); ns.play(theVid); // tried to set _x, etc. here but nothing works } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] MovieClip loader IE Caching bug
I had a similar issue that I wanted to attach an ImageNotFound clip if an image didn't load, but I'm unable to attach anything if it fails. The only way I could fix it, was to initially create an empty movieclip and load into that. If it failed, I remove and recreate the empty movieclip and then I can attach. The issue may be similar. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Mountain Sent: Wednesday, August 16, 2006 10:58 AM To: Flashcoders mailing list Subject: [Flashcoders] MovieClip loader IE Caching bug I don't do too much online work to be honest so I've only just found this out - but I cannot believe Adobe haven't fixed this bug. http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/w whelp.htm?context=LiveDocs_Partsfile=2538.html Using listeners for the movieclip loader, events only fire the first time the swf is loaded, if it's cached in ie then the listeners don't fire! How fundamentally flawed is this!?! Is their an elegant workaround or do I really have to use the 'old' onEnterFrame bytesLoaded v bytesTotal comparision? OMG Arrgh! Etc. M ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] WSIWYG HTML text editor in Flash?
I just did exactly this, a couple of days ago. I created a class that can apply any kind of supported HTML formatting. The idea seemed daunting at first, but the class is relatively small. You can assign/remove textfields that it should watch. I don't have it here with me right now, but here's the basics: It doesn't use replaceText at all. I have a switch statement for the various textformat options (some are Boolean (bold, italic, etc) and some have arguments (leading, size, etc). When the textfield has focus use an interval to get the beginIndex and endIndex. You can clear the interval onkillFocus. Then in your setFormat function Public function setFormat (type, arg):Void { var temp_fmt:TextFormat = currentField.getTextFormat(beginIndex, endIndex); switch (type) { case bold: case italic: case underline: //etc... { temp_fmt[type] = temp_fmt[type] == false ? true : false; break; } case leading: case align: case size: //etc... { temp_fmt[type] = arg; break; } } currentField.setTextFormat(beginIndex, endIndex, temp_fmt); } This should give you a head start. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Tuesday, August 01, 2006 10:11 AM To: Flashcoders mailing list Subject: [Flashcoders] WSIWYG HTML text editor in Flash? Two related questions. In a nutshell, trying to make a WSIWYG HTML text editor for Flash 7. Question 1: Has anyone created an HTML text editor component or class of some kind in Flash? Basically, having a textfield containing a paragraph of text the user can apply bold, size, font, etc. to - I assume it would use something like: textfield.replaceText(Selection.getBeginIndex(),Selection.getEndIndex(), theNewString) or something to that effect. So to my second question, I was able to get the above working, but the html Textfield would not apply the new HTML tags, it would show them literally when replaceText was used. Initially, I set the text with textField.htmlText = myText and renders fine with the bolding, but textField.replaceText() seems to not allow the textfield to show the bold tags applied - it shows the literal tag. Any ideas? Basically, would like to create a WSIWYG HTML text editor (flash 7), but from what I read in the archives, it's a lot harder than it sounds and maybe not even possible in Flash right now, but I don't want to give up too early. It seems that all the basic methods are available, there are just some quirks to work out with the Textfield class. Thanks, Jason Merrill Bank of America Learning Organization Effectiveness - Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Littleloud: Flash Developer Position
Maybe he just forgot to put the ;) At the end. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of hank williams Sent: Friday, June 09, 2006 3:06 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Littleloud: Flash Developer Position Its all about tone. Hank On 6/9/06, Nick Weekes [EMAIL PROTECTED] wrote: I dont see the problem with them keeping the job email short, and saying get more info from our website? Ettwein, Josh wrote: Heh.. That's exactly what I was just thinking. Wow...where do I sign up? :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 9:28 AM To: Flashcoders mailing list Subject: RE: [Flashcoders] Littleloud: Flash Developer Position but you really shouldn't have had any problem finding that out by looking at our website. And these are the nice people you want to work for. :) Jason Merrill Bank of America Learning Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
There is a bit of an anomaly with importing classes... For example you have 3 classes. Let's call them FirstClass, SecondClass and ThirdClass. Within FirstClass you import and create an instance of SecondClass and within SecondClass you import and create an instance of ThirdClass, creating a chain. On the main timeline of the fla, you import FirstClass, but don't create an instance of it. Because you didn't create an instance of it, rightfully it is not compiled. But, both SecondClass AND ThirdClass are compiled. You can check it either by file size or by clicking Debug--List Variables in the player window. Most likely because there is an instance of SecondClass created within FirstClass and an instance of ThirdClass created within SecondClass. It would make sense though that because an Instance of FirstClass was not created, that the compiler should just stop right there, but that isn't the case. Perhaps that's why there is the flaName_exclude.xml trick, but even then you have to explicitly exclude each class. It's not really a trick, but may be a little known concept. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Stearns Sent: Thursday, May 25, 2006 2:36 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? import in flash is only used to save you some typing. when you use import com.package.Class; the class is *not* included in the swf until you reference that class in your code somewhere. like var blah:Class; you don't have to use import, you can also use: var blah:com.package.Class; and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class' it's just a typing shortcut. On May 25, 2006, at 2:01 PM, j.c.wichman wrote: Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript
RE: [Flashcoders] OOP 101: Is import really necessary?
Adding...Importing it as a package does properly exclude the classes. From my example, obviously why import a class and not use it, but I'm trying to understand the logic of the compiler. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Booth Sent: Thursday, May 25, 2006 3:17 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] OOP 101: Is import really necessary? There is a bit of an anomaly with importing classes... For example you have 3 classes. Let's call them FirstClass, SecondClass and ThirdClass. Within FirstClass you import and create an instance of SecondClass and within SecondClass you import and create an instance of ThirdClass, creating a chain. On the main timeline of the fla, you import FirstClass, but don't create an instance of it. Because you didn't create an instance of it, rightfully it is not compiled. But, both SecondClass AND ThirdClass are compiled. You can check it either by file size or by clicking Debug--List Variables in the player window. Most likely because there is an instance of SecondClass created within FirstClass and an instance of ThirdClass created within SecondClass. It would make sense though that because an Instance of FirstClass was not created, that the compiler should just stop right there, but that isn't the case. Perhaps that's why there is the flaName_exclude.xml trick, but even then you have to explicitly exclude each class. It's not really a trick, but may be a little known concept. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Stearns Sent: Thursday, May 25, 2006 2:36 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? import in flash is only used to save you some typing. when you use import com.package.Class; the class is *not* included in the swf until you reference that class in your code somewhere. like var blah:Class; you don't have to use import, you can also use: var blah:com.package.Class; and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class' it's just a typing shortcut. On May 25, 2006, at 2:01 PM, j.c.wichman wrote: Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need
RE: [Flashcoders] OOP 101: Is import really necessary?
It will include them, unless of course you exclude each one of them using the excludeAssets xml file. This file over-rides everything. Even if you instantiate the class, it will be excluded. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryanm Sent: Thursday, May 25, 2006 4:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Then how do you explain my results? Because some of those classes instantiate other classes (in the UIObject hierarchy), so those classes are compiled even though you didn't instantiate the first class. Importing *any* of the MM UI components will instantiate all kinds of lower-level classes, causing the entire UIObject hierarchy to be compiled even if you never use the class you actually imported. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com