After a short stint of not understanding what the heck people were moaning about on twitter (re @jesterxl's comments about cuddling), and thanks to him, I came across Grant Skinner's post about curly braces.
I am personally a cuddler. I find the code easier to read, and I am of the school of thought that less lines of code is better. Also, to me logic dictates that if you are starting a block of code, you would emphasize that by showing me on the line that you are declaring the opening of that code, that the code block begins with the curly. In Ruby, there are no curly's for code blocks, so it doesn't bother me there.
But what bothers me, and Grant mentioned it, is how Flashbuilder autogenerates non-cuddled code blocks. And he griped about it, asking that anyone who knows how to fix the problem please let him know. Well, here's my quick fix, using Flashbuilder 4 on Eclipse 3.6 on OSX6.5:
-> Preferences (cmd + ,) -> Flash Builder -> Editors -> Code Templates -> ActionScript
For each of these classes, I manually updated the templates so that the curly braces all were at the end of the opening line for package, class and constructor, i.e.
package com.lordB8r.controller{
public class TestClass{
public function TestClass():{
}
}
}
and methods did the same thing:
private function runTestClass():void{
}
ahhh, breathe deeply, knowing that all auto-magically generated code in AS3 will now conform to my preferences.
And yes, I can export these settings, in case I don't want to manually change all of them for each instance of Eclipse (and then reimport them).
Now, I obviously am not smart enough to be the first person to have come up with this. There is the following resources I found:
InsideRia's article by Greg Owen
FlexFormatter
ActiveTuts by Jesse Freeman
and the best example so far is someone who actually made real templates of what they use in their workflow:
FBB blogpost by Maxim Kachurovskiy
And you can quickly find your own by using lord google.
LordB8r's ramblings, notes, and posts. These are my thoughts and answers to my own expirements on Ruby, Rails, Flex, Python, Django, PostgreSQL, MongoDB, Scala, robots, independent contracting, coffee, scotch, beer, and anything that makes me curious (just not tax codes, anything but tax codes).
Tuesday, December 21, 2010
Monday, December 6, 2010
Resizing Dynamically Loaded swfs using swfloader
In my current project, I am using RobotLegs and a parent application to load in "modules". However, I don't use modules, because frankly, I don't quite get why I should. Instead, I have separate swfs that I can load, and pass information to them, if necessary. The biggest frustration that I have is that when I resize the parent application, my child, which is a loaded swf, doesn't know it's stage has been resized, and thus doesn't resize itself. To fix that, I tried a few different options, including resizing the loader, the system manager, the loaded application, the screen, everything!!!
The problem I was running into is that my loaded swf was getting it's size clipped. This was unacceptable.
For example, if I loaded my swf into my app, if the window was sized at 700x400 (w x h), if I resized my window to something smaller, the controls inside the loaded swf would follow accordingly. However when I resized the window larger than 700x400, the controls would get clipped by an auto-assumed max size of the loaded swf's stage.
GRRRRRRR!!!!!!
So I have lost countless hours of sleep, including the time it's taking me to post this incoherent message. But I feel I must share about resizing a loaded swf without scaling. Right now I have some jerkiness in the movement, but it forces a scale and resize of the loaded swf's width and height.
I avoid using the _loadedSwf.scaleContent and _loadedSwf.maintainAspectRatio. These together were fun to figure out, but the end result was that my controls were scaling, and I didn't want that. If I turned off scaleContent, then nothing would resize. If I turned off aspect ration, then things started looking wonky.
because I had added my _loadedSwf to a SkinnableContainer, and that container was getting resized, I wanted my _loadedSwf to update to that container's size. On initialization I do use a method inside _loadedSwf. And to use that, I have something like the following:
var loadedSM:SystemManager = SystemManager(_loadedSwf.content)
loadedSM.application["updateDimensions"](container.width, container.height);
This worked great for the initial setup, but resizing still didn't work. I won't recount the countless hours I've tried to make it work. Needless to say, and the reward for reading this post is to see that to make this work, I did the following on the resizeMyApp(), called by the parent application whenever an EVENT.RESIZE_EVENT is dispatched:
_loadedSwf.content.width = container.width;
_loadedSwf.content.height = container.height;
Object(_loadedSwf.content).setActualSize(container.width, container.height);
loadedSM.application["updateDimensions"] (container.width, container.height);
I got the idea on page 48 of this manual (Thank you Matt Horn!!!)
http://livedocs.adobe.com/flex/3/loading_applications.pdf
These last 2 lines seem a bit hazy to me, but if I remove one of them, then the resizing doesn't work. I do have some jerkiness that I need to work out, but the overall resizing now commits correctly. I think there is something in the updateDisplayList() that I've missed, but somehow this makes the call work.
The problem I was running into is that my loaded swf was getting it's size clipped. This was unacceptable.
For example, if I loaded my swf into my app, if the window was sized at 700x400 (w x h), if I resized my window to something smaller, the controls inside the loaded swf would follow accordingly. However when I resized the window larger than 700x400, the controls would get clipped by an auto-assumed max size of the loaded swf's stage.
GRRRRRRR!!!!!!
So I have lost countless hours of sleep, including the time it's taking me to post this incoherent message. But I feel I must share about resizing a loaded swf without scaling. Right now I have some jerkiness in the movement, but it forces a scale and resize of the loaded swf's width and height.
I avoid using the _loadedSwf.scaleContent and _loadedSwf.maintainAspectRatio. These together were fun to figure out, but the end result was that my controls were scaling, and I didn't want that. If I turned off scaleContent, then nothing would resize. If I turned off aspect ration, then things started looking wonky.
because I had added my _loadedSwf to a SkinnableContainer, and that container was getting resized, I wanted my _loadedSwf to update to that container's size. On initialization I do use a method inside _loadedSwf. And to use that, I have something like the following:
var loadedSM:SystemManager = SystemManager(_loadedSwf.content)
loadedSM.application["updateDimensions"](container.width, container.height);
This worked great for the initial setup, but resizing still didn't work. I won't recount the countless hours I've tried to make it work. Needless to say, and the reward for reading this post is to see that to make this work, I did the following on the resizeMyApp(), called by the parent application whenever an EVENT.RESIZE_EVENT is dispatched:
_loadedSwf.content.width = container.width;
_loadedSwf.content.height = container.height;
Object(_loadedSwf.content).setActualSize(container.width, container.height);
loadedSM.application["updateDimensions"] (container.width, container.height);
I got the idea on page 48 of this manual (Thank you Matt Horn!!!)
http://livedocs.adobe.com/flex/3/loading_applications.pdf
These last 2 lines seem a bit hazy to me, but if I remove one of them, then the resizing doesn't work. I do have some jerkiness that I need to work out, but the overall resizing now commits correctly. I think there is something in the updateDisplayList() that I've missed, but somehow this makes the call work.
Monday, June 7, 2010
the iPhone, development, and Hedonism
Sorry, should’ve clarified...some emails were going around amongst my colleagues, and we were discussing the newest iPhone. While Apple is the king of cool right now, they're still stuck with a crappy cell phone provider that is worthless if you want your phone conversation to last longer than 30 seconds (about the average amount of time before an average call drops - with full signal strength, mind you).
For me, Flash happens to be a medium I work in, but I’m a Rich Internet Application developer, and HTML5 + javascript, or Flash + javascript, or Silverlight + javascript all can achieve the same thing (eventually)...My job is to make shit look cool (kinda like bouncing gradient balls using gravity to propel themselves through millions of particles of pixie dust (optimized by apparat, of course), all while synthetically growing and teaching you something about polymorphism, or something like that)
I don’t think the hedonistic value of owning an iPhone would actually improve my life in the least, aside from earning the respect and envy of toy collectors...I know I’m a luddite, because I don’t want a phone that surfs the web on a shoddy little screen (high res or not).
Smart phone or not, I hate surfing the web on tiny screens...watching a movie, or playing a game is ok, and getting some quick information distilled down to a quick blurb on twitter-like basis would be useful, but reading entire sites, surfing through the Nytimes, or even going to craigslist suck on these little screens (at least for someone like me with big fat fingers). The iPad comes closer for casual users, or people who don’t need a professional development environment, and just some connectedness...the iPhone (compared to the Incredible) is ok, but I’m not losing sleep.
I’ve got to get back to making cool shit happen on the screen (whichever size screen that may be).
Oh, and Hedonism is an amazing scotch by Compass Box. I really love their bottle of Peat monster, and they've got some yummy other bottles. Try them out if you can.
For me, Flash happens to be a medium I work in, but I’m a Rich Internet Application developer, and HTML5 + javascript, or Flash + javascript, or Silverlight + javascript all can achieve the same thing (eventually)...My job is to make shit look cool (kinda like bouncing gradient balls using gravity to propel themselves through millions of particles of pixie dust (optimized by apparat, of course), all while synthetically growing and teaching you something about polymorphism, or something like that)
I don’t think the hedonistic value of owning an iPhone would actually improve my life in the least, aside from earning the respect and envy of toy collectors...I know I’m a luddite, because I don’t want a phone that surfs the web on a shoddy little screen (high res or not).
Smart phone or not, I hate surfing the web on tiny screens...watching a movie, or playing a game is ok, and getting some quick information distilled down to a quick blurb on twitter-like basis would be useful, but reading entire sites, surfing through the Nytimes, or even going to craigslist suck on these little screens (at least for someone like me with big fat fingers). The iPad comes closer for casual users, or people who don’t need a professional development environment, and just some connectedness...the iPhone (compared to the Incredible) is ok, but I’m not losing sleep.
I’ve got to get back to making cool shit happen on the screen (whichever size screen that may be).
Oh, and Hedonism is an amazing scotch by Compass Box. I really love their bottle of Peat monster, and they've got some yummy other bottles. Try them out if you can.
Thursday, April 22, 2010
Getting Flex 3.6 SDK, Flashbuilder 4, Tomcat, and BlazeDS to all play nice?
Ok, I'll be honest, I haven't gotten Blaze to play nicely yet, but I haven't had anything to setup w/ it yet. I'm connecting to a previous setup that used Tomcat to connect to OLAP, and I'm recreating it in FB4 instead of Spring Suite tools. Much of my team prefers STS, but I am comfortable right now in my efficiency in FB3/4, so I blogged yesterday about wiring up the Flex 3.6 SDK
Connecting to a Tomcat server was the last hurdle before I get to a BlazeDS, and so I found this nice little plugin that I couldn't get from any other source. For some reason, Tomcat isn't supported easily on Eclipse 3.5, and I'm not a fan of the standalone Flash Builder. I prefer the Eclipse plugins, and found this would help me stay within the Eclipse.
http://www.eclipsetotale.com/tomcatPlugin.html#A3
This was a very nice find. I simply put the package in my eclipse plugin folder, and immediately when I restarted Eclipse, I had a Tomcat option on my toolbar. In the preferences pane (Command+,) I could point the plugin at my Tomcat install, and away I go.
Now I can setup keyboard shortcuts (like Command+shift+t) to start/restart, or stop Tomcat. The information from eclipsetotale is quite helpful, and I'm glad I came across it.
Now to get down to some hardcore devving
:)
Connecting to a Tomcat server was the last hurdle before I get to a BlazeDS, and so I found this nice little plugin that I couldn't get from any other source. For some reason, Tomcat isn't supported easily on Eclipse 3.5, and I'm not a fan of the standalone Flash Builder. I prefer the Eclipse plugins, and found this would help me stay within the Eclipse.
http://www.eclipsetotale.com/tomcatPlugin.html#A3
This was a very nice find. I simply put the package in my eclipse plugin folder, and immediately when I restarted Eclipse, I had a Tomcat option on my toolbar. In the preferences pane (Command+,) I could point the plugin at my Tomcat install, and away I go.
Now I can setup keyboard shortcuts (like Command+shift+t) to start/restart, or stop Tomcat. The information from eclipsetotale is quite helpful, and I'm glad I came across it.
Now to get down to some hardcore devving
:)
Wednesday, April 21, 2010
Getting up to speed on the latest Flex 3 SDK’s
This is not assuming you already have Flex 3 installed on your machine (eclipse plug-in or stand alone).
In order to do this and avoid buggy errors, the latest nightly build of Flex SDK 3.6 is what I’ve used successfully. I found one of many a bug which are annoying as all get out regarding comboboxes (which is why I prefer/recommend 3.6).
In order to get up and running quickly, download either the latest or 2nd to latest nightly build of SDK 3.6, found here from Adobe.
Inside your Flexbuilder sdk folder, create a folder for 3.6.0, something like this:
for Windows: C:\Program Files\Adobe\Flex Builder 3\sdks
for Mac: [I use eclipse w/ the plugin, but it’s probably something similar] /Applications/Adobe Flex Builder 3 Plug-in/sdks
Now install (or copy over) the newest SDK to this folder from the download.
Next you’ll need to download the data visualization package (and unit testing if you use that). While the latest build is for 3.5, you can use the package for 3.6 as well.
And instructions for where to copy the files from/to:
This helped me get the environment up and running quickly in 3.6. This can also apply to anyone developing using Flashbuilder 4 and working with SDK 3.x (for previous projects).
In order to do this and avoid buggy errors, the latest nightly build of Flex SDK 3.6 is what I’ve used successfully. I found one of many a bug which are annoying as all get out regarding comboboxes (which is why I prefer/recommend 3.6).
In order to get up and running quickly, download either the latest or 2nd to latest nightly build of SDK 3.6, found here from Adobe.
Inside your Flexbuilder sdk folder, create a folder for 3.6.0, something like this:
for Windows: C:\Program Files\Adobe\Flex Builder 3\sdks
for Mac: [I use eclipse w/ the plugin, but it’s probably something similar] /Applications/Adobe Flex Builder 3 Plug-in/sdks
Now install (or copy over) the newest SDK to this folder from the download.
Next you’ll need to download the data visualization package (and unit testing if you use that). While the latest build is for 3.5, you can use the package for 3.6 as well.
And instructions for where to copy the files from/to:
This helped me get the environment up and running quickly in 3.6. This can also apply to anyone developing using Flashbuilder 4 and working with SDK 3.x (for previous projects).
Monday, April 12, 2010
Creating an AIR Installer badge for Flex Devs
In building a recent app, the customer asked me to also make a flash badge for their installer. This way they could deploy the app installer, yet control the download of the AIR app. For me, the badge allows two things, control of the app's image, and some nice SEO. If you can get other sites to deploy your badge (which is a simple group of files), then you can get some nice cross linkage SEO (not to mention and SEO linking/MetaData you might have in the SWF that runs the installer), and also some good data.
So to create a Badge, use Adobe's sample badge which I found here (on my Mac):
/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.6.0/samples.
After you copy it into your project's folder (or wherever you'll most effectively work with it), you'll need to open it in Flash to manipulate some of it. Now, I am not a Flash IDE user. It takes me quite some time to figure out what the heck timelines are, and what layers are doing where, but in all honesty, if I could just figure this out, I'm sure I could do some killer stuff in Flash that would help out my enterprise apps. Anyways, inside the group of items are .js, .html, .as, .swf, .jpg, and .fla. The .fla allows me some room for designing, creating, and manipulating my text area. Following Lee Brimelow's (http://www.gotoandlearn.com/play?id=56) example of making a tooltip in Flash (something I enjoy taking for granted in Flex), I built a hover over tooltip in my installer badge, as well as added some SEO in the metadata of the swf, and inside the jsp/html page.
It took me a few minutes to realize that the badge itself was generated from Flash, so once I got inside of Flash, and started tooling around, I found out I could easily automate, or graphically change around, things on my installer badge. And by using my own customized image, I could adjust inside the .fla what the image was to be shown, and could now use an animated .gif, or a .png, or (using the awesomeness of alchemy and ZaalLabs) 40+ image types.
Also, because the fla incorporates the as file, I adjusted a few settings there for some more seo, and used that to compile and push out my swf. bada-boom, bedaubing, I now have a kick-a$$ installer badge, with a custom logo, and I can mess around and adjust anything about the badge I want (including animation, or generative art, or what not). And the installer file is tiny (in comparison to a flex app, this thing was only about 6k when I was done). 6 friggin K. That's ridiculously small…I need to learn to make Flex apps that small.
Anyways, please enjoy hopefully these step by steps will help you make a better AIR app installer badge.
So to create a Badge, use Adobe's sample badge which I found here (on my Mac):
/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.6.0/samples.
After you copy it into your project's folder (or wherever you'll most effectively work with it), you'll need to open it in Flash to manipulate some of it. Now, I am not a Flash IDE user. It takes me quite some time to figure out what the heck timelines are, and what layers are doing where, but in all honesty, if I could just figure this out, I'm sure I could do some killer stuff in Flash that would help out my enterprise apps. Anyways, inside the group of items are .js, .html, .as, .swf, .jpg, and .fla. The .fla allows me some room for designing, creating, and manipulating my text area. Following Lee Brimelow's (http://www.gotoandlearn.com/play?id=56) example of making a tooltip in Flash (something I enjoy taking for granted in Flex), I built a hover over tooltip in my installer badge, as well as added some SEO in the metadata of the swf, and inside the jsp/html page.
It took me a few minutes to realize that the badge itself was generated from Flash, so once I got inside of Flash, and started tooling around, I found out I could easily automate, or graphically change around, things on my installer badge. And by using my own customized image, I could adjust inside the .fla what the image was to be shown, and could now use an animated .gif, or a .png, or (using the awesomeness of alchemy and ZaalLabs) 40+ image types.
Also, because the fla incorporates the as file, I adjusted a few settings there for some more seo, and used that to compile and push out my swf. bada-boom, bedaubing, I now have a kick-a$$ installer badge, with a custom logo, and I can mess around and adjust anything about the badge I want (including animation, or generative art, or what not). And the installer file is tiny (in comparison to a flex app, this thing was only about 6k when I was done). 6 friggin K. That's ridiculously small…I need to learn to make Flex apps that small.
Anyways, please enjoy hopefully these step by steps will help you make a better AIR app installer badge.
Friday, March 19, 2010
Working w/ Global settings in Flash to get around Sandbox Security issue
I am working on an app that needs local resources and network resources. I was getting very frustrated during my development because I couldn't read the local setup file. Unfortunately, after a lot of digging around, the only reason I could find that the app wouldn't load was because the global settings for flash had been changed. Because these settings are only available by going online here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html
The following isn't a tab, but allow you to view set your player updates:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager05.html
Anyways, the annoyance for me is a couple of things:
1) why is this remote (aka why do I have to keep reloading a page to look at flash player settings inside of a flash swf?)
2) What is the garbage that Charles is recording going back and forth, and
3) where is this swf object located on my machine so that I may have some more control over it.
It's amazing to see what sites (intentionally visited or not - which includes pop-ups) that are stored in the global settings…I need to understand this more if I'm going to want more security for my machine.
Anyways, the point I had about this post was that the global security settings were causing me some problems in connecting my app to the intertubes. Once I made a checkmark on the Global Security Settings, I could actually see content and it resolved my problems (and all of this started as a search into possible cross domain issues, and not just my own irrational fears that someone might actually want to track all the websites I've been to and store private information about it without letting me know/delete/erase this stuff, manage my own security, etc…).
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html
or here:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html
The following isn't a tab, but allow you to view set your player updates:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager05.html
Anyways, the annoyance for me is a couple of things:
1) why is this remote (aka why do I have to keep reloading a page to look at flash player settings inside of a flash swf?)
2) What is the garbage that Charles is recording going back and forth, and
3) where is this swf object located on my machine so that I may have some more control over it.
It's amazing to see what sites (intentionally visited or not - which includes pop-ups) that are stored in the global settings…I need to understand this more if I'm going to want more security for my machine.
Anyways, the point I had about this post was that the global security settings were causing me some problems in connecting my app to the intertubes. Once I made a checkmark on the Global Security Settings, I could actually see content and it resolved my problems (and all of this started as a search into possible cross domain issues, and not just my own irrational fears that someone might actually want to track all the websites I've been to and store private information about it without letting me know/delete/erase this stuff, manage my own security, etc…).
Subscribe to:
Posts (Atom)