0

i want to make end-subscription after admin enter the value/date into text_box then it will push to array,after that i want when time reach the date that been enter the application will exit.

But I don't know the method. below is my code

var my_date:Date; 

var my_timer:Timer=new Timer(1000);
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start(); 


var tarikh:Array = new Array();
tarikh.hari = [0];
tarikh.bulan = [1];
tarikh.tahun = [2];

my_date = new Date();


function onTimer(e:TimerEvent):void
{
my_date = new Date();

//trace(my_date.date + ":" + my_date.month + " : " + my_date.fullYear );

}


btnCuba.addEventListener(MouseEvent.CLICK,MMM);
function MMM (event:MouseEvent):void
{
    tarikh.hari = String(hari.text);
    tarikh.bulan = String(bulan.text);
    tarikh.tahun = String(tahun.text) ;
    tarikh.push(hari,bulan,tahun);

    setHours();
    trace(tarikh.hari + "" + tarikh.bulan + "" + tarikh.tahun);

    }

function setHours():void

{
    if (my_date.date == tarikh.hari && my_date.month == tarikh.hari && my_date.fullYear == tarikh.hari  && && my_date.minutes == 01)
    {

        NativeApplication.nativeApplication.exit();

        }

    else
    {
        my_timer.start();
        }

}
  • Hello and welcome to StackOverflow. Please consider to rewrite your question because the problem is not clear and the code does not help to understand the problem. – Organis Mar 24 '18 at 08:32
  • I wanted to make like when user input the date.the date will store into array..and i want sethours function to capture the value from array and when local time match the value in array the application will be closed.My problem is when i write this code " if ( (my_date.date == tarikh.hari && my_date.month == tarikh.hari && my_date.fullYear == tarikh.hari && && my_date.minutes == 01) This code getting error .... @Organis – Mohd Nur Syazwan Mar 26 '18 at 00:56
  • How **Array** is relevant to this at all? Normally, you use **Array** to store a list of typical data, like, **Array** of **Point** coordinates, or **Array** of student names. – Organis Mar 26 '18 at 08:20

1 Answers1

0

tarikh is an array. Arrays are assigned to using the array index access operator. When you want to store data in an array, you do it like this:

array_name[index] = value

or in this case,

tarikh[0] = hari;

Looking at the code, tarikh seems to mean date, hari, bulan and tahun seem to mean day, month and year. The Date class doesn't have these properties (you'll have to translate them to English); alternatively, an easier method of comparing dates is just to compare the getTime() function returns by the two date objects:

if(my_date.getTime() == tarikh.getTime()) { NativeApplication.nativeApplication.exit(); }

The problem is that tarikh is not a Date object now, but is an Array. Arrays don't have any properties by themselves (apart from length), so maybe you're looking for a tarikh being a Date object? You could try making tarikh as a Date object with the values like so:

tarikh = new Date(hari.text + " " + bulan.text + " " + tahun.text); if the text values are letters (like Tue Feb 3 2005), otherwise if they are numbers or integers then try casting it and using it in the appropriate parameter.

Gimmick
  • 11
  • 1
  • 1