How to display logos in Flex 3.2? - apache-flex

I have been given the unenviable task of displaying a logo on a flex 3.2 form on our website. I'm learning flex as I go, and I can embed a logo now.
The problem is, I need to display a different logo, depending on which client the user works for. And I need to have it working by end of day, Friday, August 30th. As in, this Friday.
This is the code I have for embedding the logo:
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%" colSpan="6">
<mx:Image width="180" source="#Embed('/assets/images/logo.JPG')"/>
</mx:GridItem>
</mx:GridRow>
So, what I need to know is, is there any way to get Flex 3.2 to display a different logo for each client? The above code obviously isn't going to do it.
As a further bit of info, we do have the logos as blobs in the Oracle database.
Thanks for any help.

You need not embed, you can give path to the images on the server. like
<mx:Image width="180" source="http://somedomain.com/images/logo.JPG"
id='image'/>
OR, using the id of the image component, you can assign the logo dynamically, like the following
private function onCreationcomplete(e:FlexEvent):void
{
if(client ='xxyy'){
image.source = 'http://somedomain.com/images/xxyy.JPG ';
}
}

If you are familiar with BlazeDS, then you could try this approach: BLOB from Java to Flex via BlazeDS.
For the approach from #Zeus I would recommend to write an image servlet which delivers the client logo at request from your database blob.

Related

Flex application UI is gone and instead there is a completely white background?

My Flex application has seemingly disappeared. When I run the application it is showing a completely white background. There are no errors and it was working previously. I've ran clean and stepped back through my code.
The problem is I set the ID a component in my Application to "contentGroup". Even though no error was thrown this ID is used by the application and the application skin.
<components:ContentGroup id="contentGroup" width="100%" height="100%" />
To fix it use another ID:
<components:ContentGroup id="mainContentGroup" width="100%" height="100%" />

Cannot write accents in TextInput

i'm doing the maintenance of a flex application and i have a form to create new items:
<mx:FormItem id="frmName"
width="100%"
label="{Translate.getInstance().translateWords.name}"
required.edit="true"
required.new="true"
required.view="false">
<s:Label id="name_l"
width="100%" height="23"
text="{ myProgramVO.program_name }"
maxDisplayedLines="0"
lineBreak="toFit"
includeIn="view"/>
<s:TextInput id="name_ti"
width="100%" height="23"
maxChars="100"
maxChars.edit="100"
maxChars.new="100"
text="{ myProgramVO.program_name }"
includeIn="edit,new"/>
</mx:FormItem>
I don't know why, but i cannot write characters with accents when i'm creating a new program, but i can when i'm editing a program. And does not seem an unicode problem because i can type ñ without any problem.
The mxml file has <?xml version="1.0" encoding="utf-8"?> and the file is the same for item edition.
Can somebody guide me in the right direction?
PS: If anybody needs more code just ask for it and i'll paste in pastebin or something
After some research, it seems that there's nothing wrong with my code, it seem a problem with focus when mix html and swf.
When i try to create a new program, i need to mix html and flex, but when i edit the program there's no html code, and works well.
I got the problem only in linux (flash version 11.2), in windows (version 11.8) works perfectly, so seems a problem has been fixed
Thanks anyway guys :)

How to Create Advanced Flex custom components library

I want to create a custom component library. the components are customize-able during creation time. means like Accordion or TabNavigator, when we drag and drop the Accordion in flash builder it
<mx:Accordion x="38" y="167" width="200" height="200">
<s:NavigatorContent width="100%" height="100%" label="Accordion Pane 1">
</s:NavigatorContent>
</mx:Accordion>
look there is two tags came at a time mx:Accordion and s:NavigatorContent how it happens. how can i create a component like this.
I want to create a component of container with three buttons. after i drag component into flash builder it should editable mean its tag must look like this
<local:container x="38" y="167" width="200" height="200">
<s:button width="10" height="10" />
<s:button width="10" height="10" />
<s:button width="10" height="10" />
</local:container>
In order to add additional tags when the user drags your custom component into Flash Builder you'll have to write an extension for your component and configure it within a design.xml file.
Here are a few links to get you started:
Flash Builder Design View extension FAQ
Extending Flex Builder
Design View Extensibility Kit for Flex 4.5
First You want to understand one thing, that is creation of custom components is to simplify the tags. Though the flash builder also won't supports such kind of thing. The custom components child can be created internally by overriding some methods in it, which depends upon the base class you inherit.
Creation of Custom component will lead only to
<local:container x="38" y="167" width="200" height="200">
</local:container>
Though you can add child in it by manually or internally.

How to Import FileReference and FileSystemTree to ActionScript

I tried to insert a FileSystemTree in Flex .
Flash Builder doesn't recognise that and produces the error:
1046: Type was not found or was not a compile-time constant: FileSystemTree
Here's the code . It's a very basic one ....
<mx:HDividedBox width="100%" height="725" paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10" y="41">
<mx:VBox width="200" height="100%">
<mx:FileSystemTree id="fileSystemTree" width="100%" height="100%" change="onChange(event)" />
</mx:VBox>
<mx:Canvas width="100%" height="100%" id="content" ></mx:Canvas>
</mx:HDividedBox>
I'm using Flex 4 , Flash Builder 4. What am i doing wrong ? Is FileSystemTree supported in Flex 4 ?
That component is only available within Adobe AIR applications, not browser-based Flex applications, since browsing the local file system would violate the browser sandbox.
EDIT: Now that I understand your intention, yes, you can upload files from a flex application without having to use AIR. Instead of using the FileSystemTree component (which is AIR only), you use FileReference.browse() to allow the user to select a file from the local filesystem to upload. This page from the documentation will give you all the info you need: Working with file upload and download
Hope that helps.

Flex Forms: getting labels to line up, right-justified

I thought this was the default behaviour (all the Adobe docs seem to indicate that this is the case).
Say you have a form:
Name: [______]
Password: [________]
generally you want Name and Password to line up on their right-hand side (right justification). The length should be the length of the longest label.
When I add the following code to my MXML (authoring in Flex 4) it does not do that at all! But rather tjust crams everything left-justified, similar to the Name/Password example above.
What's the solution?
<s:Form id="directoryForm_A" width="100%">
<s:layout>
<s:VerticalLayout horizontalAlign="justify"/>
</s:layout>
<s:FormItem label="Click">
<s:Button label="Button"/>
</s:FormItem>
<s:FormItem label="Root Directory">
<s:TextInput x="0" width="100%" enter="handleUserSetRootDirectory(event)"/>
</s:FormItem>
</s:Form>
Which Adobe docs were you reading? You realize that the Spark Form are going to be very different than the Halo / MX Form. I would also suspect that the Spark form is not working yet.
Here are the docs on the Spark Form.
I think you'll benefit from reading the layout rules section of the FormItemLayout details. I cannot find the documentation that claims that all labels will be right aligned.
For anyone looking to a beta solution, Peter deHaan posts about this exact topic here: http://blog.flexexamples.com/2010/08/28/setting-the-text-alignment-on-a-spark-formitem-label-in-flex-hero/
Do note, since his example doesn't translate directly over to my issue:
adding to the for some reason disables the ability for the renderer to calculate the maxLabelWidth
Hope this helps others in the future.

Resources