how to use available skins in flex - apache-flex

How to use the skins shown on various sites e.g
flex skin site
into my flex project. Please help.

Take a look at the source for one of the samples.
Start here to load the first sample.
Then right click and select "View Source" from the context menu, to bring up the source.
You'll see this line of code in the main application file:
<mx:Style source="AeonGraphical.css" />
And that is how you include a css file in a Flex application.
Depending on the content of the CSS file; Flex may pick up the design automatically. Or you may have to specify a styleName on individual components.

Related

DNN Portal and Page relative images in custom skin css

I have a custom skin that I designed. It is used on more than one portal that I manage. I want to add the ability change a header image based on the page that is being displayed. This image is a background and I don't want to use a content pane to achieve this. Also, I would prefer to not use Java script either (but I have a feeling this will be necessary)
I know how to reference the skin path for resources, but this would put the same image on every portal and page. I want to have a default image like header_bg.jpg in an /images folder in each portal that uses the skin.
So I want to know if there is a way to get the relative root of the portal from the skin css file that is being used by that portal?
Thanks in advance
You could put the CSS into Portal.css for each of the portals, that gets loaded on every page of a DNN site, depending on which portal it is.
Portal.css loads after container and module CSS files.

Dynamically loading style in Flex AIR App

So i decided to implement some themes in my AIR app. I have converted my CSS files into SWF files, removed the Style linkage from my main file. Based on the user preferences stored in a file, I decide which theme to use. i.e; load the SWF file using StyleManager class.
I made my application window invisible, added a StyleEvent.COMPLETE event listener for the IEventDispatcher object returned by StyleManager.loadStyleDeclarations method. After the StyleEvent.COMPLETE occurs, I made my main window visible.
The problem i have now is, for a few seconds, i can see white canvases and all my components without any styles before using the style selected. I want to know if my approach is correct or do I need to make any changes to implement this properly?
Alright, so I seem to have figured it out myself. Getting some help from this link albeit.
Previously i read the settings in my applicationComplete and loaded the styles. So i guess all the UI components were created and added to the display list. They were bare naked without any style values.
So i changed the reading of the settings file to preinitialize, so that by the time the applicationComplete is triggered, AIR has already loaded the SWF stylesheet. So it will display the UI as i wanted.

CSS in a Flex 3 Library

I've made a library in flex with different components and my CSS I want to use in different projects (the goal of a library....).
BUT even if I can use my components, I can't use my CSS file which is in the library.
When I try <mx:Style source="assets/style.css" />, it wasn't found :(
So, how I should do to have a CSS file in my library which can be use in a project ??
Thanks for all your help
Right click your project in the package explorer and locate your CSS file. It should show up automatically if your source path is set up correctly and the asset is descendant of that directory. Then just make sure the checkbox next to the CSS file name is checked.

Flex External Stylesheet Conventions

I know that there are questions regarding this same topic, but for HTML. What are some good conventions in regards to using external stylesheets in a Flex app.? How would you break up the stylesheets (names of stylesheets and what they include)?
Flex compiles the external CSS file when you publish your project.
There is a way to load CSS at runtime using Flex; it can be done by compiling CSS files into SWF files and load them at runtime using StyleManager.loadStyleDeclarations.
See the LiveDocs on Stylesheets at Run Time for more info.
Some conventions we use in organizing stylesheets:
Have one main.css stylesheet that holds all of the data for skinning the base application.
Have one fonts.css stylesheet to store all of the fonts in the main app, because these can get quite messy.
The main.css stylesheet is included in the main swf via the <mx:Style source="main.css"/> tag. We load our app with as little as possible, and once everything is loaded, if we need to immediately show some text (sometimes we just have a video playing if it's an advertising site), we fade/tween in the main elements and load the fonts.css via StyleManager.loadStyleDeclarations at runtime.
If we have an admin panel, we have an admin.css stylesheet which we load at runtime because the main app doesn't need it.
We don't need to divide up the CSS anymore than that because we usually create a whole set of skins in a Theme, so the stylesheet is just applying those skins to components and is pretty lean (using Flex 4). I tend not do divide stylesheets into anything smaller (like "pages.css", "comments.css", "popups.css", or even "controls.css", etc.) because it would be overkill and too much to manage for little in return. That's common with HTML, but that's because HTML requires CSS for nice presentation; Flex could do without CSS entirely.
When developing, one of us usually develops most of the skin right away (having a default wireframe setup, like those found on ScaleNine as they do the photoshop/flash/after-effects. There's no way to not have to recompile the css swf if you make changes. But if it is loaded at runtime, you only have to recompile the css file and not the main swf, which is useful but not really useful during hardcore skin development.
I tried keeping the main stylesheet separate during development (in a custom Theme), and it made development a LOT harder, because I had to recompile the css separately every time I made a change and sometimes I had to recompile the main app too, and there were strange and hard-to-track-down bugs, etc. Then I was compiling two different apps. So I recommend keeping the main css file part of the main app.
If you wanted runtime css without having to recompile anything, try Ruben's CSS Loader and check out the source. But that would come at a runtime performance cost.
Flex is not something I've dealt with, but I did some research. It looks like the code to call a remote stylesheet is this:
<mx:Style source="com/example/assets/stylesheet.css" />
Flex Quick Start: Building a simple user interface: Styling your components says this:
Note: You should try to limit the
number of style sheets used in an
application, and set the style sheet
only at the top-level document in the
application (the document that
contains the tag). If
you set a style sheet in a child
document, unexpected results can
occur.
The implication of this seems to be that multiple stylesheets are not really possible. It sounds like what you want to do is organize your stylesheets, check out Organizing Your Stylesheets and Architecting CSS for some ideas for approaches. It looks like you have classes and basic tags, but the W3C stylesheet specifications are different from the Flex stylesheet specification.
As a non-Flex developer, Namespaces looks interesting as a way to organize namespaces: How to use the new CSS syntax in Flex 4.

Converting a Flex custom component to a module

How to take an existing custom component in Flex and convert it into a module?
EDIT: What should be done in the mxml where this custom component is used? Should it be replaced with a to load the module? If yes, how to deal with code that uses instances of the components?
Change the root mxml tag to <mx:Module... then in the properties of the project click on the "Flex Modules" button and add it in there.
Edit: This is assuming your modules are in the same project. I prefer to create new projects per module as it makes development easier with multiple developers. So what I do is create a new project, change the root to <mx:Module..., in the properties of the module project I disable it from creating the html wrapper, then in my main project I just load up the module swf's based on what menu item was clicked
You would need to place a ModuleLoader in place of the custom component like
<mx:ModuleLoader id="moduleLoader" width="100%" height="100%"/>
And load the Module using the url.
moduleLoader.unloadModule();
moduleLoader.url = "path\to\module.swf";
moduleLoader.loadModule();
You can keep the above code in a function and load modules.
If your module will be used in the same project only, you can create a new MXML Module that can be optimized for the project from FlexBuilder

Resources