archive-com.com » COM » C » CRAFTYMIND.COM

Total: 161

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • main.mxml
    text Loading htmlOut text Loading else htmlOut text private function exeLoaded evt Event void removeEventListener Event ENTER FRAME loadAni var loader URLLoader evt target as URLLoader var byter ByteArray loader data as ByteArray var search String byter readUTFBytes byter bytesAvailable var index int for var i int 0 i byter length 11 i byter position i if byter readUTFBytes 11 d8 announce trace found at index i index i byter

    Original URL path: http://www.craftymind.com/factory/BlizzardDownloader/srcview/source/main.mxml.html (2016-04-27)
    Open archived version from archive


  • Hacking width and height properties into Flex’s CSS model | Craftymind
    case anyway Heres a complex menu system controlled completely with css including y positioning height changes and header visibility View Source We now have separation of content from style thats alot closer to what HTML offers and as a bonus all property based databinding continues to work on the values passed through CSS cm extHBox styleName header mx Label text Header Text cm extHBox cm extHBox id nav styleName navContainer cm extHBox styleName navItem mx Label text Nav Item 1 cm extHBox cm extHBox styleName navItem mx Label text Nav Item 2 cm extHBox cm extHBox styleName navItem mx Label text Nav Item 3 cm extHBox cm extHBox mx Button label Switch CSS click switchCSS y nav y nav height 2 header background color 000000 border style solid border color FFFFFF border thickness 2 color FFFFFF x 0 y 0 percent width 100 height 20 visible true navContainer background color 000000 border style solid border color FFFFFF border thickness 2 vertical align bottom horizontal align left padding left 3 x 0 y 20 percent width 100 height 50 navItem vertical align middle corner radius 5 border style solid border sides left top right border color FFFFFF border thickness 2 background color 000000 padding left 3 padding right 3 color FFFFFF height 30 Post navigation Previous Post Image smoothing in Flex Next Post Kick starting the garbage collector in Actionscript 3 with AIR 8 thoughts on Hacking width and height properties into Flex s CSS model Scott Schafer says November 10 2008 at 11 48 am This is very cool and useful thanks for posting it However it seems to have a limitation if you want to specify the position or dimensions of a component through CSS you have to put it in an extHBox What I really wanted is to be able to specify dimensions for say a text label directly in that text label s CSS declaration So here s what I came up with This is a Canvas that not only gets its position and dimension properties from its CSS declaration but gives the same flexibility to its children package view containers inspired by http www craftymind com 2008 03 31 hacking width and height properties into flexs css model This is a canvas that allows for the properties width height etc see the properties array to be set through the component s CSS file import mx containers Canvas import mx core IUIComponent import mx core UIComponent public class CanvasExt extends Canvas private static const properties Array width height percentWidth percentHeight x y visible public function CanvasExt super override public function styleChanged styleProp String void super styleChanged styleProp if styleProp styleProp styleName if runtime css swap or direct change of stylename updateProperties this for var i int 0 i numChildren i var child UIComponent UIComponent getChildAt i updateProperties child private function updateProperties obj UIComponent void for each var item String in properties var prop Object obj getStyle item if prop null obj item prop Alejandro Madrigal says November

    Original URL path: http://www.craftymind.com/hacking-width-and-height-properties-into-flexs-css-model/ (2016-04-27)
    Open archived version from archive

  • Source of FlexCustomCSS

    (No additional info available in detailed archive for this subpage)
    Original URL path: /factory/FlexCustomCSS/srcview/ (2016-04-27)


  • Image smoothing in Flex | Craftymind
    of smoothing both dynamically loaded images as well as embedded images in one simple script It also handles broken images gracefully Heres a quick sample showing the affects of scaling the Google logo with and without smoothing SmoothImage test case And the code used to create this Top Images mx Image source googlelogo width 60 height 25 mx Image source googlelogo width 200 height 90 mx Image source googlelogo width 400 height 180 Bottom Images local SmoothImage source googlelogo width 60 height 25 local SmoothImage source googlelogo width 200 height 90 local SmoothImage source googlelogo width 400 height 180 Post navigation Previous Post Saving class data to disk in AIR Next Post Hacking width and height properties into Flex s CSS model 9 thoughts on Image smoothing in Flex Fedlarm says May 9 2008 at 7 09 am very cool Here is it as a class package ipaper framework import mx controls Image import flash display Bitmap public class SmoothImage extends Image override protected function updateDisplayList unscaledWidth Number unscaledHeight Number void super updateDisplayList unscaledWidth unscaledHeight if content is Bitmap var bmp Bitmap Bitmap content if bmp bmp smoothing false bmp smoothing true Lance says June 13 2008 at 1 27 pm How would this work with an image that is being defined in the CSS file This is great BTW something I as a designer first seriously need to bring my artwork into flex Thanks Chetan Sachdev says August 2 2008 at 11 52 am Very nice example Thanks Maria says July 2 2009 at 11 55 am This code worked fine for me to make images look smooth I just wanted some of my imgages to implement this not all Check it here http askmeflash com article m php p article id 4 Francisc says February 24 2010 at

    Original URL path: http://www.craftymind.com/image-smoothing-in-flex/ (2016-04-27)
    Open archived version from archive

  • Saving class data to disk in AIR | Craftymind
    close return amf public static function writeFileObject fil File obj Object Object var stream FileStream new FileStream stream open fil FileMode WRITE stream writeObject obj stream close return obj These 2 static methods act as simple helper wrappers to read and write classes out to disk The example class we want to save below looks very similar to the type of class we use inside eBay Desktop package com ebay model import com ebay model SearchPreferences Bindable RemoteClass alias com ebay model UserPreferencesModel public class UserPreferencesModel public static const STANDARD String standard public static const SKINNY String skinny public var logoutOnClose Boolean false public var viewState STANDARD public var globalSearchFilters SearchPreferences new SearchPreferences private var maxHistoryItems uint 1000 public function set maxHistoryItems max uint void maxHistoryItems max public function get maxHistoryItems uint return maxHistoryItems In order to write a class out to disk and read it back in you have to add RemoteClass metadata to it It doesn t matter what the value is it just needs to be unique to the application This provides Flash with an identifier for linking amf data to class definitions when its loaded back in It doesn t matter what value you put in the RemoteClass tag but the best practice is to use the class name of the model you re saving Additionally in this example we d need to make sure both UserPreferencesModel and SearchPreferences model have RemoteClass metadata since caching the UserPrefencesModel will automatically attempt to cache the SearchPreferences as a child model Only public variables will be cached to disk so both the static values and the private var will be thrown out but the public getter setters will be cached Interacting with the cached data using AIRUtils looks like this private var fileRef File File applicationStorageDirectory resolvePath UserPreferences dat

    Original URL path: http://www.craftymind.com/air-utils-saving-classes-to-disk-in-air/ (2016-04-27)
    Open archived version from archive

  • eBay Desktop released! | Craftymind
    it becomes to the eBay user community Iâ m hoping to spend the next months worth of posts discussing some of the Flex and AIR techniques used in the app Post navigation Previous Post Actionscript 3 0 prototyping viable but costly Next Post Saving class data to disk in AIR 2 thoughts on eBay Desktop released Eddie Berman says February 29 2008 at 9 25 pm Great work I look

    Original URL path: http://www.craftymind.com/ebay-desktop-released/ (2016-04-27)
    Open archived version from archive

  • Craftymind | Hacking away at UI development | Page 8
    we were set to go right Well not exactly First off we learned that a call to System gc only does a mark OR a sweep on any given object but not both in the same call So in order to have the effect of releasing memory back to the OS we needed to call it twice in a row One call to mark any dereferenced objects and sweep away old marks and the second to now sweep away marks from the first call flash system System gc flash system System gc Now this seemed to be releasing memory back with pretty basic test cases but it wasn t working under production scenarios and we had to turn to Adobe engineers to help with the problem What we learned was that you have to contend with 2 different kinds of pointers when working in AS3 pointers that exist in bytecode and pointers that may exist in the Flash player itself that you d never know about What I started to realize was that the Flash player was never really engineered to be aggressive about memory usage It was designed to plug memory leaks and manage memory plateaus but not designed with an assumption that users would be interested in lowering those plateaus It makes sense because most Flash content is viewed in the browser for a short amount of time before the plugin is destroyed and all memory is released when a user navigates away With AIR the rules changed since users are more conscience of discreet application memory usage and applications might not always need the same memory when launched vs after 2 hours of usage First up we found that the Flash player was always maintaining a reference to the last Sprite clicked so if you destroyed an AIR window that the users had interacted with you couldn t get garbage collection to work until interacting with another window which can become a big problem if you re running in system tray mode and there are no windows to click in Secondly we learned that you have to push any existing enterframe handler off the call stack by creating a new one Adobe took care of the first problem but to handle the second one we had to change our GC call a bit private var gcCount int private function startGCCycle void gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC Another facet we hadn t considered was the affects of the Flex framework on garbage collection Flex kept some of the same design philosophy as the player itself mainly that end users were loading applications in the browser and then navigating away when done Garbage collection was therefore considered on a micro level involving user components but not at the framework level which could be guaranteed to exist throughout the life of the app Adobe made strides on patching the framework to work better in discreet Windows but ultimately some things couldn t be changed What we found was that CSS could not be defined in any mx Window component It had to be defined in the root mx WindowedApplication which would take care of declaring CSS globally for all windows Also we were forced to clear some global variables ourselves which caused our code to now look like this private var gcCount int private function startGCCycle void ContainerGlobals focusedContainer this gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC Lastly not all features in AIR could be unhooked with our enterFrame trick after another couple days of testing we found components that needed to be unhooked with Timers like the HTML component One last tweak to our garbage collection cycle and we were home free private var gcCount int private function startGCCycle void gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC setTimeout lastGC 40 private function lastGC void flash system System gc We were now able to successfully garbage collect any objects that have been dereferenced in Flash We had three things we had to look out for in the app now All display objects that added listeners on to model data had to be weakly referenced or they wouldn t be automatically dereferenced This is because our architecture kept model data alive while individual window stages were being destroyed I feel like I should point out that contrary to some beliefs it is not a good idea to apply weak references by default throughout your entire app Trust me when I say that its alot easier to debug an application with memory leaks due to strong listeners then it is to debug an app in which users report random failures because underneath the hood weakly referenced objects are getting accidentally destroyed when the GC kicks in You can never avoid bugs so you should program in a way that makes them consistent to find All asynchronous events needed to be explicitly shut down This included Timers Loaders File and DB transactions Setting these to be weakly referenced is not enough as all asyncronous objects in AS3 register themselves to the Flash player while they are running It is impossible to access objects that have been dereferenced in code but continue to be referenced by the player like a running timer No anonymous closures allowed After all this was taken care of we began to learn that garbage collecting objects in Flash didn t translate so easily to releasing memory back to the OS If you ever look at the memory graph in the Flex debugger and then open up the Task Manger or Activity Monitor to compare memory usage you ll notice a huge disparity between the two FlexBuilder reports only 15mb of AS3 object data

    Original URL path: http://www.craftymind.com/page/8/ (2016-04-27)
    Open archived version from archive

  • Blowing up HTML5 video and mapping it into 3D space | Craftymind
    around the video frame to blow up that part of the video the exploded pieces will continue to play the video inside them After a while they retract back to their original place One feature I didn t have time to figure out was adding depth to the explosion so pieces that are closest to ground zero fly up into the air as they sail outward With full shadow effects this could look really cool 3D Video This demo in particular runs really well inside webkit based browsers but not so much in Firefox Firefox doesn t appear to have any hardware acceleration for Ogg decoding so I had to drop the video size in half in order to run at acceptable framerates Even still Firefox chokes pretty badly on my Macbook Pro Update I ve changed the ogg video to be 640 x 360 prepare to see firefox weep Lessons learned There s a couple hints I found out along the way that are good to know if you want to play around with drawing video First you need a bit of hackish code to get this to work effeciently and it flows like this Video playing Draw Video onto Canvas 1 Draw fragments of Canvas 1 onto Canvas 2 Don t ask me why but copying pixel data out of a video tag is expensive so expensive that drawing it into a temporary canvas and then drawing pieces of that temp canvas onto a final canvas is faster then just referencing the video tag repeatedly within the same loop That s why you ll see 2 Canvases in the source code for the demos I m sure there s a technical reason for this duplication process but it s a lazy reason Secondly don t try copying individual

    Original URL path: http://www.craftymind.com/blowing-up-html5-video-and-mapping-it-into-3d-space/comment-page-3/ (2016-04-27)
    Open archived version from archive



  •