Posts Tagged ‘air’

UILoader and borders ..

July 1st, 2008

Today i make a few of you fellow developers a very happy. When you are developing a image gallery you would like to draw a nice white border around your images. Now we all know that is not a problem when you are working with landscape format picture. Lets look at a common method used to give a UILoader a nice white border

JAVASCRIPT:
  1. import flash.display.Sprite;
  2. import flash.net.URLRequest;
  3. import fl.containers.UILoader;
  4. import flash.events.Event;
  5.  
  6. var myLoader:UILoader = new UILoader();
  7. myLoader.addEventListener(Event.COMPLETE, loadComplete);
  8.  
  9. myLoader.width  = 400;
  10. myLoader.height = 300;
  11. myLoader.x      = stage.stageWidth  * .5 - myLoader.width  /2;
  12. myLoader.y      = stage.stageHeight * .5 - myLoader.height / 2;
  13.  
  14. addChild (myLoader);
  15.  
  16. myLoader.load (new URLRequest ('BOY.JPG'));
  17.  
  18. function loadComplete (e:Event):void
  19. {
  20.  
  21. var myBorder:Sprite = new Sprite();
  22. myBorder.graphics.lineStyle(2, 0xFFFFFF);
  23. myBorder.graphics.drawRect (0,0,myLoader.width, myLoader.height);
  24.  
  25. myLoader.addChild (myBorder);
  26.  
  27. }

 

picture1

As you can see above here we have a cosmetic blooper because the border does not go around the inner content (where you want it) of the UILoader but the outer content of the loader its self leaving a black hole between your image and your border. :(

Not to worry my friends there is a solution to this little issue. If you trace UIloader.content you will see that it is in fact a Bitmap Object !. And what can you do with Bitmap objects my friends ? RIGHT !! Apply filters to them. I was abled to solve the issue by adding a filter to the content part of the UILoader on the stage its self. So lets remove the Sprite method and add a nice thin glow filter around it so i looks like a white border.  See for the proper code below...

 

JAVASCRIPT:
  1. import flash.net.URLRequest;
  2. import fl.containers.UILoader;
  3. import flash.events.Event;
  4. import flash.filters.GlowFilter;
  5.  
  6. var myLoader:UILoader = new UILoader();
  7. myLoader.addEventListener(Event.COMPLETE, loadComplete);
  8.  
  9. myLoader.width  = 400;
  10. myLoader.height = 300;
  11. myLoader.x      = stage.stageWidth  * .5 - myLoader.width  /2;
  12. myLoader.y      = stage.stageHeight * .5 - myLoader.height / 2;
  13.  
  14. addChild (myLoader);
  15.  
  16. myLoader.load (new URLRequest ('BOY.JPG'));
  17.  
  18. function loadComplete (e:Event):void
  19. {
  20.  
  21. var glow      = new GlowFilter (0xFFFFFF, 1,2,2,100);
  22. var oContent  = myLoader.content;
  23.  
  24. oContent.filters = [glow];
  25. }

 

picture2

 

Now you can see its all coming to gather in the end no need to worry any more we just acomplished our goal of putting a border around the inner content its self.

PS one more note

JAVASCRIPT:
  1. // <!-- SNIP
  2. var oContent  = myLoader.content;
  3. oContent.filters = [glow];
  4. // SNIP -->

As you see here im assigning the filter to a reference of the myLoader.content, i did this because myLoader its self is read-only so keep this in mind.

 

Download both the good and bad code here

in de 7e hemel met Adobe air

April 27th, 2008

Het was 4 april jongst leden, ik kon er niet bij zijn maar Lee Brimelow en zijn companen van Adobe waren van de partij in amsterdam om Adobe air te promoten. Ik vind het echt jammer dat ik er niet bij kon zijn want ik vind Adobe air echt een pracht uitvinding.

Wat is Adobe air ?.

Adobe air is een methode om je javascript / html en flash documenten om te toveren in windows bestanden met de exe extentie (wat in werkelijkheid niet waar is want het heefd een PK signature dus het is stiekem een zip bestand)

Als je deze methode gebruikt kan je dus je web apps op een buroblad gebruiken vooral media websites zullen hier een voordeel aandoen omdat zij hun media speler kunnen aanbieden op het buroblad van de gebruiker en met de term "Bekijk nu <site naam hier>" offline !!. Maar er is meer tussen hemel en aarde dan een media website dus ik ga aantonen hoe het ook in de voordeel van jouw website kan zijn.

Tijd voor actie

Ik heb als opvolger van mijn vorige artiekel (over google gadgets ) een feed reader gemaakt voor phpvrouwen.nl die een lijst met meest recente posts van mij/ons laat zien op de website. Deze app op zich is niet zo veel aan, Er zijn dan ook maar 68 regels voor nodig en zonder nuttenloze enters on de source op te schonen kom je waarscheinlijk op 50 echte regels code. hier volgt de standaard flash applicate ..

flahplayer

Je hebt flash player nodig om hier de rss reader te zien

Zorg er voor dat je Adobe air heb geinstalleerd en als je dan op het air icoontje clickt dan word de air versie van deze applicatie geinstalleerd. De air applicatie is het zelfde als je hier op de pagina ziet maar het verschil is dus... Ik breng mijn applicatie bij jouw thuis ..

Resources

Air player: hier
Flash player: hier
Rssreader (standaard) flash fla
Rssreader (Air versie) flash fla