Taking the last example a little further, here I have added some animations to the generated balls. These balls are now increasing and decreasing in size while sitting at the same place. But the fun part is they are draggable too. Try it for your self and this is all running in HTML5 and flash both. Same code base.
The output for this example is here and the source code can be downloaded here.
Again this example uses haXe timer and its completely portable to all targets through NME.
Happy haXe -ing.
Category Archives: Uncategorized
haXe: interactive balls in HTML5
Today we are going to interact with some Canvas elements in HTML5. Previously I tried this with on ENTER_FRAME event and I think you know the rest of the story Thats my previous blog post is all about Finally I updated to code example to see haXe timer in action. The final version is here for the demo and the source code is here for you to download and play.
When the demo is open, it will create some random circles in Canvas. Now click on any circle to select it. It now sticks with mouse and once you click it again, it will stay in that position and stop coming the mouse. While in flash player the selected circle comes on top, even it was below another circle before selection, but in HTML5 version sometimes it works and sometimes not.
This is all same code base publishing to different targets. This particular code compiles successfully to flash, HTML5, Neko and iOS. I have tested in all targets, simply awesome.
Happy coding.
No Excuses
OpenPlug: Tic-Tac-Toe game
After my first application for Android with OpenPlug|Studio, I tried my hands on game development with it. So here is the basic Tic-Tac-Toe game done with it. The source code is available at GitHub.
Well, I must say if you are developing for Android, then it cannot be one size fit all. Every device is of different configuration in terms of screen size, resolution and capabilities.
First visit to “God’s own country”
This is again a wild trip, a sudden decision and a fast move I must say if you want to feel real India, go with a friend, to his/her own place. Nothing like getting the raw experience. And if you do that, I am sure you will be amazed by the Indian tradition, hospitality and the thousand year old culture we still preserve on our country.
Kerala, often know as “The God’s own country” is truly stand up to its name. If you are by any chance in Bangalore, then there are buses and trains to reach the place. And my destination was Kannur.
View Larger Map
And I was travelling from Bangalore, so it was 9 hours journey in a bus on an average, though it took us 12 hours to reach as of traffic.
I was all tired and restless, but once we reach the place and spend some minutes there, then suddenly I regained the energy!! Well, its all nature every where and I mean every where. We went through trees all the time with narrow road and this is just beautiful experience. At night we visited local club and I am glad, people have just accepted me apart from the language barrier. I could not speak / understand Malayalam so my friend became the translator. Thanks a lot to him.
Next day was the visit to the sea, beaches and the town. We travelled with a motorbike and the pictures tell a thousand words!
First time ever I was in a beach where one can drive bikes,scooters or four wheelers.
Amazed to see the beauty.
The same river, which I rafted earlier in my first water rafting experience, is grown in width and I saw it here too. The small river, flowing through the hills with its massive potential of forces, is grown to a huge river, some what calm and widespread.
Then the spring and the diving experience in it, is just one has to experience.
The atmosphere was cold, i was expecting chilling cold water in the fountain, but it was kind of warm water!!
Nature surely knows how to manage things and what best fits everyone.
First visit to "God's own country"
This is again a wild trip, a sudden decision and a fast move I must say if you want to feel real India, go with a friend, to his/her own place. Nothing like getting the raw experience. And if you do that, I am sure you will be amazed by the Indian tradition, hospitality and the thousand year old culture we still preserve on our country.
Kerala, often know as “The God’s own country” is truly stand up to its name. If you are by any chance in Bangalore, then there are buses and trains to reach the place. And my destination was Kannur.
View Larger Map
And I was travelling from Bangalore, so it was 9 hours journey in a bus on an average, though it took us 12 hours to reach as of traffic.
I was all tired and restless, but once we reach the place and spend some minutes there, then suddenly I regained the energy!! Well, its all nature every where and I mean every where. We went through trees all the time with narrow road and this is just beautiful experience. At night we visited local club and I am glad, people have just accepted me apart from the language barrier. I could not speak / understand Malayalam so my friend became the translator. Thanks a lot to him.
Next day was the visit to the sea, beaches and the town. We travelled with a motorbike and the pictures tell a thousand words!
First time ever I was in a beach where one can drive bikes,scooters or four wheelers.
Amazed to see the beauty.
The same river, which I rafted earlier in my first water rafting experience, is grown in width and I saw it here too. The small river, flowing through the hills with its massive potential of forces, is grown to a huge river, some what calm and widespread.
Then the spring and the diving experience in it, is just one has to experience.
The atmosphere was cold, i was expecting chilling cold water in the fountain, but it was kind of warm water!!
Nature surely knows how to manage things and what best fits everyone.
OpenPlug | Studio : things to consider
Talking about one code base and multiple devices is a tricky affair. In that case there are various frameworks and platforms which strive to do that. One of the most beautiful platform I found is OpenPlug|Studio. Well, being an Actionscript developer and working on Flex SDK, one will certainly feel at home with OpenPlug|Studio. Being said that, there are some very subtle differences to consider while creating applications with this platform compared to Flex itself.
1. Its loosely based on Flex 3 SDK. That means there are things like “mx” components like “WindowedApplication” is present in it. The work flow is similar to any Flex 3 based project. But then it is recommended to use “mob” namespace based components for they are mobile optimized for almost all devices. Again this OpenPlug|Studio SDK, which is known as Elips SDK only supports a subset of Actionscript 3.
2. Almost all the “mob” components are final classes. The immediate effect is one can not extend native “mob” components to create a new component.
3. The display object containers do not include “MovieClip”.
4. Using the available flex/actionscript frameworks is a strict no, as to one will end up writing the whole framework again for this OpenPlug|Studio (Elips SDK). For this ElipsSDK is a subset of Actionscript 3.
5. I was trying to open an image in the device with the default photo viewer application on Android, but then at the end came to know that this is not possible. Though Elips SDK provides the component, which can display the photo. I think, that indicates we can use Elips SDK to view images, run videos/audios with SDK components but can not directly force the default players/viewers of the device to launch the files.
6. About the “List” component I have already shared my views in the blog post earlier. Just use a default “ItemRenderer” to use the “List” component for the time being, until the Elips SDK fixes the bug.
7. Accessing the file system is a little tricky! I was trying to access file system of an Android phone , both phone memory and SD card memory. While the document says, it could be accessed as
Path to access memory card is: app-storage:/ExternalStorage/ Path to access internal memory is: app-storage:/InternalStorage/ In AIR, it corresponds to subfolder in app-storage:/, to keep Flash compatibility for simulation.
But in reality I could never get into the file system with them. The in-phone memory access I still have to find a way, the SD card file system can be accessed as
var extFolderPath:String = File.applicationStorageDirectory.nativePath+ "ExternalStorage";
var externalFolder:File=new File(extFolderPath);
8. Javascript can be used inside the Application with “script” tag as
mx:Script source="test.js"
This is interesting as from inside javascript file one can access the components with their “id” as one accesses them in Actionscript. But take care not to use any javascript libraries here as this is not DOM manipulation we are doing but using javascript syntax to do our Application. I have not tested the loose typing metaphor of javascript with a project, will update when I do that.
9. The OpenPlug|Studio is a free IDE and it works on both Mac and Windows. There is a plugin version, which could be installed over a FlashBuilder and a standalone version which could be installed separately without any dependencies. And the forum at the OpenPlug|Studio site is quite active, though it may not be instant but at least you will get your answers within a decent amount of time.
I thought would put my experiences here, so as to it may help someone out there with similar kind of problem.
OpenPlug | Studio : things to consider
Talking about one code base and multiple devices is a tricky affair. In that case there are various frameworks and platforms which strive to do that. One of the most beautiful platform I found is OpenPlug|Studio. Well, being an Actionscript developer and working on Flex SDK, one will certainly feel at home with OpenPlug|Studio. Being said that, there are some very subtle differences to consider while creating applications with this platform compared to Flex itself.
1. Its loosely based on Flex 3 SDK. That means there are things like “mx” components like “WindowedApplication” is present in it. The work flow is similar to any Flex 3 based project. But then it is recommended to use “mob” namespace based components for they are mobile optimized for almost all devices. Again this OpenPlug|Studio SDK, which is known as Elips SDK only supports a subset of Actionscript 3.
2. Almost all the “mob” components are final classes. The immediate effect is one can not extend native “mob” components to create a new component.
3. The display object containers do not include “MovieClip”.
4. Using the available flex/actionscript frameworks is a strict no, as to one will end up writing the whole framework again for this OpenPlug|Studio (Elips SDK). For this ElipsSDK is a subset of Actionscript 3.
5. I was trying to open an image in the device with the default photo viewer application on Android, but then at the end came to know that this is not possible. Though Elips SDK provides the component, which can display the photo. I think, that indicates we can use Elips SDK to view images, run videos/audios with SDK components but can not directly force the default players/viewers of the device to launch the files.
6. About the “List” component I have already shared my views in the blog post earlier. Just use a default “ItemRenderer” to use the “List” component for the time being, until the Elips SDK fixes the bug.
7. Accessing the file system is a little tricky! I was trying to access file system of an Android phone , both phone memory and SD card memory. While the document says, it could be accessed as
Path to access memory card is: app-storage:/ExternalStorage/ Path to access internal memory is: app-storage:/InternalStorage/ In AIR, it corresponds to subfolder in app-storage:/, to keep Flash compatibility for simulation.
But in reality I could never get into the file system with them. The in-phone memory access I still have to find a way, the SD card file system can be accessed as
var extFolderPath:String = File.applicationStorageDirectory.nativePath+ "ExternalStorage";
var externalFolder:File=new File(extFolderPath);
8. Javascript can be used inside the Application with “script” tag as
mx:Script source="test.js"
This is interesting as from inside javascript file one can access the components with their “id” as one accesses them in Actionscript. But take care not to use any javascript libraries here as this is not DOM manipulation we are doing but using javascript syntax to do our Application. I have not tested the loose typing metaphor of javascript with a project, will update when I do that.
9. The OpenPlug|Studio is a free IDE and it works on both Mac and Windows. There is a plugin version, which could be installed over a FlashBuilder and a standalone version which could be installed separately without any dependencies. And the forum at the OpenPlug|Studio site is quite active, though it may not be instant but at least you will get your answers within a decent amount of time.
I thought would put my experiences here, so as to it may help someone out there with similar kind of problem.