Changing the source of mx:Style at run time

Is there a way to be able to change the stylesheet for an
application at run time? Or is the only way to handle it on the
server?

For those who might be interested, here is a class that will
load a xml file (that describes styles) and applies the styles
found to your application.
The xml file is in the format:
<?xml version="1.0" encoding="utf-8"?>
<dynamicStyles>
<Application selectorType="type"
backgroundImage="images/background.jpg"/>
<ApplicationControlBar selectorType="type"
highlightAlphas="0.5, 0.25"/>
<ToggleButtonBar selectorType="type"
highlightAlphas="0.5, .25"/>
<viewPanel borderStyle="solid" borderThickness="1"
borderColor="#efefef" backgroundColor="#d0d0d0"
backgroundAlpha="0.5" color="#170505" cornerRadius="5"
dropShadowEnabled="true"/>
<infoPanel borderStyle="solid" borderThickness="1"
borderColor="#7f7e7e" backgroundColor="#ffffff"
backgroundAlpha="1.0" cornerRadius="5"
dropShadowEnabled="false"/>
<infoLabel fontSize="11" fontWeight="bold"/>
</dynamicStyles>
The AS class is the following (be sure to name the .as file
that same as the class name and modify the "package" section yo
include any path required by your setup.
package
import mx.styles.CSSStyleDeclaration;
import mx.styles.StyleManager;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.*;
import flash.xml.XMLNode;
import flash.errors.IOError;
public final class RuntimeStyle
private var _source:String;
public function get source():String {
return _source;
public function set source(value:String):void {
if (value != _source){
getStylesheet(value);
_source = value;
private function getStylesheet(value:String):void {
var urlRequest:URLRequest = new URLRequest(value);
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,
ioErrorHandler);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityErrorHandler);
urlLoader.load(urlRequest);
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
var xmlDoc:XML = new XML(loader.data);
applyStyles(xmlDoc);
private function ioErrorHandler(event:IOErrorEvent):void {
throw new IOError("Error Attempting to load
RuntimeStylesheet:" + source + " Original Error: " + event.text);
private function
securityErrorHandler(event:SecurityErrorEvent):void {
throw new SecurityError("Error Attempting to load
RuntimeStylesheet:" + source + " Original Error: " + event.text);
private function applyStyles(xmlDoc:XML):void {
var xmlList:XMLList = xmlDoc.children();
for each(var node:XML in xmlList) {
if (node.@selectorType == "type") {
var cssStyle:CSSStyleDeclaration =
StyleManager.getStyleDeclaration(node.name());
if (cssStyle != null)
setStyle(cssStyle, node);
else {
var cssStyleDeclaration:CSSStyleDeclaration = new
CSSStyleDeclaration();
setStyle(cssStyleDeclaration, node);
StyleManager.setStyleDeclaration("." +
node.name().toString(), cssStyleDeclaration, true);
private function
setStyle(cssStyleDeclaration:CSSStyleDeclaration, node:XML):void {
var attributes:XMLList = node.attributes();
for each(var attributeNode:XML in attributes) {
var attributeName:String = attributeNode.name().toString();
if (attributeName != "selectorType") {
var attributeValue:String =
node.attribute(attributeName).toString();
if (attributeValue.indexOf(",") == -1)
cssStyleDeclaration.setStyle(attributeName, attributeValue);
else
cssStyleDeclaration.setStyle(attributeName,
attributeValue.split(","));
}

Similar Messages

  • How to change the font size and style on run time

    dear all
    i try to change the font style and font size on runtime. I did the following:
    1- i created an item(:font_size) in which i will write the size of the font for the the other item ('customer_name')
    2 on the post_change trigger for 'font_size' i write this code
    SET_ITEM_PROPERTY('customer_name',FONT_size,(:font_size);
    i write 12 then then font size changed , then i write 18 , the size does not change. and when i write any value , no change happens. I do not know why
    the second problem is how to change the font style
    i made three checkbooks (bold,italic,underline)
    on the trugger when_checkbox_checked i write
         IF :BOLD = 'B' THEN
         SET_ITEM_PROPERTY('N_SAMPLE',FONT_STYLE,'BOLD');
         ELSE
    SET_ITEM_PROPERTY('N_SAMPLE',FONT_STYLE,'REGULAR');
         END IF;     
    no change happend at all.
    please help

    Hi friend,
    it's a really really strange tip... May be it's a Forms bug? I've tried with set_item_property..and.. you're right, it doesn't work..
    So.. you can try making this:
    - create a visual attribute with an specific font size....
    - use the
    SET_ITEM_INSTANCE_PROPERTY('block.item',CURRENT_RECORD,VISUAL_ATTRIBUTE,'you_visual_attribute');
    and call it from psot-change....
    It works
    Hope it helps,
    Jose.

  • Is it possible to change the visibility of a inputText in run-time?

    Supposed my jsp has a radio-group with two radio buttons called "visible" and "invisible" and an iputText component. What I want is: at the beginning the inputText is visible and enable. If I click the "invisible" this inputText will changed to invisible and disable. And if I click the "visible" this inputText can be seen and enable again.
    Can I do this with JSF or just with java script?

    To enlarge on what rlubke has been saying.
    <h:outputLabel rendered="#{! loginBean.loggingOut}"  style=" color:rgb(198,0,0);" value="#{i18nBean['USER.VMP010.ITEM6']}" styleClass="PageTitle"/>See how the rendered attribute is deriving it's value from a bound boolean expression. The expression "loginBean.loggingOut" evaluates to a method-call "loginBean.isLoggingOut()" which should return true or false. The "!" operator can be used in much the same way as you use it in Java.

  • How to change the source ip address

    hi all,
    i got the problem that how to change the source ip address when i
    get a website's page!
    i mean i want to change the source ip address when i access the
    remote website, sure i know when change the source ip, i can not get
    the result correctly when changing the source ip address, but it is not
    important to get the result i just want to send out a "click" event to the website by calling a post method in the site!
    does anybody have some ideas?
    Best Regards,
    Eric Gau

    Here's some code that connects to google and does a get:
    import java.io.*;
    import java.net.*;
    public class HTTPTest {
        private Socket sock;
        private BufferedReader in;
        private BufferedWriter out;
        private boolean running = false;
        HTTPTest() {
        private void go(String site) {
            try {
                sock = new Socket(site, 80);
                in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
                System.out.println("Connected");
                out.write("GET / HTTP/1.1\r\n\r\n");
                out.flush();
                doRead();
            } catch (IOException e) {
                e.printStackTrace();
        private void doRead() {
            running = true;
            String line;
            System.out.println("Read started");
            while (running) {
                try {
                    line = in.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                    line = null;
                if (line == null) {
                    running = false;
                } else {
                    System.out.println(line);
            System.out.println("Socket closed");
        public static void main(String [] args) {
            String site;
            if (args.length > 0) {
                site = args[0];
            } else {
                site = "google.ca";
            new HTTPTest().go(site);
    }

  • Change the source system

    Hello
    In our Quality Box , I need to change the source system connection (from QR1 to QR2). I created the new connection successfully. Now the issue is all the Transfer structure still using OLD connection ( i.e QR1) . I run BDLS and it did not word. How can I re-assign the new source system (QR1)  to all of my Transfer structures in one go. Is there any report ?
    Farooq

    Hello,
    You cant directly convert the existing objects for a source system to the new source system.
    For that you need to do a transport of the objects to the QA box while maintaining the entry in BDLS to convert to the new source system.
    Regards,
    Shashank

  • Change the Frame content Control style

    Hi,
    Is any way to change the style of current Frame content control  as dynamically...?
    I am using Frame control and navigating to Test.xaml, Test.xaml contains some windows Label control  with styles, So Need change the Test.xaml label color dynamically, while it's in Frame, How..Please help me...?.
    Frame.Navigate(typeof(Test));
    After navigating in to Frame, I need change the Test.xaml control styles  how..?

    Try this:
    1) Create some public static Brushes inside Test.xaml.cs
    2) In the setters for these brushes, assign the value to the Labels
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • Change the source for a media player based on selection from a list.

    All of this is referring to my public facing website in Office 365.
    I put the following code in a content editor web part:
    <audio controls>
      <source src="http://someserver/somefile.mp3" type="audio/mpeg">
    </audio>
    This works just fine. 
    What I want to do, is display a table below this which is a list of mp3's. when the user clicks on one of them the audio plays in the <audio controls>. 
    In other words, I want to change the source of the above player when I click on a link elsewhere in the page.
    Thank you
    Joe Fager

    What you'll need to do is have a javascript onclick/onchange event in the dropdown that runs a set of code that will reset the audio control with the new source. That can be done with jQuery.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • Any way to permanently change the source?

    Got an eMac and an Intel-based Mac mini, both running 10.5 with all current updates. The mini contains my iTunes-managed movie library. I can use Front Row on the eMac to access the mini's movie library, but I need to change its source from the local iTunes library (which is empty on the eMac) to the mini. Not a problem, but it's annoying to have to do this all the time.
    Is there any way to permanently change the source on the eMac so that it always points to the mini?

    Anyone? Anyone?

  • Changing the source system in QA

    Hello All,
    I just wanted a quick opinion from your experience on the following issue:
    We  have a ECC Dev client 20 connected to BI Dev client 20
    Similarly we have ECC QA 120 connected to BI QA 120
    But due to some reason we now want to connect a new ECC QA client 150 to BI QA 120 and take out ECC QA 120 totally(120 is wiped off).
    I already have a lot of development transported to BI QA where the source system is ECC 120. Now if 120 dies and we pull the data from 150, what are the pitfalls to watch for?
    Like all my Master data objects , DSO and Cubes still point to ECC QA client 120 but now the "actual" source system is going to be ECC QA 150.
    Points,
    Gaurav

    You need to replicate all the data sources in BI from QA 150 and change the source system assignment to 150 instead of 120.
    Also, you need to reinitilase delta for delta enabled extractors.
    Two  things to watch out:
    1.  If you dont have source system identifier,  then if you happen to get records with same key, then it will overwrite. This applies to both master and transaction data.
    2. For transaction data that is not delta enables, there may be a possibiltiy with which the records will get duplicated. So, better to delete the old requests before reload the data from QA150.
    Ravi Thothadri

  • How can I change the source file so it is direct from external hard drive?

    I am trying to make a movie on imovie of a snowboarding trip that I went on, there is around 80 to 100 gig of mp4 movies that will not fit on my computer that I have stored on my external harddrive. I had the movie half finished then found I could do no more as I had no space left in my mac. I had to delete everything and start again but I'm not doing this until I can find a way of changing the source file so I can take them direct from my external hard drive as to not use up all my computers available space. I have moved imovie to my external hard drive but it still tries to read from a movie file on my mac, how can I change that so it will read from a source file on my external hard drive, is it possible?? Can someone help me??

    Hi Bengt, Thanks for your input, much appreciated.
    I have a WD 1TIG hard drive and are using usb connection, is it possible to use fire wire with these? I have had trouble with a lot of the videos I Imported, once they downloaded the file in the viewer window showed up blank and when I mouse over them it places a picture of another file in the window and wont drag and drop into the movie window, like their corrupted or something? Had to delete just about all of them and start again. Also is it possible to select a bunch of videos in the viewer window as to change the dates to the correct dates? All I have been able to do is "select all" which is no help.

  • Assets panel styles, can i change the color of a style to be an exact color?

    Assets panel > styles, can i change the color of a style
    to be an exact color? for example, if i want to create a navbar
    with the black and gray glass affect style, but i want to change
    the color but keep the same style of shading. each style in the
    assets panel has a default color, but i want to change the color
    and keep the style. i did change the color a little bit by
    adjusting the hue and saturation, but i can't seem to get an exact
    match of the color i am trying to duplicate. any help is greatly
    appreciated thanks

    When a style is applied to any object, the Properties panel
    at the bottom will reflect the attributes which are editable in
    that applied style. The properties which can be edited are fill and
    stroke colors also apart from adjusting the Hue and Saturation.
    Gradient colors can be modified by changing the fill color.
    The nodes in the gradient will change the color from blue to black
    or any other intended color of change. If you know the color you
    can either enter it as a 6 digit value or you can pick a color from
    an existing object.
    Hope it helps. Let me know I am missing you query
    completely.

  • How to change the source type for a primary key on a form?

    Hi,
    At the time of creating a form, I had set the source type for the primary key to an existing sequence.
    Now I want to change the source to a trigger.
    Can anyone suggest how to do it?
    Thanks in advance,
    Annie

    Annie:
    Define the trigger and then delete the page process named 'Get PK'
    Varad

  • Automating Importing a Visio OLE Object or Changing the Source of a Previously Imported OLE Object

    My colleagues and I import our Visio files into FrameMaker 10 via the following mechanism: File > Import > Object... > Create from File (with Link checked).  We do this because, for us, the benefits of object linking and embedding outweight the pitfalls. In order to institute and automate a graphic file naming convention, I want to be able to do one of the following using ExtendScript:
    Replace each Visio OLE object with that of a renamed or new Visio file. (I've tried using the Import() method  with many different import-script settings, but have not found the correct import-script, if such a thing exists for importing Visio files  imported by reference and linked as OLE objects. My typical error when attempting this is FV_DisallowedImportType, which indicates the source file type is disallowed by my import-script settings. When I talk about my import-script settings, I'm referring to the adjustments that I make to the parameters returned from a call to GetImportDefaultParams().  I've tried numerous import-script combinations but have had no luck. )
    Rename the Visio source file and change the source file of an already-linked Visio OLE object.  (To do this, I need to determine how to implement a script that equals the following user actions while a FM document is open: clicking on Links... under the Edit menu to bring-up the Links window; selecting each link displayed in the Links window; clicking the Change Source button for each selected link; entering the new file name in the File name field of the Change Source window; clicking Open.  Needless to say, I found nothing in the ExtendScript capabilities that indicates that this approach is doable. It may be doable using FDK F_Codes, I haven't explored that avenue and would like to avoid it.)
    Modify the OLE2 facet such that it points to the renamed file instead of the previous name for the file.  (This does not seem like a clean approach.  As is the case now, I don't know how to properly update the facet with the new file name.  I've experimented with simply changing the file name strings from new to old, but that does not work.  There's probably some error-checking or checksum that needs to be recomputed.  Bottom line: I don't know enough about facets.)
    Any help would be greatly appreciated.
    Thanks, Paul

    Hi Paul,
    I tried doing something like this years ago with FrameScript, but found out that the OLE stuff is not exposed to FrameScript or the FDK. So it is probably not exposed to ExtendScript either. When you query an OLE graphic's InsetFile property, it returns a null string, the same as a graphic Imported by Copy would. As far as I can see, importing as an OLE object is only available through the Windows FrameMaker interface.
    Rick

  • How to change the source system for just a datasource

    Hi,
    Our test/development BI system ( BI 7.0 Unicode ) is connected to our development system and to our test system, 1 BI system connected to 2 R/3 systems.
    During some time, the test system won't be available so all datasources that point to the test system must be connected to the development system. In RSA1 is not possible to change the source system in a datasource: RSDS 057
    'Creation of DataSources for SAP source system D30CLNT007 is not permitted' , same error trying to copy the datasource,.
    Any idea about how to proceed ?
    Regards,
    Joan

    Hi,
    If I try to repliclate metadata in the datasource, message RSAR 051 appears: 'error when opening an RFC connection'. This error is expected because the logical system pointed in the datasource does not exist.
    Is not possible to change the source system in datasource ( in RSA1 ) because the field is always greyed, also if I try to copy the datasource the message RSDS 057 appears.
    Any idea about how to proceed ?
    Regards,
    Joan

  • Change the source of place holder dynamically in report

    Hi,
    We need to assign values to place holder dynamically in report pages based on the page number.
    Basic requirement is to have dynamic images (generated in before report trigger with file name having timestamp and page number) in dynamic pages (getting repeated based on number of lines in the report).
    Is there any way we can have a place holder mapped to this field (Read from file, type: Image) and change the source dynamically when each page is formatted?
    Any pointers for this will be helpful.
    Thanks,
    Ayyappa

    Hi,
    We need to assign values to place holder dynamically in report pages based on the page number.
    Basic requirement is to have dynamic images (generated in before report trigger with file name having timestamp and page number) in dynamic pages (getting repeated based on number of lines in the report).
    Is there any way we can have a place holder mapped to this field (Read from file, type: Image) and change the source dynamically when each page is formatted?
    Any pointers for this will be helpful.
    Thanks,
    Ayyappa

Maybe you are looking for

  • ITunes thinks songs are missing when they are NOT...

    I've written about this in the past and I thought I had fixed it manually. For some reason a large number of my songs (about 1300) in iTunes are not able to be found on the drive when I try to play them. Once I try to play them I get an error message

  • Iphone 4 wont be recognized by itunes

    ok so i tried reverting my iphone 4 back to factory settings and it looked like nothing was happening so i unplugged it and plugged it back in and then it said connect to itunes and it wont connect then i tryed putting it DFU mode and now it wont tur

  • Problem with this run

    get this error: 500 Internal Server Error javax.faces.FacesException: #{backing_SaveBkg.commandButton_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException     at com.sun.faces.application.ActionListenerImpl.processAction(Action

  • Updating to Lion on my macbook and not able to access iPhoto

    I have updated my macbook (Mac OS X) to Lion but I can't seem to update iphoto. I have no access to iphoto and there is a wheel that continually spins saying it is updating, but it is now Day 7 and there is no update and there are no photos. Help!

  • Slow Adaptive Resolution Update

    We recently setup a monstrous workstation in studio by BOXX. Everything runs great however there is a sluggish update and response in the viewer of After Effects when moving a camera or scrubbing through a scene. Lite scenes have no issue....but slig