this site made with datapod, hosted by a2hosting, part of tanguay.info
Home
Edward's Web Developer Site
Windows, Linux, AJAX, Ruby, Python, Java, CSS, XML, PHP5, Excel VBA, MySQL, C#, Perl, Flash, EVERYTHING...
Search Entire Site:
e.g. php array
Questions
Question
question
WINDOWS XP QUESTION - added on August 31, 2007
Is there anything like a Windows Explorer type application with Firefox-like tabs and the CTRL-T tab concept? Would be nice. 
Alex: Try the FreeCommander
arrow pointing right
Edward: Looks cool, thanks.
arrow pointing right
reply
post comment or question
Question
question
ECLIPSE QUESTION - added on September 6, 2007
Is there a hotkey in Eclipse that can put in a timestamp like this: 2007-09-15 15:31:01 ? 
post comment or question
Question
question
.NET 3.0 QUESTION - added on September 29, 2007
How is .NET 3.0 the old WinFX, I thought WinFX was mainly the file system that was supposed to be built into Vista? 
Karthik: I am working in .net 1.1. Web application using asp.net and vb.net. I want to read an excel file from awebsite and save the datas into my sql database. My input is the URL of the excel file. Can u please guide me. reply
post comment or question
Question
question
FLEX QUESTION - added on October 4, 2007
Is there an easy way to rename all of your package paths if you have, say, 100 classes in "game/util" and you want to move them to "game/tools"? 
guerkan: this has to be handled by a refactoring tool. but the one in flex isn't handling it. A new version of flex builder seems to be out. There is no filepackage and classpackage correlation anymore. You can more your classes into an other file folder but they will remain in the same classpackage before you rename the package name in the class file reply
post comment or question
Question
question
FLEX DESIGN QUESTION - added on October 4, 2007
In the Bruce Lee project, when you draw the background you do createBuffers(), what is going on here, I understand these are used to switch between various animations of the play figure to make him move smoothly, is that right? 
guerkan: whole package display is rewritten now. but the concept still exists: - a buffer is an image i can add into the flex display list. then it will be shown in the browser. - we can draw smaller images (player, enemy, items etc) into a buffer - for animation, the whole images has to be recreated each frame. That means, redrawing the background and redrawing the smaller images. For optimization, the buffer keeps a list of all painted smaller images. This list of rectangles is used in the next frame for erasing the smaller images and redrawing new ones. The erasing is done by drawing parts of the huge background image into the buffer. The parts are determined from the list of smaller images drawn a frame before. - for flicker free drawing a doublebuffering method is used. The class DisplayBuffer holds two Buffers. One for drawing and the other one for displaying. In each frame the buffers are switched, where the buffer drawn before gets the displayed buffer now. I am not sure if this is an optimal solution. An other solution is to add each smaller image into the flex display list too. This would move all drawing into the flash runtime. Then the game code is just for changing the position of the smaller images in the flex display list
arrow pointing right
Edward: The buffer concept makes sense theoretically and I'm continuing to step through the code until I get the big picture of this application. One of the things I have to keep reminding myself of as I get into this application code is that it is not a website. I have pretty much always programmed websites and so for me there is never state, or at least if you need state it is an exception to the norm and you store it in a session variable and you have to be careful that you don't store too much in state, etc. In application programming such as Flex state is all around you, it is the norm, every variable you store stays there and will never go away. The concept of "page hits" and "server roundtrips" is gone. And you don't have to do any AJAX backflips to emulate it: state is just always there. This concept and the concept of the event model (e.g. you start loading an XML file and then go on processing while the XML file is not loaded yet, and only when it is loaded does it fire an event to start processes that use the data) are the two hardest things for me to get over as I switch from classic web programming to application programming.
arrow pointing right
guerkan: i think we have to differ two state types; persistent state and memory state. In flex we can work on the memory state which is present all the time. We can structure the memory state with classes and objects. This gives us a good link between our programming language and the memory state. Things starts getting complicated when we want to save data onto disk in flex or bringing persistent state from disk into the memory state of flex. Two types of forces makes it complicated in flex to close the gap between this two types of states. The first force is the slowness of the persistent state. We can't say in flex "load the data and work on them" in the same method call. This is due to the second force: response time of the user interface. That means, while doing one thing - loading data - flex can't do an other thing - getting user input and doing the presentation. This is one of the problems we encounter in real-time-systems like flex. We can use the flex event model to overcome this problem of response time. In that model, we start initiating loading of data and doing other work mean while (going back to the runtime and letting him do the presentation and input controlling). When flex is ready with loading, our code gets triggered again. Now we have just a few milliseconds doing work again. Otherwise the user interface (browser) would not response any more, because the runtime is busy running our code. A real-time-system is forced to use the faster memory state, otherwise it would loose too much processing time by accessing a persistent disk state. In standard web development (php, jsp), we are using business software. Here the requirements are unlike from a real-time-system. The business software should be able to response to a huge amount of requests from remote clients running on different systems. The fact of not having any state in the business software makes it more easy to handle the huge amount of requests. But no software can work without any state, so the state of a business software component is our request. Sometimes the state is send back to the client as cookies. Newer application server afford the concept of sessions where the state is kept on the server side for the same client. All types of state handling in the business software can be seen as a pesistent state (except session handling). In one scenario data is send to the disk and in the other one it is send to the client. Once the data is held by the disk and once it is held by the client. The persistent state handling is slow for a real-time-system, but good for business software. If the server breaks or any clients break, we can recover the state and keep on working. This is different in the flex game. If the client breaks, the user has to start in the first level again. In this conceptual view, ajax is getting the technology for closing the gap between a real-time-system and the business software. Where the browser keeps the memory state (dom model), makes the presentation and our code handles the user interaction. For streaming in new data from the persistent state to the memory state, we are using ajax. It's just for triggering the loading. Then we are going back to the browser and waiting to be informed by the browser, when the data is in memory state already. It's like flex, isn't it?
arrow pointing right
reply
post comment or question
Question
question
FLEX DESIGN QUESTION - added on October 10, 2007
In the main file "BruceLee.mxml" I see you import a number of mx... modules, yet I find it surprising that when I press F3 on e.g. "mx.managers.SystemManager" that I can go to "SystemManager.as" as if it is a class in the application, yet it is an internal class from Adobe, but why am I able to look at it, where it is saved (I don't find it in my "Flex Navigator" on the left? However when I try to navigate to other modules, e.g. "mx.modules.ModuleBase" it says "source could not be found". Furthermore when I type in junk in these module files, it compiles fine, as if these files are simply copies of the internal system files for us to look at but not change. What is going on here, this is not how, e.g. ASP.NET works where you can do some reflection of the innerclasses but you don't get to see the CODE. 
guerkan: the mx classes seems to be open source. when you go to http://tools.assembla.com/flexsdk/browser you can browse all class sources there reply
post comment or question
Question
question
FLEX DESIGN QUESTION - added on October 10, 2007
What is the procedure again to set up the BruceLee game, I deleted and recopied the /bin directories in Data and Scripting and now I get RSL Linking errors which starting BruceLee 
guerkan: When Project BruceLee starts, it loads Scripting.swf and Data.swf from the other Projects. These files has to be copied into the bin folder of the Project BruceLee. We must instruct FlexBuilder to copy these files automaticaly into the bin folder. This can be done by going to Project->Properties->FlexBuilderPath->LibraryPath and click "AddProject". Now expand the the newly added library node in "build path libraries". Double click the "RSL URL" node. The dialog "Library path item options" opens. Select "Link Type" to be "RSL". Select "Digest" for "Verification" and click the "Add" button there. A new dialog "Edit RSL deployment path" opens. Click "OK" leaving the default values. You should see the filename of the swf file in the "deployment path" gridview. Click "OK" for the "library path item options" dialog, too. Do the same procedure "Add Project" with the other library and click "OK" in the "Properties for BruceLee" dialog. The project "BruceLee" is ready configured now. But the library project "Scripting" uses classes from the project "Data". Go to the properties of the "Scripting" Project and select "Flex library build path". Select the tab "Library path" and click "Add Project". Add the "Data" Project into the "Scripting" Project. Expand the "Data" node in "build path libraries". Double click "Link type" and select "External". Now the scripting project knows all classes in the data project without being merged into one tall library together. Normaly when creating a library project, the library doesn't put the class files automaticaly into the swf. To select these classes you must go into the properties dialog of the library project and select "Flex Library Build Path". In the tab "Classes" you can check all classes that the swf of the library should contain. reply
post comment or question
Question
question
FLEX QUESTION - added on October 10, 2007
What is the different between a New Flex Project and a New MXML Application? 
guerkan: it should be the same. one is with precreated mxml file and the other one not, i presume. reply
post comment or question
Question
question
FLEX QUESTION - added on October 10, 2007
Why doesn't CTRL-H work in FlexBuilder? How can I search all files in my workspace? 
post comment or question
Question
question
FLEX DESIGN QUESTION - added on October 10, 2007
Why does BruceLee.mxml have an Application tag in it but mxml files that I create have a mx:Application tag? Is there a reason why you took the mx: namespace off? 
guerkan: with mx namespace on: <Application xmlns:mx="http://www.adobe.com/2006/mxml" without mx namespace: <Application xmlns="http://www.adobe.com/2006/mxml" xmlns without any :<namespaceprefix> defines a standard namespace for all elements without any prefix. I'll switch it on again later when i become more a friend of xml-tag coding. At the moment, the less characters like ,;.<" is there, the more i like it :-) reply
post comment or question
Question
question
FLEX QUESTION - added on October 10, 2007
When I am in a class and want to change a control, how do I address it, e.g. I have a TextArea control that is called "content" and I want to say something like Application.application.stage.Controls("content").Text = "new text", how do I do this? 
guerkan: i think, you have to use getChildByName(string). Look at live docs here the stage class extends DisplayObjectContainer. Here is a small description of the display list: reply
post comment or question
Question
question
FLEX QUESTION - added on October 10, 2007
In FlexBuilder there are no longer any Code Templates (the only context is SQL) so how do you make code completion with CTRL-space? 
post comment or question
Question
question
ACTIONSCRIPT 3.0 QUESTION - added on October 10, 2007
Is there an ArrayList type in ActionScript 3.0, similar to in C# and Java? I don't want to have to deal with keeping track of the index count, just want to add things to a collection. 
guerkan: Array in as3 is an ArrayList. You can add objects with push() and remove objects with splice(). Don't forget: in actionscript3 you can extend objects at runtime with new features. You don't have to define them in class before. Example: obj["mymethod"] = function():void { trace("hello"); }; obj.mymethod(); Object is behaving like an hashtable here. And function is behaving like an ordinary object. Example: var obj:Object = new Object(); obj["name"] = 10; obj[2] = "hello"; Here, the index parameter can be a string or can be an integer. Object now looks like an indexed array. The class Array is derived from the class Object. So it inherits all the array and hashtable functionality from Object. Array has just some additinal method declarations like push(), splice(), forEach(). Some syntactical sugar is build in the language: var a:Array = [1, "A", "B"]; Creates an array object by definition.
arrow pointing right
Edward: nice, thanks, here is a quick example of array as arraylist, need to experiment around with the foreach as well (check out this blog about how it is undocumented so far, some other interesting stuff, this is kind of Ruby like
arrow pointing right
reply
classPath question: short question i need directions on setting a ActionScript 3.0 classpath thx in advance reply
post comment or question
Question
question
FLEX QUESTION - added on October 11, 2007
How do you solve the problem that a flex/flash application does not recognize keyboard presses until the user first clicks inside the browser, i.e. on the stage, which then gives the application focus? Is there a way to "force the focus" onto the stage when the application starts? 
post comment or question
Question
question
FLEX QUESTION - added on October 13, 2007
How do I dynamically change the color of a button in code? In design when I change the color .fillColors and .fillAlpha are set, but these aren't properties of the button in ActionScript. 
post comment or question
Question
question
FLEX QUESTION - added on October 27, 2007
When programming in Flex/ActionScript I often copy in some code or use some object and then run but get an error e.g. "Access of undefined property LineScaleMode", ok, so then starts the great treasure hunt of what I need to import in order for this thing to work, after 5-10 minutes I happen upon "import flash.display.LineScaleMode", include this at the top of my package, and things work. But I am thinking, shouldn't this be automatic? This always baffled me about import statements in .NET as well, I mean if the compiler knows what library it was looking for to be able to compile "LineScaleMode" why doesn't he just TELL me this and suggest the line "import flash.display.LineScaleMode" to put at the top of the package, or, better yet, just INSERT this line for me and compile the application and run it? Can't it do that? And if not, what is the fastest way for me to look these kinds of things up, e.g. some kind of table "when you use ______, you need to the include statement _________". 
post comment or question
Question
question
FLEX QUESTION - added on February 10, 2008
Debugging an actionscript projectt, when I click to make a breakpoint I get a dot with a slash through it and I can't debug, why is that? 
Custom Images/item Types/questions/debug Slash.png
post comment or question
Question
question
FLEX QUESTION - added on February 10, 2008
How can it be that in a class constructor in an actionscript project that we have a line "init()" without an ending semicolon and it causes no error? 
Custom Images/item Types/questions/init No Error.png
post comment or question
Question
question
ACTIONSCRIPT 3.0 QUESTION - added on February 10, 2008
What's up with this syntax, to get the title out of the XML object you use two periods: xml..title. If you only use one, you get an error. 
Custom Images/item Types/questions/xml Double Dot.png
post comment or question
Question
question
FLEX QUESTION - added on February 10, 2008
What I want to do is (1) load data from a text file, and then (2) use this data. However, in ActionScript 3.0 it tries to use the data before it has been loaded (!), as the debugging output shows below. How can I change the following code so that it (1) first loads the data, and (2) then uses the data (like, say, you do in in PHP or C# or Java, etc.) Here is the source code as ActionScript Project that I created in FlexBuilder 2: download source code 
Custom Images/item Types/questions/loading Issue.png
dangerOp: It's not "using" the data before it loads it, it simply creates the objects asynchronously. After declaring the XmlData object, it continues in the loader() method, while the new threads start on their own and they happen to complete loading after the other trace calls in loader(). Hope that makes sense.
arrow pointing right
Edward: Thanks, this took me awhile to grok. Here is a little application that I got to work that does what you say, it loads the data from a text file and waits for it to load before displaying etc., this is a difficult concept to understand in Flex if you have been doing database-backed web programming for years. Here is the code the for that application for all who want to see a simple example working to pick apart and understand this.
arrow pointing right
reply
post comment or question
Question
question
FLEX QUESTION - added on February 12, 2008
So in trying to solve the problem of not being able to get ActionScript to wait for the text file to load, I created a LoadManager which adds an event listener for the ENTER_FRAME event, and I just wanted to trace out some text and wanted to run it and see that the text is being output every frame (e.g. a couple time every second). However, I get the error in the add event listenener line that there is a null object. Does it mean the application object? How can I fix this so that I have a loop going where I can constantly check if my file has been loaded? 
Custom Images/item Types/questions/load Manager.png
post comment or question
Question
question
FLEX QUESTION - added on February 13, 2008
How can I get my LoadManager to communicate with my MXML page? 
So now I tried two ways to fix the Flex loading issue. First, I made a button which (1) loads the text from the text file and (2) inserts it into the text attribute of a label field, but: same thing, it gets goes to get the text with XmlData but then comes back empty-handed and puts an empty string in the label AFTER WHICH the text is then loaded in XmlData, so, same issue there. So I then put Internal.LoadManager.Start() in the creationComplete() attribute of the Application tag, and inside the LoadManager it attaches the function enterFrame to the ENTER_FRAME event and by tracing I am able to see that the data from the text file is retrieved every second, BUT the label in my application remains empty (!). The issue is that I can load the data all I want inside the LoadManager but how do I access this value from my application? It is as if I have two application running, one which HAS my data and one which NEEDS my data but I can't get them to communicate. Do I need to set some kind of global variable or have some Singleton somewhere which holds the data which my LoadManager loads into and my application reads? Here you can download the source code to see this mystifying issue in action, perhaps you can help me solve it! 
Custom Images/item Types/questions/load Issue2.png
post comment or question
This site was made with Datapod.