The following example shows how you can pause the indeterminate animation in a Flex ProgressBar control by setting the mode property to “polled” or “manual”. You can resume the animation by setting the mode back to “event”.
Full code after the jump.
Continue reading ‘Pausing the animation in an indeterminate ProgressBar control’
Loyal reader, Madhu, asked the following question the other day:
Is it possible to color individual headers of the accordion?
Well, I played around with it briefly this evening and it seems that you can get individual accordion headings using the Accordion class’s getHeaderAt() method, then it is just a matter of saving that reference in a variable, or applying a style directly to the returned Button reference.
The example itself is pretty simple, but I’m sure the same principles apply to other styles as well.
Full code after the jump.
Continue reading ‘Setting styles on individual Flex Accordion headers’
The previous example, “Using the URLVariables and FileReference classes to pass data from Flex to a server-side script”, showed how you could use the upload() method in the FileReference class along with the URLRequest and URLVariables classes to send data from your Flex application to a server-side script. Well, what happens if you want to send data from your server-side script back to your Flex application? Say hello to the uploadCompleteData event! This event gets dispatched after data is received from the server after a successful upload.
The uploadCompleteData event is not dispatched if data is not returned from the server.
The following example shows how you can set up an event listener for the uploadCompleteData event to display information about the file upload.
Full code after the jump.
Continue reading ‘Using for the FileReference class’s uploadCompleteData event to capture data from a server-side script’
We’ve already seen examples of using Flex to upload and download files (see “Uploading files in Flex using the FileReference class” and “Downloading files in Flex using the FileReference class”), but I’ve seen a lot of bugs/questions centering around the FileReference class lately so thought I’d try and do another example or two.
The following example shows how you can use a combination of the URLVariables, URLRequest, and FileReference classes to pass GET or POST variables to a server-side script while doing a file upload. In this example, we just happen to pass a simple text userID and the user’s Flash Player version, but it should be easy enough to modify the script slightly to pass more unique information to the server (such as a unique user token stored in a SharedObject or a browser cookie). I also added a crude little timer on the example to make it a bit classier.
Full code after the jump.
Continue reading ‘Using the URLVariables and FileReference classes to pass data from Flex to a server-side script’
The following example shows how you can specify a custom label function on a Tree control in Flex where the returned label is specific to the node name.
Full code after the jump.
Continue reading ‘Defining a custom label function on a Flex Tree control’
The followig example shows how you can pass parameters to an HTTPService by passing an Object in the HTTPService’s send() method. The remote ColdFusion script is a simple “hello world” type script which accepts a single parameter, “name”, and returns a single parameter, “welcomeMessage”.
Full code after the jump.
Continue reading ‘Passing parameters to an HTTPService’
A recent comment asked how you can indent the Accordion header text as setting the paddingLeft style wasn’t working as expected for them. Well, as it turns out, you need to set the paddingLeft style directly on the AccordionHeader style (Flex 2 and 3) or create a new style with paddingLeft style specified and use the headerStyleName style (Flex 3 only).
Full code after the jump.
Continue reading ‘Indenting Flex Accordion header labels’
The following example shows how you can resize a List control in Flex using the rowCount property. By setting the rowCount property, the List control is automatically resized so that only the specified number of rows are displayed.
Full code after the jump.
Continue reading ‘Resizing a Flex List control using the rowCount property’
The following example shows how you can create multi-line rows with wrapping text and variable row heights with the Flex List control.
Full code after the jump.
Continue reading ‘Creating multi-line list rows with variable row heights’
The following example shows how you can set some of the deprecated styles in the Accordion container (such as fillAlphas, fillColors, and selectedFillColors) by using the headerStyleName style.
Full code after the jump.
Continue reading ‘Customizing the Accordion header in Flex 3′
The following examples show how you can embed a font from a Flash SWF into a Flex application using @font-face in a <mx:Style /> block, or using the [Embed] metadata.
Full code after the jump.
Continue reading ‘Embedding fonts from a Flash SWF file into a Flex application’
The following example shows you how to change an embedded font’s appearance by setting the fontAntiAliasType style, fontSharpness style, fontThickness style, and fontGridFitType style.
Full code after the jump.
Continue reading ‘Setting a font’s anti-alias type, sharpness, thickness and grid fit type in Flex’
The following example shows how you can set and style a status message in a Flex Alert control by simply setting the status property (and statusStyleName style if you want to style the status message).
Full code after the jump.
Continue reading ‘Adding a status message to a Flex Alert control’
The following example shows how you can set both the titleIcon property and iconClass property for a Flex Alert control.
Full code after the jump.
Continue reading ‘Adding a title icon to a Flex Alert control’
The following example shows how you can use the trustContent property of the <mx:Image /> tag to allow you to apply certain effects to images loaded from a remote web site.
I was building a sample the other week and while it worked fine while testing it in Flex Builder, it had some issues when I deployed the SWF to the web. What was the problem? Well, my Flex SWF was trying to load an image from a remote website (www.helpexamples.com) and apply a Wipe effect (or something like that). The error I was getting was:
SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: <local SWF> cannot access <remote image>. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::BitmapData/draw()
at mx.effects.effectClasses::MaskEffectInstance/getVisibleBounds()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\effects\effectClasses\MaskEffectInstance.as:769]
at mx.effects.effectClasses::MaskEffectInstance/initMask()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\effects\effectClasses\MaskEffectInstance.as:648]
at mx.effects.effectClasses::MaskEffectInstance/startEffect()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\effects\effectClasses\MaskEffectInstance.as:461]
at mx.effects::Effect/play()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\effects\Effect.as:970]
at CrossDomain_test/___CrossDomain_test_Button2_click()[C:\Documents and Settings\peter\My Documents\Flex Builder 3\CrossDomain_test\src\CrossDomain_test.mxml:24]
So, after a bit of playing, I discovered that the solution was to specify the trustContent property for the Image control and set the value to true. Of course, after setting that, I got the following error when trying to test my Flex SWF locally, but it worked flawlessly when posted the SWF online:
SecurityError: Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property. <local SWF> was attempting to load <remote image>.
at flash.display::Loader/_load()
at flash.display::Loader/load()
at mx.controls::SWFLoader/loadContent()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1305]
at mx.controls::SWFLoader/load()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1177]
at mx.controls::SWFLoader/commitProperties()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\controls\SWFLoader.as:1005]
at mx.core::UIComponent/validateProperties()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\core\UIComponent.as:5580]
at mx.managers::LayoutManager/validateProperties()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\managers\LayoutManager.as:517]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\managers\LayoutManager.as:637]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\core\UIComponent.as:8368]
at mx.core::UIComponent/callLaterDispatcher()[E:\dev\flex\sdk\frameworks\projects\framework\src\mx\core\UIComponent.as:8311]
Full code after the jump.
Continue reading ‘Loading and modifying remote images’