Archive for Flash
September 22, 2007 at 21:17 · Filed under Flash, Flex, Plugins
It recently came to Larry and mine’s attention that there isn’t an easy way to switch plugins for OS X. Mike Chambers had put one out early last year, but is no longer valid as it was for PPC macs. The problem now with Intel macs is that if you install any flash player lower than 9, it is PPC so it won’t run if you open up the browser. Your browser will tell you that you don’t have have Flash installed.
This is easily fixed by opening “Get Info” on your browser and checking run in rosetta. But that is a little tedious to be switching back and forth.
So here’s a much more graceful commandline tool to automate this for you – Plugout. It’s a commandline tool that easliy let’s you switch to the target plugin, and restart the browser in rosetta (if necessary). It will work with any plugin. It comes with the Flash players 7-9 and Silverlight 1.0. But is easily extendable to add Quicktime, or RealPlayer, or whatever other plugin you want.
Plugout will be available as a Ruby gem shortly, and in the future I’d like to add support for remote updating of the plugins. But I’m not sure what kind of legal trouble this could cause. I’m sure I’ll be getting a letter from Adobe or Microsoft about even distributing the plugins up front. I’ll wait for a cease and desist.
We’re also working on GUI’s for plugout. Flash IDE and Flex Builder. And hopefully a standalone app of some sort that can be used in QA teams. For now commandline usage is simple enough for us developers. Gotta give some love to unix man.
Thanks to Larry Gordon for helping figuring out some ins and outs of how this should all work. Thanks to Larry Gordon and Alastair Green for the name plugout.
To install the tool run “sudo ./install.sh” from the commandline (inside of the plugout directory). The installer copies the plugout executable to /usr/bin and copies the plugout_plugins directory to your home directory. Refer to the homepage or ‘plugout -h’ for a how to.
Plugout Homepage
Screencast
Download it
Also a heads up – I haven’t had a chance to test this on a PPC Mac, so if anyone out there has a PPC mac and can test this all out that would be great!
September 20, 2007 at 18:21 · Filed under Flash, Flex
I need a huge favor from someone. I need to find all the flash player 9 plugin files (/Library/Plug-Ins) For every version of flash player 9 (for PPC). The way to get all these plugins is to install players 9.0 – 9.0.60 from the archives page. After each install, go to the /Library/Plug-Ins folder and swipe the necessary flash plugins. Put them in a folder labeled 9.0.x for each version.
I can’t get them myself because I’m on an Intel mac, the PPC installers won’t install it. So please, if anyone out there has a spare 30 minutes and a PPC help me out and zip up those files on an FTP for me.
September 20, 2007 at 11:02 · Filed under Flash, Flex, Rails, Remoting, Ruby, RubyAMF
So maybe this isn’t a question you were expecting. But does anyone else have any problems with the colors / brightness on RubyAMF? This post didn’t include RubyAMF. Apparently because it’s too dark to read. Which is alright. But it makes me want to hear from more people. Should I re-skin the site to be mostly white with some red? I’m on a mac so the brightness / gamma is different and it shines for me
RubyAMF is getting to the point where it’s a great experience tying it in with Rails (and of course with Lite) – the fact that it works with scaffolding and in your controller with render :amf makes it a winner for me. But if people don’t use it because they can’t read the site then it’s time for an update. I love working on RubyAMF so I want everyone to have a great experience with it. Maybe this sounds weird – but I LOVE remoting. The first project I did with remoting was with MercuryCloud and Patrick Mineault. Ever since then it’s been a key part of almost every project I build. So I’m not trying to be pushy about RubyAMF at all, just know that everything I put into RubyAMF is pretty carefully thought out for performance factor and ease of use.
What do you think, time for a re-skin or color update?
September 19, 2007 at 08:01 · Filed under Events, Flash, Flex, Rails, Ruby, RubyAMF
Simeon Bateman put together a nice demo app for RailsConf to show off the power of Flex and Rails. He’s got three examples – an HTTPService example, weborb, and RubyAMF. Check them out.
September 18, 2007 at 18:39 · Filed under Events, Flash, Flex, Ruby, RubyAMF
Be sure to check out the Flex on Rails session at MAX with Tony Hillerson of EffectiveUI.
Here’s the session description:
Learn how to integrate your Flex applications with a Ruby on Rails back end. Topics include remoting, using ActiveRecords in Flex, and the Flex/RoR SDK. Finally, learn how to deploy your Flex application to Adobe Integrated Runtime (AIR).
RubyAMF exposure will be limited, but thanks goes to Tony for even considering RubyAMF to be part of his presentation. Thanks Tony!
September 18, 2007 at 00:22 · Filed under Flash, Rails, Remoting, Ruby, RubyAMF
I’d like to shed a little more light on the best ways to send parameters to RubyAMF Rails, so that you can use params[:]. Specifically using Flash 9, NOT Flex. The most important two things to note are these:
- Any objects properties whether it be a basic object, or value object get merged into the params hash. ONLY the first parameter gets merged though.
- Any incoming value object also gets put into params[:classtype]. So if an incoming VO is of the type “vo.Event”, it will be put in params[:event]. This will enable you to fully use scaffolding without adding is_amf conditionals.
So what does this mean? If you send parameters correctly from Flash, there are only a few updates to get everything working correctly on the rails side. Here’s a generic example that should translate to a real working example.
RAILS:
class MyService < ActionController
def update
user = User.find(params[:id])
if is_amf
u = user.update_attributes(:name => params[:name], :email => params[:email])
else
user = User.find(:id)
end
if u
render :amf => true
end
end
def create
if is_amf
user = User.new({:name => params[:name], :email => params[:email]})
else
user = User.new(params[:user])
end
if user.save
render :amf => true
end
end
def destroy
user = User.find(params[:id])
user.destroy
render :amf => true
end
end
So in this example the destroy method works without having to mix in the is_amf variable. The create and update method has to mix in the is_amf variable because we’re not passing value objects back and forth.
Here is the corresponding AS3 to call these methods correctly.
AS3
function createUser():void
{
myservice.create([{name:'asdfasdf',email:'aaron'}], onResult,onFault);
}
function updateUser(user:Object):void
{
//user should be => {id:1, name:'Aaron', email:'aaron@something.com'}
myservice.update([user],onResult,onFault);
}
function destroyUser(id:Number):void
{
myservice.destroy([{id:id}],onResult,onFault);
}
So what do we do to update the create and update methods so they don’t have to use is_amf? Value objects or _explicitType. These are two options to help you map everything the way you want. Here’s how they both work.
Value objects are simple. They boil down to a generic object with one extra piece of information – the class type. In our case. A ‘User’ class. So when you instantiate a value object, and send it over to RubyAMF, all your properties come over in a generic object, but it also sends the class type. Pretty simple. On the RubyAMF side your class type is caught and a Value Object of the same type is instantiated in Ruby / Rails. So if your value object is a User class, it is in turned mapped to params[:user].
So do we absolutely need value objects to get the params[:user] hash to be the correct object? No. RubyAMF uses a special property to handle value objects on the server side. _explicitType. If you send a generic object with the _explicitType property, it will be turned into a corresponding value object for you. It just so happens that the _explicitType is used to map a value object class to params[:classtype]. So we can use this to map our generic object to the params[:user].
Let’s look at how we can update methods so we don’t need to use is_amf.
Rails:
def create
user = User.new(params[:user])
if user.save
render :amf => user.as_single!
end
end
def update
user = User.find(params[:id])
if user.update_attributes(params[:user])
render :amf => true
end
end
AS3
function createUser():void
{
myservice.create([{_explicitType:'user', name:'Aaron', email:'aaron@something.com'}],onResult,onFault);
}
function updateUser(user):void
{
//uyser should be => {id:1, _explicitType:'user', name:"Aaron", email:"myemail"}
myservice.update([user],onResult,onFault)
}
So by specifying the _explicitType property, it’s going to put an active record update_hash in params[:user]. Pretty cool. Now I’m not suggesting you use _explicitType at all times as it’s kind of a hack. You should use value objects instead. But hey, you’ll probably benefit from knowing more about RubyAMF.
Please let me know if there are any questions or suggestions for making it better.
September 17, 2007 at 18:15 · Filed under Flash, Flex, Ruby
Rant is a simple tool I’ve been working on here and there, and it’s at a place where I’d love to get some eyes on it.
Rant is a mashup of ANT and Ruby for the best of both worlds. Ant is useful for a lot of little tasks – setting up hierarchal chains of execution, executing scripts, moving files, generate templates etc. But then there are times when I wish I could just script parts of the build process. Now you can with Rant. As mentioned, it’s a mashup of ant and ruby. During the build process, an entry point into a ruby file is made that allows you to execute commands, which can be whatever you think of in ruby.
Rant is an all around build tool for those developing projects in Flash or Flex, but don’t want to use Flash IDE or Flex Builder.
Currently I’ve only been able to test this on a Mac, and am looking for some eyes to make sure this works in Windows / FlashDevelop. Give it a shot! Download it here.
Please check out the readme file as well. This is a great place to start.
See the readme file.
September 16, 2007 at 20:43 · Filed under Flash, Flex, Rails, Remoting, Ruby, RubyAMF
Ok folks, here is 1.3.3. This release has a few really important fixes in it. In case you didn’t notice, I silently released 1.3.2b into the rails installer. That had one serious bug fix, and 1.3.3 has a few more fixes that I came across that are somewhat serious. So please update to 1.3.3.
Check out the release log for details.
September 12, 2007 at 23:44 · Filed under Flash, Flex, Rails, Remoting, Ruby, RubyAMF
It’s that time again. Here is RubyAMF 1.3.2a. This has a number of really good fixes in it.
First I’ve added support for BigDecimal. What does that include? Native NaN, Infinity, -Infinity de/serialization. Now those values will be handled by RubyAMF. There is also top level functions isNaN and isFinite to support those new values.
Here is a list of the new pieces that go into BigDecimal support on the Ruby side:
isNaN / isNaN?
isFinite / isFinite?
NaN #not a number.
Infinity #infinity (Infinity / Math.POSITIVE_INFINITY)
NInfinity #negative infinity (-Infinity / Math.NEGATIVE_INFINITY)
As an example, immagine we do this as a service call from Flex:
myRO.getNaN()
And in Ruby:
def getNaN
#LITE:
return NaN
#RAILS:
render :amf => NaN
end
def getInfinity
Infinity
end
def getNinfinity
NInfinity
end
The result will be NaN in the player. Same goes for Infinity / NInfinity. Note that AMF0 only supports NaN.
I’ve also cleared up an issue with outgoing Date objects having problems being cast in the Flash player. The problems don’t happen anymore, but the solution was to skip writing any references to other Date objects in the AMF stream.
Previously, the player would get hung up on referenced Date objects while deserializing the AMF – which caused the player to throw a TypeError. The strange thing is that even though there was a casting error, the dates were still usable and correct.
Now I just force it to write every Date object to the stream, which fixes this. But is this a problem with the player?
See the release log for more info on this release.
1.3.2a is now in the Rails installer as well.
September 11, 2007 at 02:12 · Filed under Flash, Flex, Rails, Remoting, Ruby, RubyAMF
I’ve added better support for params hash mapping. So those that tried to do the following but ended up failing, can now do it.
def update
u = User.find(params[:id])
u.update_attributes(params[:user])
if u.save
respond_to do |format|
format.amf { render :amf => true }
end
end
end
That wouldn’t work previously. So I have an update for this in /trunk that now handles this.
Actually, here’s a good time to explain how remoting parameters map to the params hash in rails.
-All incoming VO's get put into params[:CLASSNAME]. EX(params[:user]).
-If an Incoming VO is not an active_record, but a custom vo which maps
to a fully qualified class path (:map_to => 'my.package.class.MyCustomVo').
It will be put in params[:mycustomvo]
-All incoming parameters ALSO get put into their index. EX(user = params[0]).
-For incoming active_record VO's, the params[index] is an update hash.
-If the first param is an Object or VO, it's property values are merged
into params. (params[:id], params[:firstname], etc..)
Make note that the only time an objects properties are merged into the params hash is if it’s the FIRST parameter in the remoting call. As usual – if anyone has an idea to better this just let me know.
These updates are in /trunk for now, and I will release 1.3.2 as soon as I get BigDecimal support in.
« Previous entries ·
Next entries »