Posts Tagged Flash
The iPad and me
I don’t really like to do opinion pieces. On the subject of technology, like religion, sometimes it doesn’t really matter what you say; both sides never really listen to each other. I don’t want to add another pointless my side is better than yours article. But I think it is sad when people say that such and such is bad and should die. Like it is currently the case with Flash and the whole iPad brouhaha. What I think these people don’t consider is the human impact behind this.
If Flash was to go away tomorrow, I’d find myself without a job. Well, I’d need time to learn another language and then I’d find another job but it wouldn’t be the same thing. I am really glad I found Flash and ActionScript 3. This is what I want to do for at least the next 5-10 years. What I like about it is that it speaks to both my programmer and creative side. It is also fast-paced; in the web agency world, you move from projects to projects really fast and you have to keep up with technology at the same time. It might seems weird but I really like that; no time to get bored. If it wasn’t for Flash, I don’t think think I would love my job as much as I do.
After the iPad announcement I found myself a bit confused and stressed about my future. The future of Flash seemed uncertain so my future seemed uncertain to. Not uncertain because of the evolution of technology (like HTML5) but because a company decided what the outcome should be. If all Apple products stop supporting Flash, this is not good news to me. What possibilities I had would lessen. Some would say that I shouldn’t tie myself to a technology, I know, and if I have too I will learn something knew, but as I said before I really like Flash. That made me think that it’s not only companies that can choose who gets to live or to fade (technology wise). Us, as developers, can put our weight in the balance too. As long as there will be people producing get content for the Flash platform, it will continue to thrive. If I like Flash that much, I must not be alone and from reading all those article that take Flash’s defense, I think I am right. So I feel more at ease now. The future is still uncertain but certainly less gloomy.
One last thing about the iPad. Zeldman in his post states that the computer of tomorrow is a computer that is dead simple but that in return doesn’t give all powers over it for the sake of usability, like the iPhone and the iPad do. I think that a portion of the population in fact wants that. Right now this portion might be big, but I think it will shrink because it doesn’t consider that the children that are raised right now have never seen the time when there was no computers. These will be way more computer literate than my parents lets say. For that I think a device like the iPad is closer to a toy than to a tool. If it wanted to dominate the netbook market, than it will fail. We don’t really know what is the role the netbook is going to take, but by making one that is limited in its usage, you also reduce your chance of getting it right.
Well that’s all I had to say.
How to make Collada model double sided in Papervision3D
Posted by zedia.net in Papervision 3D on September 16th, 2009
Well I searched for this for a little while and even tough it is pretty easy, if I didn’t figure it out at first probably other people had the same absence of mind. Also I find it hard to find example of Papervision3D and know which version was used; you find a lot of examples but you never know if the API changed since then so I am going to do a complete example with the version used.
The version used for this example is 2.1.92.
What I wanted to do was to load a Collada model in Flash an animate it. Every thing was going fine with the test models until I used the real models. You see the real models had holes in them that allowed you to see inside the model. Now if your material is single sided, when looking inside, you are going to see through the material and it will look buggy. The solution to this is just to make all material in your model (you can map multiple textures in one loaded Collada model), but that is not as easy as it sound. I tried a couple of options before hitting myself on the face. What did you learn back with ActionScript 2; wait till something is loaded before trying to modify it. This also applies to loaded models. Once loaded I made a little function that would cycle through all materials and make them double side.
Here is the code for the example :
//create all the actors of a Papervision3D scene var viewport:Viewport3D = new Viewport3D(1000, 800); addChild(viewport); var renderer:BasicRenderEngine = new BasicRenderEngine(); var camera:Camera3D = new Camera3D(); var scene:Scene3D = new Scene3D(); //create the DAE/Collada object and load the model var model:DAE = new DAE(false); model.load("model.dae"); model.addEventListener(FileLoadEvent.LOAD_COMPLETE , daeLoadComplete, false, 0, true); scene.addChild(model); //finally add the enter frame listener to render the scene addEventListener(Event.ENTER_FRAME, render, false, 0, true); function render(event:Event):void{ renderer.renderScene(scene, camera, viewport); } //this is where the magic happens, we cycle through all the materials of the model and make them double sided function daeLoadComplete(event:FileLoadEvent):void{ var matList:MaterialsList; var mat:MaterialObject3D; matList = model.materials; if ( matList ) { for each (mat in matList.materialsByName) { mat.doubleSided = true; } } }
I didn’t include the import statement because I plainly forgot to send them to myself, but I will update this post to add them. Have fun loading models!
How to connect to Google Analytics Data API in Flash
Posted by zedia.net in ActionScript 3 on June 5th, 2009
In one of my previous post, I explained how to connect to Google Analytics Data API in AIR. The problem with that way of connecting was that it only worked in AIR. In Flash it works locally, but as soon as you put in on your web server it stops working. Not it is cool to build an AIR (desktop) application that pulls data from Google Analytics, but it would also be cool to build a web application that does the same thing. Well I found out how to do just that. It is a bit more complicated because it involves a bit of server side coding, in this case PHP.
How the process works is that first you login to Google Analytics, Google will then send you a token that you must use when asking for data. So we will have two simple PHP files; one to login in and one to ask for data.
The first one looks like this:
<?php //this file is called get_token.php $user = $_REQUEST[user]; $pass = $_REQUEST[pass] require_once 'curl.php'; $curl = new Curl; $response = $curl->post('https://www.google.com/accounts/ClientLogin', array(accountType => "GOOGLE", Email =>$user, Passwd => $pass, service => "analytics", source => "zedia-GAStats-0" )); $tempArray = explode("Auth=", $response); ?> <root> <token><?php echo ($tempArray[1] ); ?></token> </root>
The second one looks like this:
<?php //this file is called call_ga.php require_once 'curl.php'; $url = $_REQUEST["url"]; $token = $_REQUEST["token"]; $curl2 = curl_init(); curl_setopt($curl2, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl2, CURLOPT_HEADER, "0"); curl_setopt($curl2, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl2, CURLOPT_URL, $url); curl_setopt($curl2, CURLOPT_HTTPHEADER, array('Authorization: GoogleLogin auth=' . $token)); $response2 = curl_exec($curl2); echo ($response2); ?>
As you can see to make my calls to Google I am using the cURL library that is usually already installed on your server if you have PHP. Also for the get_token.php I am also using the Curl class, made by Sean Huber, that just makes it easier to work with cURL. Upload these files to your server. Now that we have the server side figured out, we can move on to the Flash part; here it is:
package { import flash.display.Sprite; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLVariables; import flash.text.TextField; public class Main extends Sprite { private var loader:URLLoader; private var _loader2:URLLoader; private var _textField:TextField; private var _token:String; private var _buffer:String = ""; public function Main():void { loader = new URLLoader(); loader.addEventListener(Event.COMPLETE, _onTokenLoaded, false, 0, true); //this call will load the token loader.load(new URLRequest("http://www.YOUR_URL_WHERE_THE_PHP_RESIDE.net/get_token.php?user=YOUR_USERNAME&pass=YOUR_PASSWORD")); _textField = new TextField(); _textField.height = 300; _textField.width = 300; _textField.multiline = true; _textField.wordWrap = true; addChild(_textField); } private function _onTokenLoaded(event:Event):void { var tempString:String = String(loader.data); tempString = tempString.substring(1, tempString.length); var tempXML:XML = XML(tempString); _token = tempXML.token; _textField.text = _token; _loader2 = new URLLoader(); _loader2.addEventListener(Event.COMPLETE, _onFeedLoaded, false, 0, true); var request:URLRequest = new URLRequest("http://www.YOUR_URL_WHERE_THE_PHP_RESIDE.net/call_ga.php"); var urlVar:URLVariables = new URLVariables(); urlVar.token = _token; urlVar.url = "https://www.google.com/analytics/feeds/accounts/default"; request.data = urlVar; _loader2.load(request); } private function _onFeedLoaded(event:Event):void { _textField.text = String (_loader2.data); } } }
What you basically do is that you use your server to do all the communication between the Flash and Google. Everytime you will want a different feed to get different data you will call the call_ga.php file. It is that simple. If you have any question on this feel free to ask them in the comments.
An update on Flash SEO
I was just in Jim Corbett Flash Player Internal v2 presentation at FITC and I learned a couple new facts about SEO that I wanted to share.
First, it now seems that Google will be indexing loaded files; that was intented for a while and I will still have to make some experiments to see if it really works but Adobe says it works. Well it doesn’t really work like they would want it to work: when Google sees that the SWF is loading a file, it doesn’t load it in the currently playing Flash file but it makes a note of it and will load and reference that content later. The text in there will still be associated with the previous url, but it won’t play in the right context. That last caveat doesn’t bother me much; my biggest concern was that all the work I do is preloaded by an external preloader, so none of my content was Flash SEO friendly. Now it will get indexed.
Another interesting fact that was kinda hinted in the presentation was that the SEO Flash player is not suppose to index text when it is out of bound of the stage; when the user doesn’t see it. But, if you put a button outside of the viewable area and that button will bring the SWF in a state where text is displaying on the stage(viewable), that text will be indexed. The problem is that the headless player doesn’t check if the button is viewable or not. This is not confirmed and I will also have to make tests on this.
Well I have to get back in there now.
PureMVC Skeleton for Flash Applications / Websites
I have done a couple of site using PureMVC and Flash and it seems that at the beginning of a project I’m always doing the same things, creating the ApplicationFacade, the folder structure, the main fla, etc. I thought it might be useful to slap together a generic skeleton for a PureMVC Flash application or website. You can download it here:
All you have to do is in the src/com folder, rename the folder PROJECT_NAME to your project, and do a find and replace in files for PROJECT_NAME to replace it with what you changed the forlder name to. I didn’t include the PureMVC library in there because I suggest fetching the files from the official PureMVC website so that you always get the latest version. Once you get them, put them in the lib folder and you should be able to compile.
The rar file contains the following:
- Main.fla, Preload.fla
- Main.as
- ApplicationFacade.as
- StartupCommand.as
- ApplicationDataProxy.as
- ApplicationMediator.as
- IMain.as (Interface so that the preloader can use the init function of Main.as)
- the folder structure
This should help save half an hour every new PureMVC project.
Online Awards for Flash Websites
I compiled a small list of award websites at work and I tought it would be usefull to share it here too. I didn’t test any of those yet, so I don’t know which give the best results in term of traffic and visibility but here is what I have right now:
Favorite website awards (you have to pay) (25 words desc)
http://www.thefwa.com/
Dope awards (35 words desc)
http://www.dopeawards.com/
Design Licks
http://www.designlicks.com/
Best Web Gallery
http://bestwebgallery.com/category/flash/
Design Flavr (needs a screenshot of at least 523px)
http://www.designflavr.com/category/flash/
Design Snack (needs a screenshot 389 x 180px)
http://www.designsnack.com/
101 best websites (requires login)
http://101bestwebsites.com/category/flash
Inspiration Up
http://inspirationup.com
Website Design Awards
http://websitedesignawards.com/index.php/category/flash-gallery/
Spyline
http://spyline.de/section/flash
Creative Website Awards
http://www.creativewebsiteawards.com/
Mowsnet Web Awards
http://www.mows.sk/awards/index.php
iBlog
http://iblog.chubzz.com/
Another Bookmark
http://anotherbookmark.com/
Refresh links (nothing new since may 2008)
http://refreshlinks.org.uk/
Flash in the pan (seems outdated nov 2008)
http://www.flash-in-the-pan.org/
Flash Blasted (seems outdated nov 2008)
http://flashblasted.com/
Flash Galleria (seems outdated)
http://www.flashgalleria.com/
New Web Pick (requires a login and does not seem so relevant)
http://www.newwebpick.com/
I classified them by relevance from my first impression, so as you go down the list, the less relevant and usefull becomes the link. This list will have to be updated as I compile results from them.
Google Analytics For Flash; is it that usefull?
Posted by zedia.net in Google Analytics on December 10th, 2008
Not too long ago Google released Google Analytics for Flash. My first reaction was one of happiness; finally some attention would be put into Flash analytics. But after looking into it a bit more I found out that Google Analytics for Flash wasn’t such a big deal.
On Google Analytics side, nothing changed; no specific stats just for Flash, just the good old interface we all know. On the Flash side, nothing changed much there either; instead of doing this:
1 2 | ExternalInterface.call("pageTracker._trackPageview('/somepage');"); |
You now do this:
1 2 | tracker = new GATracker( this, "window.PageTracker", "Bridge", false ); tracker.trackPageview( "/somepage"); |
From the look of it, it’s actually more code than before.
The cool thing about GA for Flash is the ActionScript 3 mode. In that mode, you can call the tracker even if the JavaScript code wasn’t imported in the HTML page the Flash file is embedded. Now that is a possibility that we didn’t have before. So in a context where you do not have control over the HTML you flash will be embedded, this will enable you to do analytics just the same. I have also seen in the road map for the project that they want to implement it for Adobe AIR also; this will be very useful.
What will you be using Google Analytics for Flash for?
My article on Flash SEO on InsideRIA
Well I wanted to mention that one of my article was posted on InsideRIA. That was a great opportunity for me and I am already thinking about another article I could write for them. There is actually a good story (in my opinion) to tell about this.
I was at first writing a longuer article, about 6 pages or more long, on how Google was indexing Flash content. I was thinking that I could write it at the same pace that I write a post for my blog but I was wrong. I really wanted to write it in a professional way which is a bit different from this blog which I write in a more casual manner. I was putting a lot of pressure on myself and when I am pressured to do something I actually end up post-ponning it indefinitively. Well, in the mean time of all this post-ponning, Google changed its algorithm, so my artcile was good for garbage. That was my fault, because I had many occasions to finish my artcile and I just didn’t.
But there was a good side to this story too; if Google changed its algorithm, it means that I could write an article about it. That`s what I did but this time I wrote it in a more casual way and I didn`t care how long it would end up. So it gave: Google changes the way it indexes SWF content. As for now, I will start to try to write a longuer article and we will see where that ends up.
In the mean time, enjoy my half-done redesign!
Bookmarking in Flash: what can and can’t be done
Posted by zedia.net in ActionScript 3 on September 30th, 2008
I’m going to start this post by telling that you cannot bookmark a web page just by using Flash. You either have to use javascript or user interaction if you want to bookmark a page from within a swf movie. That being said, it is not the only show stopper. Believe it or not, the way you can bookmark a page is different for every browser. For once I think Internet Explorer did something better by allowing a javascript function to open up the bookmarking window of the browser. I don’t know why Firefox doesn’t have such a function because I don’t see any down side to it (there is a way you can kinda bookmark a page, but then it opens up in the sidebar which is not good at all). I have also read that there is a way of bookmarking in Opera but I have followed the instructions and was never able to make it work.
How to do it
First off, if we are going to support Internet Explorer and Firefox, we first have to tell Flash which broswer the user is using. The way we do this is by having a javascript function that detect the browser. This function sets a variable that is passed to the flash as a FlashVars telling it if the user is using IE or not. Here is an example of such a function.
Bookmarking in IE
Than if the user is using IE you can call a javascript function using ExternalInterface to make the bookmarking window pop-up. This is the simple part, but there is a catch to it; if the user is using the debug version of the Flash Player and lets the bookmarking window up for more than 15 seconds, the Flash Player will throw an error because it is waiting for the javascript function to finish executing and has a timeout of 15 seconds. The way to counter the erro window to pop up is by surrounding the ExternalInterface call in a try catch statement. Here is the ActionScript 3 code that I used:
1 2 3 4 5 6 | try{ ExternalInterface.call('addToFavorites'); } catch (error:Error) { //this is just so that if you leave the add to favorite window open for more than 15 seconds it doesn't send an error } |
Here is the javascript part of the code:
1 2 3 4 5 | function addToFavorites(){ if(window.external && document.all) {//ie window.external.AddFavorite(location.href, "Home Depot Canada - Redefine Floors"); } } |
Bookmarking in Firefox
Well, in Firefox you simply cannot initiate any procedure for bookmarking so the best you can do is tell the user to press the shortcut to bookmark this page. So when the user will press your “add to favorites” button in Flash, this will pop-in a window (inside the swf)advising the user to press Ctrl + D if they want to bookmark the page. This sounds like it should work because, really, there is nothing we are actually doing and we tell the user to do everything for us. But no this doesn’t work, there is this weird problem with focus relation between Flash and the browser. If you are interacting with an swf loaded by a browser (like pressing the ‘bookmark’ button), the Flash Player will be intercepting the keyboard keys that are pushed by the user. This is why sometime when you are on a Flash website the browser will just not respond when you press Ctrl + T to make a new Tab or Ctrl + D to add the page to your favorites. The Flash Player has the focus so in order to make this work we have to give the focus to the html part of the site. You can do this by using the focus() method of a input field. You first have to add a form in your html with just one input field and set the display style to none so that it won’t show. When the user clicks on your bookmark button you pop-in your message saying that the user can press Ctrl + D to bookmark the page and at the same time you call a javascript function giving focus to the not showing input field. That way the ctrl and d keystrokes will be caught by the browser and not the Flash Player.
Here is my AS code for it:
1 2 | //do your code here to show the pop-in message telling the user to press CTRL + D ExternalInterface.call('setFocus'); |
Here is the javascript
1 2 3 4 | function setFocus(){ document.getElementById("inputForBookmark").focus(); //inputForBookmark is the id I gave the input field in the HTML with style display:none } |
You would have thought by now that bookmarking would have been made easier, but no you still have to go trough all this to get it to work from within flash. My solution for the problem doesn’t work in all browser; it doesn’t work in Opera and probably not in Safari, but at least it works in the two most popular browsers. If anyone out there knows a better way, I’d be happy to hear about it.


