Using date class to change the alpha of an object depending on time (GMT)

Hi,
I'm trying (and struggling) to get my head around AS3 and am building a flash webpage. I have 2 layers in the timeline, each containing a movie clip matching the page size with instance names backgroundDay and backgroundNight.
What I'm wanting is for the background to change for the day and night, so that from 18:00 to 06:00 the alpha of backgroundDay becomes 0 to show backgroundNight behind.
I'm been scouring the internet and haven't found anything so if anyone can help it'd be much appreciated. 
Many thanks,
Sophie

Yes, you could use a timer. Something like this:
var t:Timer = new Timer(1000);
t.addEventListener(TimerEvent.TIMER, timerHandler);
t.start();
function timerHandler(event:TimerEvent)
var d:Date = new Date();
backgroundDay.alpha = (d.hoursUTC > 5 && d.hoursUTC < 18) ? 1 : 0;

Similar Messages

  • How to use FilePermission class to change the file permission in Linux

    Hi all,
    I'm running in a issue related to changing the file permission under Linux environment. I'm using Suse 10.0 Linux and run jdk 1.5 java runtime.
    I want to create a file during execution time and change the permission of the same. I use File.createNewFile() API to create file. By default it does not have all the 3 permission (read,write,execute) for all the user ( user,owner,group). Through program I have to change the file permission ( equal to execute ,chmod 777 filename).I donot want to use runtime.exec() with chmod as the argument , since it creates a process to change the permission which may impact the performance. I want to try FilePermission class , by giving filename and permission as the argument. But it is not changing the permission . Could any one faced this problem ?
    If any body guides me, how to change the permission of the file under Linux using FilePermission class , it would be helpful.
    Thanks,
    Sankar

    How do I set the Umask prior to starting the program
    ? Could pls explain in steps.I don't think umask can help you. The mode mask prevents permission bits from being set when a file is created, but does not force any bits to be set. So if execute permission is not set explicitly when a file is created, umask will do nothing about it.
    But if you want more information about umask, see the man page for your shell script (sh, csh, etc.) or "man 2 umask".

  • How to change the alpha of a graphic symbol in flash depending on score

    i'm making a game and i don't know what script to use to change the alpha color of the graphic symbol i used.
    the game is a shooting game, ex: target points is 50, if the score is 25 the alpha color should be at 50%, if  score is 50 alpha is at a 100%
    hope someone could help..thanks!!!

    if that's a movieclip button and skeleton_mc is on the same timeline as the button, you'll need to use:
    _parent.skeleton_mc._alpha = score*2;
    if that doesn't work, in that button press, add:
    trace("button "+this);
    and on the timeline that contains skeleton_mc, add
    trace("skeleton "+skeleton_mc);
    and paste the output panel results here.

  • Can u  tell me any of you how to use Date class

    Can u tell me any of you how to use Date class. Please send me the source code.

    People won't send you the source code.
    Ask specific questions. You are very vague.
    Tell me how to build.

  • I  have just brought a preowned iPad mini which had the prev persons apple Id details still in,  I have my own I'd from my iPad I want to use. how do I change the prev persons details to enable me to use my details

    I  have just brought a preowned iPad mini which had the prev persons apple Id details still in,  I have my own I'd from my iPad I want to use. how do I change the prev persons details to enable me to use my details

    You should configure the ipad to factory settings and set up as 'new'
    settings/general/reset/erase all content and settings

  • I cannot use data and voice at the same time.

    I cannot use data and voice at the same time.
    I am on Wifi (connected) and at the same time I am on a voice call. when I switch to my RSS feed reader it does not sync it comes out with a message cannot connect to internet, I thought it is a problem with the feed reader application, IE 10 behaves the same I cannot browse when I am on a voice call.
    This is a very basic issue, am I missing something? Please help.
    My Model is lumia 820 with the latest portico update.
    TIA
    Sandeep

    I am aware that packet data via EDGE and voice cannot happen at the same time, surprisingly when I am on voice call I cannot connect to internet via Wifi too

  • A guest at our home used his ipad and changed the network name. How do I change it back to the apple network

    A guest at our house was using his ipad and changed the apple netwrok name to another and put a password on it.  How do I eliminate this netwrok and get back to the Apple Network?

    Please check out the following AirPort User Tip for details on resetting the password. Once that is done, you can access the base station to change its Wireless Name (or SSID) back to what you prefer. To discourage other "guests" from changing the AirPort settings, you should also change the default base station Administrator password.

  • Since I changed the operating system Windows 7 32bit to 64bit I can not use Firefox browser unless change the browser to safe mode.

    Since I changed the operating system Windows 7 32bit to 64bit I can not use Firefox browser unless change the browser to safe mode.When i start it the browser is not open and appears a message
    Mozilla Crash Reporter
    == Crash ID(s) ==
    20100611143157
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)

    the 20100611143157 is an update which won't instal automatically on my notebook

  • After i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

    after i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

    after i bought mac os x lion from web then download , after that to install but when they ask me to choose disk to install i can not choose, it say this disk does not use the GUID partiton table scheme. use disk utility to change the partition scheme. but

  • Can the new iPhone 5s bought from US be use in Asia by changing the SIM card?

    Can iPhone 5 bought from US use in Asia by changing the SIM card?

    an UNLOCKED ( only from Apple ) iPhone 5 will work on 3G but unlikely it will support 4G in your country
    http://www.apple.com/iphone/LTE/

  • I have a list a and want to use (CSR) Jslink to change the view but multiple fields

    I have a list but want to use CSR - jslink to change the view of multiple fields. Can a jslink have multiple fields to change. Looking at the samples
    here
    Would like to merge 2 or 3 script in one to do multiple things. Is this a best practice?
    Thanks in Advance
    Code snippet here below(tried this but not working for me.Sure im missing something): Trying to combine the prioritycolor and percentagecomplete together but not working
    // Create object that have the context information about the field that we want to change it's output render
    var fieldsContext= {};
    fieldsContext.Templates = {};
    fieldsContext.Templates.Fields = {
    // Apply the new rendering for Priority field on List View
    "Priority": { "View": priorityFiledTemplate },
    "PercentComplete": {
    "View": percentCompleteViewFiledTemplate,
    "DisplayForm": percentCompleteViewFiledTemplate,
    "NewForm": percentCompleteEditFiledTemplate,
    "EditForm": percentCompleteEditFiledTemplate
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(fieldsContext);
    // This function provides the rendering logic for list view
    function priorityFiledTemplate(ctx) {
    var priority = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    // Return html element with appropriate color based on priority value
    switch (priority) {
    case "(1) High":
    return "<span style='color :#f00'>" + priority + "</span>";
    break;
    case "(2) Normal":
    return "<span style='color :#ff6a00'>" + priority + "</span>";
    break;
    case "(3) Low":
    return "<span style='color :#cab023'>" + priority + "</span>";
    // This function provides the rendering logic for View and Display form
    function percentCompleteViewFiledTemplate(ctx) {
    var percentComplete = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    return "<div style='background-color: #e5e5e5; width: 100px; display:inline-block;'> \
    <div style='width: " + percentComplete.replace(/\s+/g, '') + "; background-color: #0094ff;'> \
    &nbsp;</div></div>&nbsp;" + percentComplete;
    // This function provides the rendering logic for New and Edit forms
    function percentCompleteEditFiledTemplate(ctx) {
    var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx);
    // Register a callback just before submit.
    formCtx.registerGetValueCallback(formCtx.fieldName, function () {
    return document.getElementById('inpPercentComplete').value;
    return "<input type='range' id='inpPercentComplete' name='inpPercentComplete' min='0' max='100' \
    oninput='outPercentComplete.value=inpPercentComplete.value' value='" + formCtx.fieldValue + "' /> \
    <output name='outPercentComplete' for='inpPercentComplete' >" + formCtx.fieldValue + "</output>%";

    Hi Patrick,
    It works in my test environment using your code.
    I suggest follow the steps as below:
    1. Save the following code as a js file (TaskListView.js) and upload it into the SiteAssets Document Library.
    2. Edit the list view page.
    3. Edit the list web part. Go to Miscellaneous -> JS Link.
    4. Add the following URL into the JS Link textbox.
    ~site/SiteAssets/TaskListView.js
    5. Click "OK" and save the page.
    If it still not works, please check whether active the Minimal Download Strategy feature in site feature or not.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Is there any way to stop my iPhone use data when i hit the data limit so i don't go over the data limit

    is their any way to stop an iphone 4s from using data when i hit the 2gb limit on verizon wireless this way i dont have to pay the fee for extra data
    thank you

    Don't know of any way for it to happen automatically, but you can still use the phone and send/receive sms with cellular data turned off.

  • 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(","));
    }

  • I have changed default language in the program & have set Language & region in system preferences. My Word (Mac2011) keeps on changing the default language to US english every time I check. Please help!

    I have changed default language in the program & have set Language & region in system preferences. My Word (Mac2011) keeps on changing the default language to US english every time I check. Please help!

    If you're having trouble making changes to files that are inside your home folder (represented by a house icon in the sidebar of a Finder window), or if you can't get changes to the settings of an application to stick, then please see below.
    Back up all data.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
    I've tested these instructions only with the Safari web browser. If you use another browser, they may not work as described.
    Step 1
    If you have more than one user, and the one in question is not an administrator, then go to Step 2.
    Triple-click anywhere in the following line on this page to select it:
    { sudo chflags -R nouchg,nouappnd ~ $TMPDIR..; sudo chown -R $UID:staff ~ $_; sudo chmod -R u+rwX ~ $_; chmod -R -N ~ $_; } 2>&-
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window (command-V). I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
    You'll be prompted for your login password. Nothing will be displayed when you type it. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command may take a few minutes to run, or perhaps longer if you have literally millions of files in your home folder. Wait for a new line ending in a dollar sign ($) to appear, then quit Terminal.
    Step 2 (optional)
    Take this step only if you have trouble with Step 1, if you prefer not to take it, or if it doesn't solve the problem.
    Boot into Recovery. When the OS X Utilities screen appears, select
    Utilities ▹ Terminal
    from the menu bar. A Terminal window will open.
    In the Terminal window, type this:
    res
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password dialog will open. You’re not going to reset a password.
    In the dialog, select the startup volume ("Macintosh HD," unless you gave it a different name) if it's not already selected.
    Select your username from the menu labeled Select the user account if it's not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
     ▹ Restart
    from the menu bar.

  • Changing the Color of an Object in Elements 4.0

    Neither of the two methods documented in Elements 4.0 to change the color of an object seem to work on my object. It is a fleur-de-lis that I extracted from a PDF an artist made for me some time ago. It's now black and I want to make it gold. What am I doing wrong?

    Harold McDougal wrote:
    The first is to select Enhance, Adjust Color, Change Color, select the color to be changed with the eye dropper and the color to change to in the bottom window. Then select okay. Okay. In my case, nothing happens.
    The color replacement command doesn't work on pure black or white. 
    If the design is black over white, try using a solid color fill and one of the lighten blend modes.
    How?
    Sample the gold color you want and have it as the foreground color chip.   Add a solid color adjustment layer over your  black and white design. The color should automatically be the foreground color in your tool box. Since should have changed this swatch to the desired shade of gold, it should be gold. Now, for the magic. If you change the blend mode of the solid color fill layer to "lighten", "screen", "linear dodge", or "lighter color", the black will be replaced by your gold.
    Note: I'm not sure which if any of the Elements versions includes the "lighter color" blend mode so if you can't find that one...don't panic.

Maybe you are looking for

  • Editing Content in Table Of Contents

    I've been able to create a nice looking TOC with Pages, and formatted it well. However, there are a few widow lines. I need to push a few lines onto another page. So I'd like to be able to insert blank lines or page breaks into the TOC in order to ma

  • How to make file smaller

    I need to make iphoto pictures smaller than 3mb...please help I need to upload into another program. thanks

  • Pre trip approval workflow

    Hi Experts , I am working on Pre trip approval workflow. Functionality : Employee signs in the portal and send the request for trip plan . Manager has 3 options 1. approve 2. reject 3. send back for correction . Issue : approve and reject is working

  • Onbehalfof element in ws-trust

    Hi All, I am not sure I am in the right place posting my question. Please direct me if this is not the right place. I am evaluating Oracle STS for implementing ws-trust for token exchange My scenario is as below client ------------sends a msg with a

  • Corrupt datablock of datafile reside on RAW devices

    Hi, I want to check BOLCKRECOVER for corrupt blocks on datafiles reside on RAW devices. Is there any tool/command tp corrupt datablock of datafile reside on RAW devices? Thanks,