• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Code to change state by time & day

New Here ,
Jul 29, 2010 Jul 29, 2010

Copy link to clipboard

Copied

Hi There,

I'm new to working with Flash Builder and have what I think is an easy question.

I work for a not-for-profit radio station and am creating an application that displays the personality that's on-air.  For example, Mon-Fri from 6a-10a I'd like it to show the morning show state, etc...  But on weekends show something generic.  I already have an XML data service that's working and displaying artist & title info... But for the life of me can't figure out how to change states by time.  I've googled and can only find state changes by button clicks, which I already knew.  Any help MUCH appreciated - thanks!

Views

464

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 30, 2010 Jul 30, 2010

Copy link to clipboard

Copied

Hi Izzy_Knight,

It depends on the time you would like this to happen. The easiest way would be to create a creationComplete event handler for the application (or the component you are creating) and then check the current time (using the Date class). On your desired times, change the state with setCurrentState() accordingly.

If you would like this to happen overtime, as-it-runs, then my suggestion would be to create a Timer object with 60000 milliseconds for example and make the same if statements there as well (you could also call, from inside your timer event handler, the initially called creationComplete handler with null as an input event).

Hope this makes sense.

Ioannis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 30, 2010 Jul 30, 2010

Copy link to clipboard

Copied

Ioannis-bels,

I'll be sure to give this a shot and let you know if this works.  Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 10, 2010 Aug 10, 2010

Copy link to clipboard

Copied

LATEST

You could use a Timer and TimerEvent.

[http://livedocs.adobe.com/flex/3/langref/flash/utils/Timer.html] and [http://livedocs.adobe.com/flex/3/langref/flash/events/TimerEvent.html]

var myTimer:Timer=new Timer(delay,repeatCount)

myTimer.addEventListener(TimerEvent.TIMER,functionThatWillChangeStates)

Hope this helps,

Balakrishnan V

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines