DaveOnCode
coder and technology lover
coder and technology lover
Aug 2nd
I just faced the terrible nightmare of “Type was not found or was not a compile-time constant” error (Flex Builder) and I lost several time to figure out what the problem was.
I realized that I was using the same name for MXML Application file which was already used by a class inside one of my packages. So, by renaming the file I solved the problem, but I was not completely satisfied and I looked for a way to avoid the error mantaining the same file/class name. Initially I tried to use namespaces, but as the reference says: “Applying a namespace means placing a definition into a namespace. Definitions that can be placed into namespaces include functions, variables, and constants (you cannot place a class into a custom namespace)”. I finally solved by renaming class references inside my package with the full qualified name (from MyClass to com.mysite.foo.MyClass)
Jun 12th
In a project, I have to use an iframe and I need that its height is automatically calculated based on its content. However is not possible to accomplish this by simply setting the attribute height to 100%, instead we must smartly use javascript to dynamically assign that value after a computation. The solution I’m going to show you is not 100% my work but instead an optimization and a better implementation of clever intuitions I found on the web.
The “trick” works in this way:
1. The iframe should has an ID assigned:
1 | <iframe id="slideshow_frame" src="frame.html" frameborder="0" width="100%" marginheight="0" marginwidth="0" scrolling="no"></iframe> |
2. the page loaded into the iframe should contains all the html into an “easy retrievable” container (a div with an ID is perfect!):
1 2 3 4 5 | <div id="content"> <div style="background: red; width: 400px; height: 120px"></div> <div style="background: green; width: 400px; height: 300px"></div> <div style="background: yellow; width: 400px; height: 60px"></div> </div> |
3. on the iframe’s page “onload” event, a function will be executed to adjust its height:
1 2 3 4 5 6 7 8 | function resizeIframe(iframeID) { var iframe = window.parent.document.getElementById(iframeID); var container = document.getElementById("content"); iframe.style.height = container.offsetHeight + "px"; } |
Jun 3rd
Flex 4 beta (codename: Gumbo) has been released, I just finished to read about the new major release. These are the main news:
The new sdk is available on Adobe Labs
More about Gumbo here:
An Introduction to the Gumbo Component Architecture (by Deepa Subramaniam)
What’s new in Flex 4 SDK beta (by Matt Chotin)
Differences between Flex 3 and Flex 4 (by Joan Lafferty)
May 29th
I discovered a couple of days ago a new open source project from Mozilla labs: Jetpack.
It’s an “API set” which allows to build Firefox’s plugins by using Javascript, HTML (including new HTML 5 tags: “video” and “audio“) and CSS (oh yes, in a single word Ajax).
Jetpack is still in an early development phase and released as 0.1 version.
Here you can find the (really brief) api documentation and here some examples.
I would like to try it in the future
May 25th
I’m preparing for the Adobe Flex 3 + AIR certification and I would like to share two AIR applications which I’m using to study an test my Flex knowledge.
The first is pretty famous, so maybe you already know it: Tour The Flex.
It provides hundreds examples of all components available in the framework and includes Adobe reference.
The second is a real helpful app (which I discovered through Twitter), because it consist in an exam simulator (flex 3 + air). Is possible to choose between 8 different test, once a test begins a timer will show you the remaining time and at the end of test the reached score will be showed. Wrongs questions will be explained and you’ll be pointed to Adobe reference for clarifications.
The (free!) application is available here: http://software.pxldesigns.com/attest
May 20th
Ok, let me explain my last experiment…
Flex’s components have a nice id property which can be used to easily referencing object created.
All you know, that if I get the following mxml Application file:
1 2 3 4 5 6 | < ?xml version="1.0" encoding="utf-8"?> <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:textinput id="input1" width="300" /> </mx:application> |
I can then create a Script block into which I’ll point to TextInput in this way:
1 | input1.text = "text dynamically added :)"; |
Perfect, but how can I reference dynamically created objects (components outside Application)?
May 11th
Finally it’s time to release my little project and my first personal and public Actionscript library.
What I’m talking about? I realized a little “subframework” which goal is to extend Flex’s logging framework, in order to write log messages to files on the disk and provide a custom Flex’s UI component (which can be easy used into every AIR application) to read/filtering these log files.
Learn more here: http://www.daveoncode.com/air-logging-framework
Just a note: although I tested the library (windows and mac) and it works fine, this project may contains bugs or doesn’t work under some circumstances. Comments and feedback are welcome!
May 4th
This is just a quick post that may (I hope) help who are going to use asdoc tool to generate Actionscript documentation for AS classes which use AIR framework.
Problem:
You want to generate documentation for your package(s), but when you type asdoc command in the terminal you get a lot of errors such:
Type was not found or was not a compile-time constant: File.
Type was not found or was not a compile-time constant: Vector
…and so on
Solution:
You have to use -external-library-path option to include AIR swc, because AIR classes are located into external swc apart from Flex framework.
These files are under /sdks/{yourSDKVersion}/frameworks/libs/air/ (where “{yourSDKVersion}” is the version of Flex SDK you are using to deploy your applications) and are the following five:
The first 2 should be imported with -external-library-path option anytime you use AIR classes, the others are necessary only if you are using the update framework and/or serivicemonitor.
The following is an example of how to use the asdoc command with the option discussed:
./asdoc -source-path=/Users/davidezanotti/Documents/workspace/myproject/src/ -external-library-path=/Applications/Adobe\ Flex\ Builder\ 3\ Plug-in/sdks/3.3.0.4589/frameworks/libs/air/airframework.swc,/Applications/Adobe\ Flex\ Builder\ 3\ Plug-in/sdks/3.3.0.4589/frameworks/libs/air/airglobal.swc -doc-sources=/Users/davidezanotti/Documents/workspace/myproject/src/ -output=/Users/davidezanotti/Desktop/doc
The code above will succesfull generate documentation for all classes under the folder “/Users/davidezanotti/Documents/workspace/myproject/src/” to the “doc” folder on the desktop.
Apr 28th
I decided to write this post, because I revised a Javascript code realized by a colleague and it was simply terrifying!
It was bad formatted, it had HTML style comments (<!- – - ->) with insignificant or unclear content, missing var declarations and so on.
What I would like to say is that, in order to use jQuery and similar js libraries a mere HTML knowledge is not enough, Javascript is not hard to understand and use as Java, C++ or other object oriented programming languages are, but several things must be clear before to write some code. If you want to use in a clever and productive way such libraries you should at least:
Too much stuff to learn? It’s the minimum to know, there are then prototyping, JSON, closures, XMLHttpRequest and so on…
Javascript is a programming language (not a tool for designers), don’t believe that a call to $.doMagic() will resolve your problems, you have to understand what is behind that doMagic() (at least the foundations) in order to realize concrete stuff… otherwise you will only write “magic spaghetti code”!
Apr 21st
I just discovered Sharify, an interesting service which goal is to provide AIR developers the tools for create shareware (sellable) applications.
It seems also very easy to use, the steps are: register to the site, create an application id, integrate the sharify library (an swf file) into the application and choose a payment method (like paypal). The service unfortunately is not free, but require the 3% of each license sold… however I find the percentage very reasonable (if the service is valid and secure as I expect).
I didn’t try it yet, but I think I’ll do in the future :)
Recent comments