Re: [flexcoders] Flash Builder unable to debug (missing flash player)
Ah, sorry, it seems like the problem is I'm on x86_64, and there is no standalone debugger for that... how strange... Anyways, does anyone have an idea on how to make 32-bit standalone debugger work on 64 bit Linux?
[flexcoders] Flash Builder unable to debug (missing flash player)
When I hit F11 I'm getting this message: "File not found: flashplayer". No more explanations given. Any ideas of what went wrong? (I'm on Linux, and of course I have flash player...)
Re: [flexcoders] Re: Speeding project compilation
Ant generally requires only JRE (some extensions may require other things, but, if you have Flex / Flash Builder, chances are you already have JRE).
Re: [flexcoders] Speeding project compilation
I believe it's somewhere in the context menu of the file in the project view. It should say something like "Copy to output folder". Sorry, I don't have FB at this machine atm. Could be the assets weren't embedded originally and this setting "suck" to them since they were loaded at runtime?
Re: [flexcoders] Re: Encoding XML Character Entity References *properly*
Both your variants are... strange... you use literal and create a new object by passing it an already created object... var xml:XML = {bar}; This is how you'd normally do it. E4X uses couple of special opcodes allocated only for it, so, my guess that using E4X expressions for constructing XMLs should be the right way to do things. If you parse XML at runtime, as opposed to the first way you bypass the compiler XML validation, which is in generall a not smart thing to do... So, my guess that either your test was somehow wrong, or, even if it was precise, then the benefit of having compile time verification of XML structure would overweight in the end. I don't believe the difference, even if not in favor of E4X may be that big to consider reproducing it "by hand".
Re: [flexcoders] Hi, how do I signal a Binding event from a class?
If you make the class bindable, the compiler will extend it from EventDispatcher, or implement IEventDispatcher, this means you can use all event dispatcher methods in that class. However, making a class bindable isn't the best coding practice, I'd rather do it by hand, it' be a more obvious code.
Re: [flexcoders] Re: flash builder: how to create an as3 project WITHOUT flex sdk
{sdk}/frameworks/libs/air look there for swc files. airglobal.swc is the must, all the rest are optional, or so I think.
Re: [flexcoders] Re: flash builder: how to create an as3 project WITHOUT flex sdk
You need to package the application using ADT, and launch it for testing using ADL. AIR runtime is different from player and it has more classes, one of them is NativeApplication. Player doesn't have that, so, you cannot run the SWF compiled for AIR in the player because some classes won't be there. http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7fd6.html here's a guide on how to do that.
Re: [flexcoders] Re: flash builder: how to create an as3 project WITHOUT flex sdk
The definition for Sprite is in playerglobals.swc. However, you are asking wrong question. You cannot compile an AS3 project w/o SDK, or you would need at least an alternative compiler, and only one that exists is the one developed by SWFTools few years ago. But it's outdated now... so, technically, for AS3 Flex SDK is your only option. On the other hand, having other libraries in your path won't harm because they aren't embedded in your project, unless you explicitly embed them.
Re: [flexcoders] Re: AMFPHP Security?
Exactly, what Gk said. You can make it difficult to forge the data on client, but you cannot 100% prevent it from being "cracked", so, better, keep the score on the server.
Re: [flexcoders] Accessing repeating components through ActionScript
var event:Event = arguments[0] as Event; this.labels.push(event.currentTarget); * Sorry, incorrect opening and closing tags.
Re: [flexcoders] Accessing repeating components through ActionScript
@id must be a simple identifier, it's the same as variable name in AS3. What you can do though is like this: add creationComplete handler to the repeating components and collect them into vector / array / dictionary / etc, whatever suites you better. Something like this: var event:Event = arguments[0] as Event; this.labels.push(event.currentTarget);
Re: [flexcoders] Re: After importing file using FileReference focus is lost
http://bugs.adobe.com/jira/secure/QuickSearch.jspa By the way, while you are on it... sometimes the window opened by FileReference isn't modal, Flash will also not dispatch key release events after the dialog box appears... I hadn't have the time to post these :) (Make sure it wasn't posted before)
Re: [flexcoders] AMFPHP Security?
You shouldn't send sensitive data to begin with, you need to calculate it on server and call saveHighScore() without parameters, so only server will know what the score was. No matter what your client technology is, the client cannot be trusted.
Re: [flexcoders] link button from a rss
Hey, np, sleep more, work less -> profit! ;)
Re: [flexcoders] link button from a rss
Claudiu: That's exactly what my code does... Gustavo: Read what the error says. You are trying to coerce String to URLRequest. Of course you cannot do it. The code from the first example should work. If it didn't, what was the problem?
Re: [flexcoders] link button from a rss
Remove the single quotes and put the brackets around the entire expression. You cannot bind to function arguments, not in that way for sure. Better yet, don't use binding: navigateToURL(new URLRequest(data.link)); Something like this.
Re: [flexcoders] How to declare a Complex Type : String + int-
You cannot really have custom types in AS3 or any other ECMAScript language. I'd go for a class with 2 fields for integer and string.
Re: [flexcoders] Aspects of functional programming in ActionScript
Despite this whole FP issue coming back into fashion in the last years, there's really no use for that in ECMAScript-like languages. Every piece of code you can write using nested functions can be rewritten in a way that no nested functions will be used and the program will work better. I'm not sure where would you need immutable objects, except date and string. I'm not sure what kind of impact you were afraid of re' constants, but, sure the constant which is not static is initialized as many times as it's scope is initialized: function foo():void { const bar:int = 100; } bar initialized as many times as often you call foo(). class Foo { private const bar:int = 100; } bar is initialized as many times as often you create new Foo. If you need an example of intensive use of "closures" in AS3, look into binding mechanism in Flex. It uses them a lot, and this is why it is bad. Another example - Googlemaps, which is just another example of a lame code. It is confusing to think that big corporation with many years of programming experience would produce crappy code. I cannot tell why did this happen exactly... but you know, lots of girls wear high heels, even though it's one hell uncomfortable :)
Re: [flexcoders] Flex 4.1 , automation_spark.swc and OSMF 1.o issues
I've compiled from trunk (it has revision 17228), and the DimensionEvent is still there, in the osfm.swc, check the catalog.xml line 957.
Re: [flexcoders] Flex 4.1 , automation_spark.swc and OSMF 1.o issues
The one that comes with this SDK: 4.0.0.14159 (this is what was released with Flash Builder 4).
Re: [flexcoders] Flex 4.1 , automation_spark.swc and OSMF 1.o issues
OK, I've just checked and DimensionEvent is compiled into osmf.swc, so, my guess is that you need to include that library too. The dependency is made through VideoDisplay spark component, however, you cannot avoid making that dependency, it's introduced in the generated code.
Re: [flexcoders] Flex 4.1 , automation_spark.swc and OSMF 1.o issues
Did you try to change the order they are included?
Re: [flexcoders] How to display a LARGE dataset of images
Just have one Loader and one Bitmap (or probably 16 or about that number in the second case). When you handle the load complete you get the loader's content and draw it to the bitmapdata, remember where it was the last time, load next image, draw again and so on... However it will work, I would imagine that it will take some time to load all the images... I still don't understand why would anyone want to view so many images simultaneously... Can you maybe convince the customer that seeing 2 images at once isn't the best user experience? I mean, what will they see on an image 10x10? you won't be even able to tell if that's a man portrait or a flowers pot...
Re: [flexcoders] How to display a LARGE dataset of images
Load them and draw to a single bitmapdata and then unload? Anyways, just out of curiosity, what kind of application would need to display that many images at once?
Re: [flexcoders] Air loading Swf loading image
Julian. That's really not so relevant... if you embed an image, the image goes inside SWF, when you load it, it remains outside of the SWF, just lives somewhere on the HD. When loading, the way you load a SWF may affect the how the player will resolve relative URLs. I believe, that if the SWF is loaded into the same application domain as the loading SWF (especially, if that SWF was loaded using Loader.loadBytes()), there's no reason to think that URLs should be resolved relatively to the loaded SWF original domain simply because it may not even have one.
Re: [flexcoders] Air loading Swf loading image
When you embed an image, the path is resolved relative to the file, where you put the Embed meta. If you load it, the path is resolved relatively to the file that loads an image.
Re: [flexcoders] Air App loads swf loads image
If I can guess, then, probably you've loaded the SWF into the same domain, and if the URLs were relative to the loaded SWF they become relative to the loading SWF. Does it make sense?
Re: [flexcoders] Problem with adobe call
That's not a call, that's an import. You are missing sources or SWC in your project.
Re: [flexcoders] How to compile single project as both Desktop and WEB
Maybe someone will correct me... but I think that the antTask from the SDK doesn't cache do the iterative compilation, so that's why it may be slower. This may not be the best technique, but I build with Ant in a way, I set it as an alternative builder... so, it's the same as running the Ant script from the command line basically. However, I don't think this will have any effect on speed... Generally, I don't think there is a way to make the compiler think that it should cache data from one compilation to reuse it in another compilation, if that's not the same project... But, again, I'm not really sure about it. Well, if the compilation speed matters, I can only think of some general advises, like, putting more code into SWCs, removing all [Embed] and @Embed() tags from the code, avoiding MXML in general... Compiling separate classes for testing rather than rebuilding the entire project (in fact, I build the entire project only few times a day, the rest of the time I'd work on a single class, or a small set of classes)...
Re: [flexcoders] How to compile single project as both Desktop and WEB
You can do that with Ant. Just compile the same project twice with different settings.
Re: [flexcoders] About baselistdata class issue
Do you expect value.item to be an XML with a single root node? If so, trace() isn't going to print out the contents of that node. Use trace(value.item.toXMLString()) instead.
Re: [flexcoders] How to split a String on spaces but including Quoted Phrases?
Ouch, actually, it has a flaw, but I'm not sure you need a fix for that, but it's possible to fix it, if you want. It only checks for the double quotes, when it checks for the non-quoted words, but it checks for both single and double quoted groups of words. If you need both single and double quotes however, the expression is going to be a tid bit longer... but if you don't need, then it'd be shorter in fact: /(".*[^"]")|(\s[^\s"]+(?!\s"))/g
Re: [flexcoders] How to split a String on spaces but including Quoted Phrases?
Sorry to chum in :) var re:RegExp = /(("|').*(?=\2)\2)|(\s[^\s"]+(?!\s"))/g; var text:String = .toString(); var result:Object; while (result = re.exec(text)) { trace(result[0]); }
Re: [flexcoders] garbage collection question
1. Using weak references is the last thing you should do, whenever possible you should avoid it. By doing so you leave all means of control of the object, and if the object has some kind of behavior that will keep it "alive", you won't be able to delete it ever (example, the *deleted* object did not close LocalConnection). It is not possible to conclude from what you describe whether objects will be removed or not. The objects will be removed when there will be no reference to the "roots". "Roots" are local variables, or field initializers. These are either persistent or temporary, local variables would be an example of temporary "roots". Imagine this life span of an object: public var persistent:Object; public var anotherProperty:Object; public var revealPresense:Dictionary = new Dictionary(true); public function DocumentClass() { super(); var temporary:Object = new Object(); // the object created, put into the heap, bound to the temporary toot persistent = temporary; // the object is in heap, now referenced by two variables. } // temporary variable is destroyed, now the object is only referenced by persistent root. public function anotherMethod():void { anotherProperty = persistent; // the object is still in heap, but now has two persistent roots. persistent = null; // the object is still not eligible for GC, it is referenced by persistent root. revealPresense[anotherProperty] = true; // let's store a weak reference and observe the object deletion. anotherProperty = null; // the object is no longer referenced, but may exist for some time. for (var obj:Object in revealPresense) trace( obj ); // it may be still here... setInterval(checkPresense, 1); } public function checkPresense():void { for (var obj:Object in revealPresense) trace( obj ); // it may be still here... }
Re: [flexcoders] Sorting problem after grouping
Hi. Did you know that you can compare stings using operators > and < as well as == ? Anyways, I'd usually just do the sorting on source and reset the view. I think that sorting of the view is just strange and the way it is implemented is convoluted... I could never understand why anyone would want to use it... Sorry to not really answer your question.
Re: [flexcoders] e4x and XML in Web Service Calls
I think that E4X is the default for the WebService. E4X isn't exactly a format... it's a language extension added to ECMAScript, just like regular expressions language in many other languages, or LinQ in .NET. Essentially, when you did this: myDataXML = XML(evt.result); You have already "converted" it to E4X, (the alternative handling of XMLs is the XMLDocument class). XML and XMLList classes allow using E4X expressions on them, XMLDocument doesn't. If you have any specific problem compiling an expression, please post it, so far all that you have posted looks OK.
Re: [flexcoders] error checking FileStream. readObject?
Just use try-catch, I don't think there's anything special for this case.
Re: [flexcoders] How to retrieve "name" property of file object in ArrayCollection
I haven't tried it, but my guess is that File either cannot be extended, or there may be some other limitations related to this kind of classes. I'd go for composition then, that is I'd create a class extending EventDispatcher and expose the name property through it's getter (which you can make bindable). Or, better yet, I would avoid using bindable whatsoever. It is OK for mock-ups and quick demos, but really, there's 0 benefits when it comes to the production code.
Re: [flexcoders] Re: Flex Affecting Web Server Memory?
Is firing the server team an option? I am running IIS and Apache on my machine (home dualcore Intell PC purchased 4 years ago) as well as MySQL server and many other applications. I have only 2GB of RAM available - I can still see SWFs, no problem. (And I can play recent 3D shooter games while doing it). This all said, I don't know what did this development team measure, but I would be afraid to give them measuring tools in the future. ;) PS. Sorry, I didn't mean to be mean, I was just reading a lot of Dilbert lately :P
Re: [flexcoders] Re: textInput databinding
Hi, I think square brackets may be an obstacle here. I think they didn't always work, or maybe they don't work even now? Anyways, if that's an array collection, you'd better use getItemAt() and if that's an XML or XMLList, you'd be better of with the XML / XMLList methods corresponding to what you wanted to do (like child(), children() and so on). Also, "data" is often times used in the framework for instances of Object, which is not bindable because it is not an IEvetnDispatcher. Check that option too.
Re: [flexcoders] Re: textInput databinding
That won't also work because there's a redundant dot before the bracket. ;)
Re: [flexcoders] Loaded SWF loses nested child instance name
Nope, not really, what happens is like this: the document class is a sprite, which has some code in it, which is called first in the application and this class is automatically added to stage, if it is not loaded. However, if the SWF is loaded, then the class isn't automatically added to stage, however, the constructor is executed before that. Now, Flash will create variables and assign the library instances to those variables if you put those instances on the stage, however, if you turn off the "automatically declare stage instances", Flash will not create the corresponding variables for them (and so you will get an option to define them yourself in your class. You don't need to initialize those variables to anything, Flash will initialize them to the timeline placed instances of the same name.
Re: [flexcoders] Flex and "Socket policy file"?
Security files are served from the socket on the server side. You don't need to change flex code for that. Well, they are not precisely files, they are the content of the security file being sent over the socket in response to . For more info see this: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
Re: [flexcoders] Security with HTML from External Site
Hm... this is a good point... however, I think that you can secure yourself by parsing tags in that text and see if they don't dispatch any events that your SWF may be listening to. But, the worst thing that can happen is that the anchor in the text will call some handler inside your application (that is execute your own code, not the foreign code), which shouldn't be really dangerous, but, that's for you to tell :)
Re: [flexcoders] Loaded SWF loses nested child instance name
Well, that wasn't a good idea from the start, as instance name isn't a reliable identification (you can assign two identical names to different instances and that will compile, while the second instance will not be available). What I usually do in such case is: I prepare the class with the fields it should have, give it to designer and explain hot to link their library items to that class, and then when I compile, I use my own version of that class with the functionality added, this way we (me and designer) can work on the same class and I don't have problems using it in my project. Ah, important to note, this approach requires that the designer turn off the "automatically declare stage instances" in publish settings.
Re: [flexcoders] Setting width/height not affecting visual display?
These properties may be overridden. My gut feeling says there should be something like commitProperties / validate or some similar method to apply all changes to the changed display object.
Re: [flexcoders] Flex print Without Dialog Box ?
Hi. I remember that MDM Zinc offered this (only for texts, not graphics) at some point (of course, only for desktop applications). Other than that, I'd say that if it is a browser based application, it should not be possible, and if it's a desktop, you should be looking into making some custom wrapper + send it serialized data, like, maybe PDF or try to generate PS files... both ways it looks like rather complex task.
Re: [flexcoders] Re: Decoding output of Flex Base64encoder in C++
Hey... HaXe compiles to CPP... all you need is just to compile it to flash and CPP, that's it... well, almost, flash memory uses big endians, so you may want to remove the flipping of the first and third bytes in decode function, and, of course, don't use Memory.select() when compiling to CPP (that's flash specific)... I think I'll update that version to compile to CPP w/o extra editing.
Re: [flexcoders] Decoding output of Flex Base64encoder in C++
Adobe encoder can conditionally ad linebreaks, that is all the difference between all RFCs basically. But, honestly, Base64 is a very simple algorithm, if you are not concerned about performance, let's say and you had started writing it at the time you've posted you would have a dozen of different implementations by now. It is really really simple.
Re: [flexcoders] Decoding output of Flex Base64encoder in C++
http://blooddy.by/en/ I'd recommend this library instead, it is much faster then the one from the SDK. I had taken part in testing it, but I'm not the author. I had written however Base64 implementation (very similar to the one in the library), and it's fairly basic. You can find it here if you want: http://code.google.com/p/e4xu/source/browse/trunk/haxe/src/org/wvxvws/encoding/Base64.hx It is written in HaXe, but it compiles to ActionScript bytecode (it is easier to use memory opcodes this way / in general the bytecode emitted by HaXe is more optimized) .
Re: [flexcoders] Re: navigateToURL
FileReference.save availability depends on the player version, the version of the SDK or Flex Builder doesn't affect that. Regarding JavaScript, I'd go for an iframe, which would load try to navigate to the URL to the file you want to load and then a script in the parent document that would check on an interval what happened to the iframe. I think that the solutions is tricky / complex to post the code, and I'm not sure which options are exactly available across different browsers.
Re: [flexcoders] navigateToURL
Use FileReference instead? Or call some JavaScript so it could call back to Flash?
Re: [flexcoders] line break?
["foo", "bar", "foobar"].join("\r");
Re: [flexcoders] My custom component doesn't hear my events
Events bubble up (from child to parent, but not the other way). You must explicitly dispatch a bubbling event in order for it to bubble (bubbling is expensive in terms of performance). SWIZ uses couple of different techniques to bind the dispatchers and listeners, one of those techniques is to add a handler to the capture phase of an event. This is by some weirdness of Flash Player event model, that all display objects dispatch events that have the capture phase, and if you add a handler for that phase globally, this handler will be called before the handlers added to target or bubbling phases. I see this as a bad practice, and would not encourage you to do so for many reasons, but it's to much for this question. I still think that adding handlers directly to the dispatchers is the best way to go about it. Whilst if you can do with the simple callbacks, it is even better. EventDispatcher offers a sort of abstraction level / common interface in order to make your work more consistent / easier to understand for other people, at the same time it adds some overhead. So, if the added overhead isn't important to you, and you want to work by the guidelines, then events are the way to go, but if performance is more important, then stick to plain callbacks.
Re: [flexcoders] Manually installing Flex SDK's to Flex Builder 3
$WORKSPACE/.metadata/plugins/org.eclipse.core.runtime/.settings/com.adobe.flexbuilder.project.prefs on my machine, I've found it using: # cd $WORKSPACE/.metadata # find . | xargs grep 'sdk' -sl was the first result for me, or maybe second. Best. Oleg
Re: [flexcoders] Alchemy with FP 10.1
Should work. Works for us anyway.
Re: [flexcoders] How to remove duplicate objects from an array of objects
Well, then my take would be this: since you are sending them from CF, you are probably using AMF, and since you do so, you can use strongly typed objects, and (again, I'm not sure but...) I think that strongly typed objects are written accordingly to their describeType - this means objects are going to be consistent when serialized. But, the thing with comparing serialized objects is more of a trick, then a really good design. I would go for some kind of equals():Boolean method for those objects and implement it in a way it would only compare the relevant data. Something more like this: class BusinessObject { public function equals(object:BusinessObject):Boolean { if (this.foo != object.foo) return false; if (this.bar != object.bar) return false; return true; } } This would cover all the cases, like when you want the objects to have only some unique properties, but other you don't mind. It will be also easier to maintain in the long run. This is an inherent problem of OO languages vs rrelational database languages, where the first implies that objects must have unique identity and the second believes that the objects that have all the same traits are the same. Of course this is not black and white, but it's a known problem. The equals-like method is probably the standard kind of solution to this problem, unless you can find some more optimized way to do it. There are more interesting things, for example, if you implement valueOf() method of an object in a way that it returns number or string, the implementors may be treated under certain circumstances as being of simple type, so, say and you have something like this: class BusinessObject { public function valueOf():Object { return int(this.foo + this.bar); } } Then you can cast BusinessObject to int and compare ints :) var bo0:BusinessObject = new BusinessObject(100, 200); var bo1:BusinessObject = new BusinessObject(100, 300); if (int(bo0) === int(bo1)) // objects are assumed equal. This approach may be more efficient if you cache the valueOf value in the BusinessObject so that when called it only returns the value.
Re: [flexcoders] How to remove duplicate objects from an array of objects
Woops, sorry, it appears that objects created using new Object syntax are sorted differently from objects created using literal... var o:Object = new Object(); o.bar = "345"; o.foo = "123"; var result:Array = this.removeDuplicates( [ { foo:"123", bar:"345" }, { foo:"123", bar:"345", foobar:"789" }, { foo:"123", bar:"347" }, { foo:"123", bar:345 }, { bar:"345", foo:"123" }, o ]); So, my code won't work in that case... well whoops...
Re: [flexcoders] How to remove duplicate objects from an array of objects
ObjectUtils sorts them on purpose, that's a bit different ;)
Re: [flexcoders] How to remove duplicate objects from an array of objects
Hey, you are welcome so far it works! :) I'm only afraid of the situation when properties are not written in the same order. To be honest, I need to read up the AMF specs to see if that was by chance, or was that the how AMF is supposed to work. (I tried to initialize the properties in different order, and delete and declare them again, and it seems like it works, however, who knows, it still may be by chance).
Re: [flexcoders] How to remove duplicate objects from an array of objects
Actually, here it is: package { import flash.display.Sprite; import flash.utils.ByteArray; /** * ... * @author wvxvw */ public class RemoveDuplicatesThroughByteArray extends Sprite { private var _patternA:ByteArray = new ByteArray(); private var _patternB:ByteArray = new ByteArray(); public function RemoveDuplicatesThroughByteArray() { super(); var result:Array = this.removeDuplicates( [ { foo:"123", bar:"345" }, { foo:"123", bar:"345", foobar:"789" }, { foo:"123", bar:"347" }, { foo:"123", bar:345 }, { bar:"345", foo:"123" } ]); this.dump(result); } private function dump(object:Object, depth:int = 0):void { var tabs:String = "\t\t\t\t\t\t\t\t\t\t".substr(0, depth - 10); for (var p:String in object) { trace(tabs, p, "=", object[p]); this.dump(object[p], depth + 1); } } private function removeDuplicates(array:Array):Array { this._patternB.clear(); this._patternB.length = 0; // If we write the whole thing ar once, the constants (such as strings // and numbers will be cached) // It looks like the properties are always written in the same // (reverse alphabetic) order. If you can prove this is wrong, // suppose the algorithm is not working! for each (var o:Object in array) this._patternB.writeObject(o); return array.filter(filterHelper); } private function filterHelper(object:Object, index:int, all:Array):Boolean { var bytes:ByteArray; var pos:int; var nextPos:int; var prevPos:int; var len:int = all.length; this._patternA.clear(); this._patternA.length = 0; this._patternA.writeObject(object); this._patternB.position = 0; while (pos <= index) { this._patternB.readObject(); pos++; } prevPos = this._patternB.position; main: while (pos < len) { this._patternB.position = prevPos; this._patternB.readObject(); nextPos = this._patternB.position; this._patternB.position = prevPos; this._patternA.position = 0; while (this._patternB.position < nextPos) { if (this._patternB.readUnsignedByte() !== this._patternA.readUnsignedByte()) { prevPos = nextPos; pos++; continue main; } } return false; } return true; } } }
Re: [flexcoders] How to remove duplicate objects from an array of objects
Duh! Gmail isn't the best place to write the code! :) var ba0:ByteArray = new ByteArray(); var ba1:ByteArray = new ByteArray(); var len:int; for ( ... ) { ba0.writeObject( ... ); ba1.writeObject( ... ); if (ba0.length !== ba1.length) // objects are different len = (ba0.length >>> 2) << 2; while (ba0.position < len) { if (ba0.readUnsignedInt() !== ba1.readUnsignedInt()) // objects are different } while (ba0.bytesAvailable) { if (ba0.readUnsignedByte() !== ba1.readUnsignedByte()) // objects are different } ba0.clear(); ba1.clear(); } Sorry :)
Re: [flexcoders] How to remove duplicate objects from an array of objects
var ba0:ByteArray = new ByteArray(); var ba1:ByteArray = new ByteArray(); var len:int; var tail:int; for ( ... ) { ba0.writeObject( ... ); ba1.writeObject( ... ); if (ba0.length !== ba1.length) // objects are different len = (ba0.length >>> 2) << 2; while (ba0.position < len) { if (ba0.readUnsignedInt() !== ba1.readUnsignedInt()) // objects are different } while (ba0.bytesAvailable) { if (ba0.readUnsignedByte() !== ba0.readUnsignedByte()) // objects are different } ba0.clear(); ba1.clear(); } Sorry, forgot the important thing :)
Re: [flexcoders] How to remove duplicate objects from an array of objects
You can do pretty well with only two ByteArrays, var ba0:ByteArray = new ByteArray(); var ba1:ByteArray = new ByteArray(); var len:int; var tail:int; for ( ... ) { ba0.writeObject( ... ); ba1.writeObject( ... ); if (ba0.length !== ba1.length) // objects are different len = (ba0.length >>> 2) << 2; while (ba0.position < len) { if (ba0.readUnsignedInt() !== ba1.readUnsignedInt()) // objects are different } while (ba0.bytesAvailable) { if (ba0.readUnsignedByte() !== ba0.readUnsignedByte()) // objects are different } } Or something along those lines.
Re: [flexcoders] How to remove duplicate objects from an array of objects
If those are simple dynamic objects you can write them to ByteArray and compare them, it will be faster than using ObjectUtils. Everything in AS, except for numeric types (but not Date), strings and booleans are references, Array.indexOf() uses strict equality (compares references), so even if there will be 1 and "1" indexOf will not treat them as same. But, most of the time this is what you want :) There's also Array.filter method, but it's slower then a simple loop. But may look somewhat prettier :)
Re: [flexcoders] Re: httpservice.lastresult completes but theres no data.
E4X always reduces the kind of nodes to because first is redundant and ambiguous. It is not clear whether the first kind is in fact two nodes - an element node with a child text node with the value of empty string, or is it a single element node. It is also longer than needed, if it is meant to be a single node. Well, the result was not missing, it's just that the way you printed it out was not good. XML.toString() prints the value of the node, not the structure. The value of the self closing node is "". However, toString() makes an exception if the node to be printed is the root node, it will print the structure of the node. I don't know what is the reason behind it.
Re: [flexcoders] Re: httpservice.lastresult completes but theres no data.
E4X prints the content of self closing nodes as an empty string (if it's not the root node). You may want to use toXMLString() to print the structure of the node.
Re: [flexcoders] How to remove duplicate objects from an array of objects
var i:int = myArray.length; var obj:Object; while (i--) { obj = myArray[i]; if (myArray.indexOf(obj) !== myArray.lastIndexOf(obj)) myArray.splice(i, 1); } Anything like this?
Re: [flexcoders] How to find the dpi of an image
DPI is a relative value... I mean, if you stretch the image, it will change... you can only find it out by comparing the number of pixels to the size of the rectangle you are going to put them in... Also, I'm afraid that given the runtime limitation on bitmapdata size, you will only be able to print (relatively) small images. As of version 9, the max size was 2880x2880 (if I remember it right), which would give you approximately 24x24 cm image, I think that in player 10 the max size is doubled. This would be OK to print on A4, but not bigger than that.
Re: [flexcoders] How to check if display object is visible to the user?
Something like: root.getRect(stage).intersects(clip.getRect(stage)) && clip.visible && clip.alpha I'm not sure about mask / clipRect / ColorMatrixFilter (they all may make the clip appear as invisible) + of course, there may be another display object on top of the clip, which you can roughly check by getObjectsUnderPoint() providing all 4 points of the rectangle generated from intersection of the clip and root rectangles, but this may not work most of the time, if clips aren't rectangles by themselves / are rotated etc...
Re: [flexcoders] Flex4 ASDOC Problems
Hi. Regarding that class, you are welcome to vote: http://bugs.adobe.com/jira/browse/SDK-26196 I didn't have those other problems you describe though, this is what our Ant task looks like for creating documentation: org.axiis.utils.NumericExpression org.openzoom.flash.utils.ExternalMouseWheel
Re: [flexcoders] Copying complex objects in ActionScript
I would rather implement a clone() function in the objects I want to clone (just like Event.clone() or XML.copy() or BitmapData.clone()). This gives you most control of what / how they are cloned with less side effects.
Re: [flexcoders] recursion help?
Actually, just for kicks: public function filterFolderFromPath(fullPath:String, children:Vector.):Folder { for each (var currentFolder:Folder in children) { if (currentFolder.path === fullPath) return currentFolder; else if (currentFolder.children.length) { currentFolder = this.filterFolderFromPath(fullPath, currentFolder.children); if (currentFolder) return currentFolder; } } return null; } you can save that local variable, but I wouldn't do it this way as it makes the code harder to read. :)
Re: [flexcoders] recursion help?
public function filterFolderFromPath(fullPath:String, children:Vector.):Folder { var foundChild:Folder; for each (var currentFolder:Folder in children) { if (currentFolder.path === fullPath) return currentFolder; else if (currentFolder.children.length) { foundChild = this.filterFolderFromPath(fullPath, currentFolder.children); if (foundChild) return foundChild; } } return foundChild; } Untested.
Re: [flexcoders] install AIR 2.5 SDK on Flash Builder (Flex 4) got error "Directory does not contain a Flex SDK"
Can you cd to the sdk root and then ls it and paste here the results? $ cd ~/flex/sdk $ ls (something like this) It sounds like you maybe didn't extract that into a proper folder / removed something accidentally. Another idea: - try compiling from command line, will it compile? If it won't (I'm afraid it won't), what error will it give? Best. Oleg
Re: [flexcoders] How to use flash player 10.1 API in Flex?
Check that you have minor player version specified and it is exactly "01". To check this compile with -dump-config and look for the player version there. It is also possible that your SDK doesn't have the required playerglobals.swc. If this is the case, download it from Adobe labs site. http://download.macromedia.com/pub/labs/flashplayer10/flashplayer10_globalswc.zip
[flexcoders] Flash Player 10.1 intermittently locks the log file
Hi, does anyone else experience the same thing? Having to close-open all browser windows only to be able to remove old traces from the log is extraordinarily annoying. This was a bug in AIR once ago, now it happens with both AIR and player.
Re: [flexcoders] Re: AS3 improvement feedback
No, that's different from type inference. Type inference preserves strict typing. It is most useful for anonymous classes or templates. That is the cases when it is preferred to let compiler to decide on the type of a variable. Think of retrieving values from the database and wanting to have strictly typed objects to be built based upon the query results. It is to boring to generate those classes by hand + it adds extra code to the application. It is better to leave it to compiler or the runtime to generate those things instead. Another case is when you are using a template, which the compiler will interpret differently every time, depending on how it is used. Using dynamic on the other hand is error prone and slow. Switching strict mode off is never a good idea. In fact, I think it would be only better if that option never existed.
Re: [flexcoders] AS3 improvement feedback
This is called type inference, it exists in several languages, C# would be one the most popular, HaXe would be the one most close to AS. @Rick Genter: It depends, most probably the compiler would give you an error/warning because of ambiguous code, and if not - would choose a common denominator for the two classes. One thing I agree though, this will not be backward compatible. On the other hand type inference is more then just a convenience feature. I hadn't seen much of it's been useful, but once it helped to resolve a very complicated situation.
Re: [flexcoders] Error while doing the Linked list demo using flex
Hi, they are in the repository in the same folder. I think that the better way to use it is like so: var list:DataList = DataList.fromArray([1, 2, 3], int); or var list:DataList = DataList.fromVector(new [1, 2, 3]);
Re: [flexcoders] Re: How do i embed a SWF in AS3?
Can the player display the SWF otherwise? How did you get the SWF you are trying to embed? Some issues you may want to check: - SWF contains newer tags then the SDK can handle (DefineFont4 for example cannot be handled in SDK <3.2). - SWF contains shape tweens - some such tweens will cause the SDK parser to fail. - SWF is to big - SDK parser will fail on very big SWFs, maybe it's just a wrong error message, but that's very unlikely. - SWF contains embedded video - I never tried this, but, since SDK has no parser for embedding video this may be an issue. - SWF was generated by some third party tool, which may not done it very well. Best. Oleg
Re: [flexcoders] Label must be a simpler identifier
This mostly happens when you forget "var" keyword but you intend to put it. The "label must be simple identifier" error means that the compiler believed that construction to be a loop label. The error isn't in the code as you show it, but you probably have more of it. Basically, just check the syntax errors, it often happens to me that I write "vat" instead of "var" and so on.
Re: [flexcoders] Re: how to access action script variable data type in mxml
Well, it's not exactly like that... the type of the local variable is checked at compile time. Later on local variables kind of "don't exist", that is the bytecode doesn't have a concept of "get local function variable strict" because what's used is the address. I.e. take for example something as simple as this: var foo:int = 100; foo++; will translate into something like: "push local" 100 "increment by one" Or, more precisely, let's look at example: package { import flash.display.Sprite; public class VarTest extends Sprite { public function VarTest() { super(); var foo:int = 100; // we declared a local variable foo++; // performed some operation involving the varible } } } o...@home:~/flex/sdk/bin$ ./swfdump -abc ./VarTest.swf . . . function :VarTest:::VarTest(): maxStack:1 localCount:2 initScopeDepth:9 maxScopeDepth:10 debugfile "/home/oleg/projects/Keeper/src;;VarTest.as" debugline 7 getlocal0 pushscope debug 1 4 0 10 debugline 9 getlocal0 constructsuper (0) debugline 10 pushbyte 100 convert_i setlocal1 debugline 11 getlocal1 increment_i convert_i setlocal1 debugline 12 returnvoid 0 Extras 0 Traits Entries Explanation: grey - the mandatory initialization stuff and debugging information, not important for our code blue - the variable declaration part, this place corresponds to var foo:int = 100; red - this is where we increment foo. Now, convert_i opcode converts the *value *into integer, regardless of the type of the variable. We could omit the type, in that case we would not have this opcode, but, this would not affect the variable type, because there "isn't a variable", there is only an address, a register, where we saved the integer value of 100. Next, we retrieve the value from register and increment it, Then, we set back the register. Note, there are no type checking at this point. We operate on values and the compiler adds the necessary casting / conversion if required, but there isn't such thing as a local variable "runtime type information" because, technically, a local variable is purely a compile time entity. The local variables may not be accessed by any external code, so, they don't require the type safety as, say, public API do. More yet, the compiler will convert all operation concerning variables into series of procedures, which don't require variables as such. It's easier to imagine this as a kind of an int-hash table, or something more like: Dictionary, with the difference from a real dictionaty being that the actual types are verified at compile time, and therefore there is no point at doing the same verification at runtime. Or, think about it as passport control at the airport: once before the flight the passports are verified, but there's no point to verify them again inside the aircraft because, regardless of what you will discover during the flight, everyone will lend in the same destination airport :)
Re: [flexcoders] Re: how to access action script variable data type in mxml
Nope, sorry Amy, it's not possible to get the type of a local variable, you can only get the type of a value it references. Example: function foo():void { var bar:IBitmapDrawable = new BitmapData(); } you can only know what the type of the value is ( BitmapData ) the type of the "bar" variable (IBitmapDrawable) may not even exist in the compiled code - there's no need for it to exist anyway.
Re: [flexcoders] how to access action script variable data type in mxml
Look up the manual on describeType. Note that local variables type isn't possible to get at runtime.
Re: [flexcoders] Error while doing the Linked list demo using flex
Hi, I think I know this implementation, and, I don't really like it, so I've made my own, you're welcome to try: http://code.google.com/p/e4xu/source/browse/trunk/src/org/wvxvws/data/DataList.as (+ dependencies) Or from templates, if you are using FD: http://code.google.com/p/e4xu/source/browse/trunk/templates/List.as.fdt
Re: [flexcoders] html-template\ index.template.html
If you build that with Ant you may just ignore that and use your own variable - that's how I did that anyway. Used task output attribute. I don't know about a way to set that thing from Flash Builder, it seems like that's one more thing that Flash Builder knows better than you ;)
Re: [flexcoders] Re: dispatchEvent import
Oh, sorry, me wrong... I didn't realize that if you put [Bindable] tag anywhere (not necessarily on class definition), then it will make compiler add extends EventDispatcher... how silly of me
Re: [flexcoders] Re: dispatchEvent import
OK... dispatchEvent is an undocumented global function... test case: var ns:Namespace = new Namespace(""); trace(ns::dispatchEvent); Another hack in AS3... well... I have couple of strong words about this, but these should be only spoken in private... crap :(
Re: [flexcoders] Re: dispatchEvent import
If it ever worked that may be because of the patched compiler / preprocessor, and so all dispatchEvent calls were translated to what is marked as [Dispatcher]. Maybe it does the same as [Bindable] on class, or maybe like HaXe "using" directive. Otherwise - just a confusing piece of code... Well, you know, so far the only reasonable place to put metadata in AS3 was __go_to_definitionHelp, and that you don't have to write... :S
Re: [flexcoders] Opinions Wanted : Best Performing AS3 Zip Library
I think that it says on the nochump site that it is not the fastest. In fact, using BiteArray.compress() with deflate would be the fastest, but that's only if you can use FP10.
Re: [flexcoders] ListCollectionMap
Cool, really, thanks for sharing. Although I didn't like the idea of extending Proxy... I think the bug where the dataProvider is accessed in a dataProvider[i] way should've been fixed now... There are also couple of wrong assumption that ListCollection makes when treating data as Arrays, thus not using interfaces. But that's definitely an edge case.
Re: [flexcoders] Best practice - remote calls from a flex library
I'm afraid you won't find a solution that covers all cases. We at some point decided to not have any business / value objects and return the SQL data unparsed > parse it on the client, of course not the other way, when sending the data. This may be really controversially to the best practices, but in our case performance matters more. Also, if you are building with AIR and using local database (SQLite), whereas security is not of concern, but the speed matters, then it's one case, once it requires roles, permissions etc, that's the other case. Also, we found that we can make more efficient serialization than AMF on our own, so, not really using value objects again. However, this may be important if the traffic matters more then the development speed / maintainability. Best. Oleg
Re: [flexcoders] Blocking
You can load it with JavaScript synchronously, ExternalInterface is also synchronous, however, it is possible that you will run out of time and the application will crash because of that. Because, even though you can try-catch timeout error, if the function that produced the error won't exit, you will get another error that you cannot try-catch.
Re: [flexcoders] Re: Addressing SERIOUS Flash Player issues
Just for the record - a quick search in the bug database for "LocalConnection" gives 88 results, about one half of them unresolved. AFAIK there are some issues related to the new security model regarding Macs and LocalConnection, though it's hard to imagine it would crash the browser... It would be very nice of you if you could find the link to the banner, or at least tell the URL of where it was deployed. I've recently posted a bug related to the changes to security model in FP10 and kind of running out of life examples to prove my case :) I think this issue is related, so, please, if you can remember where it was, it would help. Best. Oleg
Re: [flexcoders] Re: Addressing SERIOUS Flash Player issues
Well, if you will just say "it crashed", you'll get nowhere. It is possible that programs have bugs, but if you want to have less bugs, you have to provide info to help identify them. At least post a link of the banner that caused the crash.
Re: [flexcoders] Re: Addressing SERIOUS Flash Player issues
Try Chrome, it won't crush because of plugins.
Re: [flexcoders] removeEventListener - is it important?
Well, it's really hard to tell since all those objects inherit from UIComponent and it has almost every method overridden and to tell you the truth I just don't know what happens when these handlers are added or removed. I think in every particular case only the profiler will tell what is really happening. That is, the display objects may not be disposed after they are removed from stage and may be stored for the later use. Think of TabNavigarot for example, the components on each tab will be removed and then re-added to stage once every time you switch the tab and so on. What I mean it's not like in .NET for example, where once you have disposed a component you have nothing to do with it but just throw it away. Some basic Flash object have a way to explicitly free their resources, like BitmapData, TextLine or XML (in AIR), but you cannot explicitly dispose the resource used by display objects and Flex framework doesn't do anything in that regard.
Re: [flexcoders] removeEventListener - is it important?
If you are adding handlers to events dispatched by the objects that are going to be removed along with the listener, then why not? However, it is true that Flex components have no dispose() or similar methods.