Help in AS3 code of 24 hour countdown timer

hello,
i  just wanna ask if someone can help me,
i created a 24 hour flash countdown timer here http://allofmyworks.weebly.com/flash.html
the problem is when it reaches the desired time, the time still counts and became negative,
what i want is to make it only 24hour countdown clock and when it reaches the time it will only stay in 00:00:00
thanks
here is the code i used
var endDate:Date = new Date(2012,0,4);
var countdownTimer:Timer = new Timer(1000);
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
countdownTimer.start();
function updateTime(e:TimerEvent):void
          var now:Date = new Date();
          var timeLeft:Number = endDate.getTime() - now.getTime();
          var seconds:Number = Math.floor(timeLeft / 1000);
          var minutes:Number = Math.floor(seconds / 60);
          var hours:Number = Math.floor(minutes / 60);
          seconds %= 60;
          minutes %= 60;
          var sec:String = seconds.toString();
          var min:String = minutes.toString();
          var hrs:String = hours.toString();
          if (sec.length < 2) {
                    sec = "0" + sec;
          if (min.length < 2) {
                    min = "0" + min;
          if (hrs.length < 2) {
                    hrs = "0" + hrs;
          var time:String = hrs + ":" + min + ":" + sec;
          time_txt.text = time;

here is the code
var endDate:Date = new Date(new Date().getTime()+24*60*60*1000);
var countdownTimer:Timer = new Timer(1000);
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
countdownTimer.start();
function updateTime(e:TimerEvent):void
          var now:Date = new Date();
          var timeLeft:Number = endDate.getTime() - now.getTime();
          var seconds:Number = Math.floor(timeLeft / 1000);
          var minutes:Number = Math.floor(seconds / 60);
          var hours:Number = Math.floor(minutes / 60);
          seconds %= 60;
          minutes %= 60;
          var sec:String = seconds.toString();
          var min:String = minutes.toString();
          var hrs:String = hours.toString();
          if (sec.length < 2) {
                    sec = "0" + sec;
          if (min.length < 2) {
                    min = "0" + min;
          if (hrs.length < 2) {
                    hrs = "0" + hrs;
          var time:String = hrs + ":" + min + ":" + sec;
          time_txt.text = time;

Similar Messages

  • Help me about AS3 code of 24 hour countdown timer.

    Hi,
    I'm a beginner at flash.
    i  just wanna ask about making 24hours countdown clock.
    what i want is to make it only 24hour countdown clock and when it reaches the time it will start again.(every day)
    and The start time is 2 o'clok(2 pm) every single day.(for the pacific time)
    and I found this code from (http://forums.adobe.com/message/4116774 )
    It's similar with what i want but even I tried, I can't change for mind...
    and I want using hundredths too.
    so here is the code.
    Please help me,Thank you.
    var endDate:Date = new Date(new Date().getTime()+24*60*60*1000);
    var countdownTimer:Timer = new Timer(1000);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
    if(now.getTime()>endDate.getTime()){
         time_txt.text = "00:00:00";
    countdownTimer.stop();
    return
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var hundredth:Number = Math.floor(timeLeft / 10);
              var seconds:Number = Math.floor(hundredth / 1000);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              seconds %= 60;
              minutes %= 60;
              var fs:String = hundredth.toString();
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (fs.length < 2) {
                        sec = "0" + fs;
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec;
              time_txt.text = time;

    Thank U , and so sorry I have problem.,..
    It Just stop and It was not start again..........What should I do?
    because I wanna auto play every single day.
    It should be end at 2pm,and then the countdown starts again for next day.
    var endDate:Date = new Date();
    endDate.setHours(14);
    endDate.setMinutes(0);
    endDate.setSeconds(0);
    endDate.setMilliseconds(0);
    var countdownTimer:Timer = new Timer(10);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
              if(now.getTime()>endDate.getTime()){
              time_txt.text = "00:00:00:00";
              countdownTimer.stop();
              return
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var milliseconds:Number = Math.floor(timeLeft /10);
              var seconds:Number = Math.floor(milliseconds / 100);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              milliseconds %= 100;
              seconds %= 60;
              minutes %= 60;
              var mil:String = milliseconds.toString();
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (mil.length < 2) {
                        mil = "0" + mil;
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec + ":" + mil;
              time_txt.text = time;

  • Can someone pls help me to change AS3 code to AS2 code

    Hello! Dear All,
    I dont understand why with AS3 code my swf file is not working smooth at all. I would like to try it with AS2. In publish setting when I am selecting Flash Player 8, AS2 my swf is running good but showing lots of code errors.
    I dont have much knowledge about AS2 so if someone can help me with this...it would be great.
    Thanks,
    Cheers!
    Code1:
    import flash.external.ExternalInterface;
    ExternalInterface.addCallback("GetVars",GetVars);
    ExternalInterface.addCallback("SetVariable1",SetVariable1);
    function GetVars():Array {
    return [
      {VariableName:"SetVariable1",DefaultValue:"Variable1"}
    function SetVariable1(variable:String):void {
    for (var i:int = 0; i < numChildren; i++) {
      var mc:MovieClip=getChildAt(i) as MovieClip;
      if (mc!=null&&mc.name=='Audi_Cup') {
       mc.variable1=variable;
       mc.SetVariable1(variable);
    Code 2
    this.mask_mc.cacheAsBitmap=true;
    this.mask_mc.cacheAsBitmap=true;
    Text1.mask=(mask_mc);
    function SetVariable1(variable:String):void {
    if (variable!=null) {
      for (var i:int = 0; i < numChildren; i++) {
       var mc:MovieClip=getChildAt(i) as MovieClip;
       if (mc!=null&&mc.name=='Text1') {
        var object:TextField=mc.getChildByName('InputTextField1') as TextField;
        if (object!=null) {
         object.text=variable;
    SetVariable1(this.variable1);

    it's possible, but unlikely, you'll fix anything by converting to as2.  so, what problems are you having with as3?

  • Please help 'Translate' These codes from AS2 to AS3 for me

    Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
    toc    loadText = new LoadVars();
        loadText.load("Curie.txt");
        loadText.onLoad = function(success) {
            if (success) {
                // trace(success);
                Curie.html = true;
                Curie.htmlText = this.Curie;
    Please translate it for me, i need it ASAP thanks
    Kenneth

    Thank you for helping me
    Kenneth
    Date: Thu, 15 Oct 2009 05:49:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: Please help 'Translate' These codes from AS2 to AS3 for me
    Take a look at that:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
    There is a LoadVars section on that.
    There is also a tutorial here:
    http://www.republicofcode.com/tutorials/flash/as3externaltext/
    Cheers,
    CaioToOn!
    >

  • Need help with as3 for popup window

    I am nearing the end of the semester in my Flash Animation class. I have learned very simple AS3 things, code snippets etc. I am trying to find the actionscript for coding a very simple popup window, but have not found a clue.
    Here's what I want to do...I have a white box with some type on the stage. When a person clicks on the white box, I want a popup to open that is larger, that will contain the same type but larger. That box will have an x so it can be dismissed. I don't want to do this in html, only in Flash CS5. I don't want a browser window, I just want a bigger version of the smaller box. I know how to build both boxes, just don't know how to write the code. I know there will be an on-click mouse event listener, and then I am lost.
    Can anyone help with the code I might use? It would be most appreciated.

    It would be something along the lines of... (using instance names relative to your description)...
    popup.visible = false;
    whiteBox.addEventListener(MouseEvent.CLICK, showPopup);
    function showPopup(evt:MouseEvent):void {
         popup.visible = true;
    popup.popupX.addEventListener(MouseEvent.CLICK, hidePopup);
    function hidePopup(evt:MouseEvent):void {
         popup.visible = false;

  • Need help on countdown timer!

    Could someone please guide me in the direction as to how to make a countdown timer?  I created a timer that counts down to a certain date, but I just want the timer to countdown 24 hours, not to a certain date.  I also want to have a button below the timer so that when you click it, it adds 30 seconds to the timer.  Can anyone help me with this?

    Hi,
    I hope it will be use full for u....
    var timelong=2000;
    var mytimer:Timer=new Timer(timelong,1);
    mytimer.addEventListener(TimerEvent.TIMER_COMPLETE,myfunc);
    mytimer.start();
    function myfunc(event:TimerEvent)
        trace("hi it's working");
    mybut.addEventListener(MouseEvent.CLICK,addtime);
    function addtime(event:MouseEvent)
        timelong+=3000;
    Thanks,
    K Swamy Vishnubhatla,

  • Countdown timer to NEXT WHOLE HOUR..?

    Hello.
    I need to create a countdown timer function.
    Normally that would not be a problem for me, but this timer needs to countdown to the next whole hour. As an example, if the time is 23:42 the countdown would say 17:35 (17 minutes, 35 seconds).
    When the timer hits zero, it will start from 59:59 and so on.. Always counting to the next whole hour.
    Im kind of in a jam and need this done ASAP, any help would be greatly apreciated!
    / Rasmus

    Im sorry if i implied that im a great actionscripter, im not
    What i would normally do is just grab a counter script from a google search and modify it to countdown to the correct time, but i havent been able to find a counter that counts down to the next whole hour.
    It should just be plain and simple and display the time in minutes and seconds like this: 25:14
    I found this one on google, counting down for christmas. If that could be modded into showing only minutes and seconds and of course counting down to the next whole hour, that would be awsome!
    https://dl.dropbox.com/u/2628604/countdown-test.fla

  • Help changing AS3 -- AS2 please

    I was following a tutorial in AS3 with a MouseEvent but really want to use it in AS2.
    There is an Input Text box named boxOne that a user enters their name
    You click on myButton and in then in boxTwo should appear the test "Welcome to our class" and what
    was entered in boxOne.
    The error message says " the class or interface MouseEvent could not be loaded
    The AS3 code is :-
    stop();
    function handleClick(pEvent:MouseEvent):void {
    var myFirstVariable = boxOne.text;
    boxTwo.text = "Welcome to our class " + myFirstVariable;
    myButton.addEventListener(MouseEvent.MOUSE_UP, handleClick);
    I'd really appreciate some help - thanks
    ActionScript Beginner.....but trying

    Diavonex indicated how to change the avatar for this web site. My impression is that is not what you are trying to do.
    The iPad isn't set up with individual user accounts at the OS level. There is no function on it as you are describing. If I'm wrong, perhaps you could describe what you re referring to in more detail.

  • AS3 - 1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place; 2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true - ActionScript 3 - flash cs3 cs4

    Hi folks,
    Ronny's here again on forums, having particularly 2 (two) questions/problems to resolve:
    1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place
    2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true
    attached is the .zip file (as3_Countdown Timer_ver 1.0.1_by Ronny Depp.zip) with all flash source files containing:
    a) The FLash Source (file: timer_module.fla) - (FLA flash source file - Flash CS3 Professional, Flash Player 9, actionscript 3.0)
    b) com.othenticmedia.utils.dateAndTimeManagement package including 2 .as actionscript 3.0 Class files.
           i) com.othenticmedia.utils.dateAndTimeManagement.DateAndTimeManager Class in the said package. (file: DateAndTimeManager.as)
           ii) com.othenticmedia.utils.dateAndTimeManagement.CountdownTimer Class in the package. (file: CountdownTimer.as)
    c) The compiled SWF file version of this Application's blueprint. (file: timer_module.swf).
    What i need to confirm is: ........................................................ see the next post of mine. (for Problems  need to be Resolved)

    Problems to Resolve:
    Problem#1) - Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place.
    Problem#2) - Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true;
    Problem#1 Description:
    I need to pinpoint the Logical TimeSync Exception, i am still unable to figure out. That is I'm using a webservice in my Application to Synchronize the Time with the actual ET (eastern time) with accomodation of auto-adjustment for EDT GMT-4 (eastern daylight time) & EST GMT-5 (eastern standard time), times. I am using the zipcode: "10012" to pass it to the Web Service in urlRequest object, to retrieve the Current ET eastern time according to EDT & EST time settings for Manhattan/Brooklyn areas or others within  New York, NY 10012.
    Currently the Web Service is returning accurate date/time based on local EDT GMT-4 daylight time.
    Is there some defined set of dates for EDT & EST times for New York region that I can check for to ensure the correct Dates/Times for Eastern Time in New York area ??? I am using NY zipcodes because i am sure to get correct ET values.
    The Major Problem Part: is I need to correct the time by 2 seconds or approx. 2 secs, some millisecs.
    When I retrieve the Time Value from WebService, it lags behind for 2 seconds as compared to DateObj i create using computer's local time, on my Windows XP Service Pack 2 with Automatic Updates turned-on. And I'm sure about my Windows will be having latest updates for Time Management already installed. I also added the 2 secs. to the TimeSync(ed) Date to make correction to this Date obj.
    I call my custom fucntion addSeconds(dateObj:Date, secs:int) to add 2 seconds to the Date by Converting Seconds to Milliseconds.
    Please comb through the as code in files attached and Help Me Out !!!
    Problem#2 Description:
    Secondly I need to Detect the End of Stream state while using FLVPlayback component, an rtmp:// live Stream from FLASH MEDIA SERVER.
    I need to Play a YuMe Post-Roll Ad when Steam Finishes/Ends.
    Live Broadcast Stream Event starts every night on Wednesdays & Saturdays exactly  at 10:59 PM EDT GMT-4.
    Live Events only Streams/Broadcasts the stream for 50secs. exactly. When [playback stopped] it plays a PostRoll Ad and after the CountdownTimer again comes back to life. The Next upcoming Event is calculated & the Countdown begins until Next Event's time/date is reached.
    Here is the  code on the frame 1 on the MainTimeline: (rest of the params like source, volume, skinAutoHide are Set using Property Inspector for FLVPlayback instance on Stage)
    //myStream instance of FLVPlayback is on the Stage
    myStream.isLive = true;// Frame 1 Actions in the FLA
    myStream.addEventListener(VideoEvent.COMPLETE, onEndOfStream);
    myStream.addEventListener(VideoEvent.STATE_CHANGE, onState);
    myStream.addEventListener(String(VideoError.NO_CONNECTION), onStreamError);
    myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    /*if(myStream.stopped){
         trace("tracy: "+myStream.state);
    } else if(myStream.state == VideoState.STOPPED){
         trace("tracy: "+myStream.state);
    function onStreamError(event:VideoError) {
         trace(event.code + "\n\t" + event);
    function onState(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function onEndOfStream(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function netStatusHandler(event:NetStatusEvent):void {
         switch (event.info.code) {
              case "NetConnection.Connect.Success":
                   //connectStream();
                   break;
              case "NetStream.Play.StreamNotFound":
                   trace("Stream not found: "/* + myStream.source*/);
                   break;

  • Can you help with the code to publish Flash to my own domain.

    Thank you for your help, I publish the my site to my own domain, I do not use .Mac, I tested your code and ity works well on .Mac, can you help with the code to publish to my own domain.
    Thank you again

    You appear to have just collected a variety of code snippets and thrown them together, including a section of AS2 code ( gage.onRelease = function() {... )
    The suggestion I offered yesterday still stands.  You should find a tutorial regarding AS3 and the atan2 function.  Beyond that, what you show suggests this is a school assignment.  You should seek help from your fellow students and instructor if that is the case.

  • Countdown Timer HELP

    I got this countdown timer, when a date is passed in, it shows days, hours, minutes, seconds, milliseconds. One problem, is that the hours contain the days converted into hours and any other hours less the 24, minutes contain all the minutes of the days, hours and any other minutes left over etc. (I know hard its to understand). Wondering if anyone out there knew how to stop this (looking for the days, and hours left over, NOT day converted to hours and hours left over less than a day), i think i need to use mod(%), but i dont know where. Here come the code, run it, it works perfectly and you will see what I mean. Code solution would be gravy
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    mDate = new Date("15:54 April 29 2004")
    function countdown()
         var now=new Date()
         var diff=mDate.getTime()-now.getTime()
         if (diff <= 0)
              document.bid.mseconds.value = 0
              return 0;
         document.bid.days.value = Math.round(diff/(24*60*60*1000))
         document.bid.hours.value = Math.round(diff/(60*60*1000))
         document.bid.minutes.value = Math.round(diff/(60*1000))
         document.bid.seconds.value = Math.round(diff/1000)
         document.bid.mseconds.value = diff
         var id=setTimeout("countdown()",0)
    </SCRIPT>
    </HEAD>
    <BODY onLoad="countdown()">
    Countdown <BR>
    <form name="bid" method="post" action="">
    <p>Timeleft</p>
    <TABLE BORDER=0>
    <TD width="79">Days: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="days" SIZE=15></TD> <TR>
    <TD width="79">Hours: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="hours" SIZE=15></TD> <TR>
    <TD width="79">Minutes:</TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="minutes" SIZE=15></TD> <TR>
    <TD width="79">Seconds: </TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="seconds" SIZE=15></TD> <TR>
    <TD width="79">Milliseconds:</TD>
    <TD width="81">
    <INPUT TYPE="text" NAME="mseconds" SIZE=15></TD> <TR>
    </TABLE>
    </form>
    </BODY>
    </HTML>
    Regards,
    Don Colvin (Computer Science Student)

    and what is your JSP related question ?

  • Would someone be willing to check as3 code for a guestbook

    Would someone be willing to check out some as3 code for a guestbook? I'm an old person, and can't seem to get it working.
    Thanks!

    Ned suggested that I post the code, so everyone could see it. The SWF works, but the code doesn't. Any help appreciated!
    package com.mgraph\
      //IMPORTS
      import flash.display.Loader;
      import flash.display.MovieClip;
      import flash.display.Sprite;
      import flash.display.StageAlign;
      import flash.display.StageScaleMode;
      import flash.events::EventDispatcher/dispatchEventFunction();
      import flash.events::EventDispatcher/dispatchEvent();
      import flash.events.MouseEvent;
      import flash.events.TextEvent;
      import flash.events.KeyboardEvent;
      import flash.geom.Rectangle;
      import flash.net::URLLoader/onComplete();
      import flash.net.URLRequest;
      import flash.net.URLRequestMethod;
      import flash.net.URLVariables;
      import flash.text.TextFieldAutoSize;
      import flash.text.TextFormat;
      import com.utils.StringUtils;
      import com.caurina.transitions.Tweener;
      import com.pageflip.Page;
      import com.pageflip.PageEvent;
      public class Guestbook extends MovieClip {
      //PRIVATE VARS
      private var myXML:XML;
      private var frm:TextFormat;
      private var popup_mc:MovieClip;
      private var greySprite:Sprite;
      private var initPosition:Number;
      private var dy:Number;
      private var initContentPos:Number;
      private var moveVal:Number;
      private var rectScroll:Rectangle;
      private var stageWidth:Number;
      private var stageHeight:Number;
      public function Guestbook(){
      addEventListener(Event.ADDED_TO_STAGE,init);
      private function init(e:Event):void {
      stage.showDefaultContextMenu = false;
      stage.align = StageAlign.TOP_LEFT;
      stage.scaleMode = StageScaleMode.NO_SCALE;
      stageWidth = stage.stageWidth;
      stageHeight = stage.stageHeight;
      // LOAD THE XML
      var xmlPath:String;
      var xmlLoader:URLLoader = new URLLoader;
      if (root.loaderInfo.parameters.myconfig) {
      // XML PATH FROM HTML flashvars (myconfig)
      xmlPath = root.loaderInfo.parameters.myconfig;
      else {
      // DEFAUL PATH OF XML
      xmlPath = "config.xml";
      xmlLoader.load(new URLRequest(xmlPath));
      xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
      private function xmlLoaded(e:Event):void {
      // XML LOADED COMPLETE
      myXML = new XML(e.target.data);
      // ADD EVENT LISENER TO FIELDS AND TO (send_btn)
      form_mc.name_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
      form_mc.email_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
      form_mc.message_txt.addEventListener(TextEvent.TEXT_INPUT,clearAlert);
      form_mc.email_txt.addEventListener(Event.CHANGE,checkMail);
      addMouseEvent(form_mc.send_btn,sendEvent);
      // CREATE TEXT FORMAT (frm)
      frm = new TextFormat  ;
      frm.leading = 4;
      form_mc.message_txt.defaultTextFormat = frm;
      // LOAD BACKGROUND IMAGE
      var backLoader:Loader = new Loader();
      backLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,backLoaded);
      backLoader.load(new URLRequest(myXML.img_back));
      // ADD KEYBOARD EVENT WHEN PRESSING ENTER KEY
      stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardDown);
      // CREATE THE GREY SPRITE
      greySprite = new Sprite  ;
      greySprite.graphics.beginFill(0x000000,0.2);
      greySprite.graphics.drawRect(0,0,stageWidth,stageHeight);
      greySprite.graphics.endFill();
      greySprite.useHandCursor = false;
      // CREATE THE POPUP and ADD EVENTLISTENER TO (close_btn)
      popup_mc = new popup_obj;
      popup_mc.x = (stageWidth - popup_mc.width)/2;
      popup_mc.y = (stageHeight - popup_mc.height)/2;
      addMouseEvent(popup_mc.close_btn,closeEvent);
      private function keyboardDown(e:KeyboardEvent):void{
      if(e.keyCode == 13){
      // STOP USING BREAK LINE IN message_txt
      stage.focus = null;
      private function backLoaded(e:Event):void{
      // BACKGROUND LOADED COMPLETE
      var back_mc:MovieClip = new MovieClip;
      back_mc.addChild(e.target.content);
      addChildAt(back_mc,0);
      form_mc.wait_mc.visible = false;
      startPageFlip();
      // START LOADING GUEST MESSAGE FROM DATABASE
      load_guestbook();
      private function startPageFlip():void{
      var flipedPage:Page = new Page(this, stageWidth, stageHeight, 0, 0);
      flipedPage.turnPageForward();
      private function load_guestbook():void {
      // GET MESSAGES FROM DATABASE USING PHP
      var guestLoad:URLLoader = new URLLoader  ;
      var guestReq:URLRequest = new URLRequest(myXML.phpURL);
      guestReq.method = URLRequestMethod.POST;
      guestReq.data = new URLVariables  ;
      guestReq.data["getMessage"] = 1;
      guestLoad.addEventListener(Event.COMPLETE,bookLoaded);
      guestLoad.load(guestReq);
      private function bookLoaded(e:Event):void {
      // MESSAGES LOADED SUCCESSFULLY FROM DATABASE
      var bookXML:XML = new XML(e.target.data);
      showMessages(bookXML);
      private function showMessages(_xml:XML):void{
      var guest_mc:MovieClip;
      // CREATE (guest_mc) to SHOW EACH GUEST NAME & MESSSAGE
      for (var u=0; u<_xml.guest.length(); u++) {
      guest_mc = new messageObj  ;
      guest_mc.y = 95 * u;
      //CAPITALIZE THE FIRST CHAR IN NAME
      guest_mc._Name = StringUtils.capitalize(_xml.guest[u].name);
      guest_mc._Msg = _xml.guest[u].msg;
      guest_mc._Date = _xml.guest[u].sdate;
      guest_mc.guestName_txt.htmlText = setHtmlFormat(14,myXML.name_color,guest_mc._Name);
      //IF guestMessage_txt TEXT LENGTH > 110 substr guestMessage_txt AND ADD (...)
      guest_mc.guestMessage_txt.htmlText = setHtmlFormat(12,myXML.message_color,StringUtils.capitalize(StringUtils.truncate(_xml.gue st[u].msg,110,"...")));
      guest_mc.guestMessage_txt.setTextFormat(frm);
      guest_mc.tabChildren = false;
      guest_mc.tabEnabled = false;
      // ADD EVENT LISTISTENER  TO (readMore_btn) FOR EACH (guest_mc)
      addMouseEvent(guest_mc.readMore_btn,readEvent);
      msgContainer.addChild(guest_mc);
      // SHOW/HIDE SCROLL
      if (msgContainer.height < mask_mc.height) {
      scroller.scroll_btn.visible = false;
      else {
      this.mouseChildren = false;
      scroller.scroll_btn.y = 0;
      if(msgContainer.y != 10){
      Tweener.addTween(msgContainer,{y:10,time:1.5,onComplete:initScrollPos});
      else{
      initScrollPos();
      scroller.scroll_btn.visible = true;
      // ADD EVENT  TO SCROLL
      addMouseEvent(scroller.scroll_btn,scroll_Event);
      scroller.scroll_btn.addEventListener(MouseEvent.MOUSE_UP,scroll_Event);
      private function initScrollPos():void{
      this.mouseChildren = true;
      dy = 0;
      initPosition = scroller.scroll_btn.y = scroller.bar_mc.y;
      initContentPos = msgContainer.y;
      moveVal = (msgContainer.height-mask_mc.height)/(scroller.bar_mc.height-scroller.scroll_btn.height);
      rectScroll = new Rectangle(scroller.bar_mc.x + 4,scroller.bar_mc.y,0,scroller.bar_mc.height - scroller.scroll_btn.height);
      private function readEvent(me:MouseEvent):void {
      var _this = me.currentTarget;
      switch (me.type) {
      case "mouseOver" :
      _this.alpha = 0.8;
      break;
      case "mouseOut" :
      _this.alpha = 1;
      break;
      case "mouseDown" :
      // SHOW POPUP WITH MORE INFORMATIONS ABOUT THE CURRENT MESSAGE
      popup_mc.pop_nom.htmlText = setHtmlFormat(15,myXML.name_color,_this.parent._Name) + setHtmlFormat(13,myXML.datePosted_color," - Posted "+_this.parent._Date);
      popup_mc.pop_message.htmlText = setHtmlFormat(13,myXML.message_color,StringUtils.capitalize(_this.parent._Msg));
      popup_mc.pop_message.autoSize = TextFieldAutoSize.LEFT;
      popup_mc.pop_message.setTextFormat(frm);
      popup_mc.back_mc.height = popup_mc.pop_message.height + 50;
      popup_mc.x = (stageWidth - popup_mc.width)/2;
      popup_mc.y = (stageHeight - popup_mc.height)/2;
      addChild(greySprite);
      addChild(popup_mc);
      popup_mc.alpha = 0;
      greySprite.alpha = 0;
      Tweener.addTween(popup_mc,{alpha:1,time:0.6});
      Tweener.addTween(greySprite,{alpha:1,time:0.6});
      break;
      private function setHtmlFormat(_size:Number,_color,_txt:String):String{
      var htmlFrm:String  = "<font size='"+_size+"'color='"+_color+"'>"+_txt+"</font>";
      return htmlFrm;
      private function closeEvent(me:MouseEvent):void {
      switch (me.type) {
      case "mouseOver" :
      popup_mc.close_btn.alpha = 0.8;
      break;
      case "mouseOut" :
      popup_mc.close_btn.alpha = 1;
      break;
      case "mouseDown" :
      if (stage.contains(popup_mc)) {
      Tweener.addTween(greySprite,{alpha:0,time:0.6,onComplete:function(){removeChild(greySprit e)}});
      Tweener.addTween(popup_mc,{alpha:0,time:0.6,onComplete:function(){removeChild(popup_mc)}} );
      break;
      private function scroll_Event(me:MouseEvent):void {
      switch (me.type) {
      case "mouseOver" :
      scroller.scroll_btn.alpha = 0.7;
      break;
      case "mouseOut" :
      scroller.scroll_btn.alpha = 1;
      break;
      case "mouseUP" :
      scroller.scroll_btn.stopDrag();
      scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
      break;
      case "mouseDown" :
      scroller.scroll_btn.startDrag(false, rectScroll);
      scroller.scroll_btn.addEventListener(Event.ENTER_FRAME, scrollMove);
      stage.addEventListener(MouseEvent.MOUSE_UP, releaseOut);
      break;
      private function scrollMove(event:Event):void {
      dy = Math.abs(initPosition - scroller.scroll_btn.y);
      msgContainer.y = Math.round(dy * -1 * moveVal + initContentPos);
      private function releaseOut(me:MouseEvent):void {
      scroller.scroll_btn.stopDrag();
      scroller.scroll_btn.removeEventListener(Event.ENTER_FRAME, scrollMove);
      stage.removeEventListener(MouseEvent.MOUSE_UP, releaseOut);
      private function sendEvent(e:MouseEvent):void {
      switch (e.type) {
      case "mouseOver" :
      form_mc.send_btn.alpha = 0.7;
      break;
      case "mouseOut" :
      form_mc.send_btn.alpha = 1;
      break;
      case "mouseDown" :
      // CHECK FIELDS AND EMAIL THEN SEND DATA TO PHP
      if (form_mc.name_txt.text == "") {
      stage.focus = form_mc.name_txt;
      show_alert("You must enter the : « Name »");
      else if (form_mc.email_txt.text == "") {
      stage.focus = form_mc.email_txt;
      show_alert("You must enter the : « E-mail »");
      else if (form_mc.validating.currentFrame == 1) {
      stage.focus = form_mc.email_txt;
      form_mc.validating.alpha = 1;
      form_mc.validating.gotoAndStop(1);
      show_alert("« E-mail » address is incorrect");
      else if (form_mc.message_txt.text == "") {
      stage.focus = form_mc.message_txt;
      show_alert("You must enter the : « Message »");
      else {
      sendData();
      break;
      private function checkMail(e:Event):void {
      form_mc.validating.alpha = 1;
      var mail_validation:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
      mail_validation.test(form_mc.email_txt.text);
      if (mail_validation.test(form_mc.email_txt.text) == true) {
      form_mc.validating.gotoAndStop(2);
      form_mc.alert_txt.text = "";
      else {
      form_mc.validating.gotoAndStop(1);
      private function clearAlert(te:TextEvent):void {
      if (form_mc.alert_txt.text != "") {
      form_mc.alert_txt.text = "";
      private function show_alert(txt:String):void {
      form_mc.alert_txt.htmlText = "<font color='" + myXML.alert_color + "'>" + txt + "</font>";
      private function sendData():void {
      // SEND NAME-EMAIL-MESSAGE TO PHP
      this.mouseChildren = false;
      form_mc.wait_mc.visible = true;
      var phpLoad:URLLoader = new URLLoader  ;
      var phpReq:URLRequest = new URLRequest(myXML.phpURL);
      phpReq.method = URLRequestMethod.POST;
      phpReq.data = new URLVariables  ;
      phpReq.data["name"] = StringUtils.stripTags(form_mc.name_txt.text);
      phpReq.data["email"] = form_mc.email_txt.text;
      phpReq.data["message"] = StringUtils.stripTags(form_mc.message_txt.text);
      phpLoad.addEventListener(Event.COMPLETE,insertPHP);
      phpLoad.load(phpReq);
      private function insertPHP(e:Event):void {
      this.mouseChildren = true;
      var phpXML:XML = new XML(e.target.data);
      form_mc.send_btn.mouseEnabled = true;
      form_mc.wait_mc.visible = false;
      if (phpXML.inserted == 1) {
      startPageFlip();
      form_mc.alert_txt.htmlText = myXML.insert_ok;
      form_mc.validating.alpha = 0;
      form_mc.validating.gotoAndStop(1);
      while (msgContainer.numChildren) {
      msgContainer.removeChildAt(msgContainer.numChildren-1);
      // SHOW THE CURRENT POSTED MESSAGE AND CLEAR FIELDS
      showMessages(phpXML);
      clearFields();
      else {
      form_mc.alert_txt.htmlText = myXML.insert_error;
      private function clearFields():void {
      form_mc.name_txt.text = "";
      form_mc.email_txt.text = "";
      form_mc.message_txt.text = "";
      form_mc.validating.gotoAndStop(1);
      form_mc.validating.alpha = 0;
      private function addMouseEvent(_targ,_func):void {
      _targ.buttonMode = true;
      _targ.mouseChildren = false;
      _targ.addEventListener(MouseEvent.MOUSE_OVER,_func);
      _targ.addEventListener(MouseEvent.MOUSE_OUT,_func);
      _targ.addEventListener(MouseEvent.MOUSE_DOWN,_func);

  • I've tried downloading iOS5 several times and after an hour each time I get a message that says my network connection has timed out.  But I can't find any information about "timing out" or how to correct the situation.  Any help?

    I've tried downloading iOS5 several times and after an hour each time I get a message that says my network connection has timed out.  But I can't find any information about "timing out" or how to correct the situation.  Any help?

    Disable your antivirus and firewall, and try again.

  • I need to make a task with less as3 code and more timeline structure and event dispatcher !

    I went to an interview in a big company. I had to make a  task in which there is a wall with 3 lines and 5 columns filled with bombs.When you click on a bomb the bomb changes its scale, a robot enters, goes under the bomb and takes it, then goes to a smaller wall, makes the bomb smaller and place it at the same place it had been in the previous wall.I made the task with tween througout as3 code.The interviewer told me it was good but i need to make it with the less code possible and with more complex timeline structure and to use event dispatcher.What is the best way to do this ?

    The immediate thing that comes to mind is they might want to see that you can balance work between design teams and development teams.
    To do that, the robots movements (pick up bomb, bomb grows/shrinks, arms/treads/legs moving, sequences of 'doing things') can be timeline based so animators can work on those separate from code.
    Developers would be working on the logic of keeping score, moving the robot around to the correct spot with path detection, collision detection, etc.
    It's very similar to thinking in simple factories (which Flash is good at being automatically with timelines), and a bit of MVC (or just VC in some cases).
    Big companies have lots of different types of employees so you'll probably be very specific in your role so you're efficient.

  • Search help for material code in VA01

    Dear Experts,
    In VA01 tcode in item level if user press f4 in the material code then we will get all the f4 helps for few fields.Now i need to add one more field  mtart from mara table  in the existing  search help of material code.
    plz suggest me how can i proceed.
    If u have any documets regarding adding one more fied to existing search help plz send me.
    Thanks & Regards,
    farook.
    Edited by: farook shaik on Aug 18, 2009 8:58 AM

    Hi,
       You can do that using search help exits you would find several threads already posted to the forum for this like below:
    Link[Search Help Exits|Search Help Exit;
    Regards,
    Himanshu

Maybe you are looking for