Please need help converting AS2 to AS3 code

Hi, I want to convert an AS2 code to AS3. Someone can tell
what is wrong. (it is about a speed effect) - Thanks a lot.
mport flash.filters.BlurFilter;
import fl.transitions.Tween;
import fl.transitions.easing.*;
var duration:Number = 15;
var t1:Tween = new Tween(mcToTween1, "_x", Elastic.easeIn,
133, 367, duration, 0);
var t2:Tween = new Tween(mcToTween1, "blur", Elastic.easeIn,
0, 0, 1, true);
t1.onMotionChanged = function() {
oldx = x;
oldy = y;
x = mcToTween1._x;
y = mcToTween1._y;
speedx = Math.round(Math.abs((x-oldx)));
speedy = Math.round(Math.abs((y-oldy)));
mcToTween1.filters = [new BlurFilter(speedx*2, speedy*2, 1)];
trace(speedx);
t1.onMotionFinished = function() {
t1.yoyo();
};

use:
MovieClip(parent.parent.parent).rdcmndPause=1;
this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
function keydownF(e:KeyboardEvent):void{
fscommand("KEYPRESSED", e.keyCode);
if(e.keyCode==32){
MovieClip(parent.parent.parent).rdcmndNextSlide=1;

Similar Messages

  • Help Converting AS2 to AS3 Drag and Drop Event

    Hi All,
    This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
    Source for Drag and Drop: (Note: Single MovieClip)
    // pause the Captivate movie
    _root.rdcmndPause = 1;
    // when the user's mouse is let go check if there was a successful drop
    _root.onMouseUp = function(){
              // If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
              if ( Math.abs(_root.sourceX + _root.sourceWidth  / 2 + _root.sourceParentX - (_root.destX + _root.destWidth  / 2)) < (_root.destWidth  / 2) &&
                         Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
                        _root.rdcmndNextSlide = 1;
              } else {
                        // show error movie clip for 2 seconds (60 frames at 30 frames per second)
                        _root.showErrorMessage = 60;
      mc.onEnterFrame = function(){
              // continuously update the source area's coordinates and size
              _root.sourceX = mc._x;
              _root.sourceY = mc._y;
              _root.sourceWidth = mc._width;
              _root.sourceHeight = mc._height;
              _root.sourceParentX = _parent._x;
              _root.sourceParentY = _parent._y;
    mc.onPress = function(){
              // Uncomment following line to have control click capabilities
              //if(key.isDown(Key.CONTROL))
              // when user clicks on the source area click start the drag
                        startDrag(this);
    mc.onRelease = function(){
              // stop drag when user releases the source area
              stopDrag();
    Source for Destination Area (Single MovieClip named destArea)
    // Set a root variable to control when the error message is displayed
    _root.showErrorMessage = -1;
    // Use setCoords variable so we only set the destination coordinates once
    var setCoords = 0;
    destArea.onEnterFrame = function(){
              if (setCoords == 0){
                        // set the destination x, y, width, and height
                        _root.destX = _parent._x;
                        _root.destY = _parent._y;
                        _root.destWidth = _parent._width;
                        _root.destHeight = _parent._height;
              // destination coordinates have been set, change setCoords so it doesn't get set again
              setCoords = 1;
    Code for the Error Message (Single MovieClip named errorMessage)
    // Don't display the error message initially
    errorMessage._alpha = 0;
    errorMessage.onEnterFrame = function (){
              // If the drag and drop method detects a missed drop
              // then show this error message by setting _alpha to 100
              if (_root.showErrorMessage > 0){
                        errorMessage._alpha = 100;
                        // decrementing this variable controls the time the
                        // error message will be displayed
                        _root.showErrorMessage--;
              } else {
                        // Don't display the error message
                        errorMessage._alpha = 0;

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • Help Converting AS2 to AS3 (Spacebar Action in Captivate)

    Hi All,
    There seems to be a lot of these posts on this forum so I thought I would see if anyone could help me out. I had some code developed for me that was in AS2 and I need this in AS3 due to the upgrade in software. Below is the AS2 code:
    _parent._parent._parent.rdcmndPause = 1;
    myListener = new Object();
    myListener.onKeyDown = function () {
              fscommand("KEYPRESSED", Key.getCode());
        If (Key.getCode() == 32)
                        _parent._parent._parent.rdcmndNextSlide = 1;
              EndIf
    Key.addListener(myListener);
    The code is simple really. It was suppose to allow the Spacebar to be used as an input key to go to the next slide in Captivate. There is a single MovieClip in the file. Please let me know.
    Thanks

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • I can't activate my desktop account. Error: E_AUTH_NOT_READY. Please, need help!

    I instaled my desktop Adobe Digital Edition, but I'm failing in activate it with my Adobe Id. The error code is:   E_AUTH_NOT_READY
    Please, need help!

    For this problem, you need to deauthorize and authorize ADE again.
    Launch ADE
    Help -> Erase authorization.
    ADE will be deauhorized.
    Now again AUTHORIZE ADE
    Help-> authorize computer.
    Error will be fixed !!

  • Would like to trace my ipod touch because I was robbed. I would find it please. need help from you guys. Not because I am able to get another. Thank you.

    would like to trace my ipod touch because I was robbed. I would find it please. need help from you guys. Not because I am able to get another. Thank you.

    - If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    iCloud: Find My iPhone
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    - If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
    - Change the passwords for all accounts used on the iPod and report to police
    - There is no way to prevent someone from restoring the iPod (it erases it) using it unless you had iOS 7 on the device. With iOS 7, one has to enter the Apple ID and password to restore the device.
    - Apple will do nothing without a court order                                                        
    Reporting a lost or stolen Apple product                                               
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

  • I Need Help to Access The Source Code From A Form to Know the Calculation Formula

    Hi,
    I Need Help to Access The Source Code From A Form to Know the Calculation Formula. The application is a windows form application that is linked to SQL Server 2008. In one of the application forms it generates an invoice and does some calculations. I just
    need to know where behind that form is the code that's doing the calculations to generate the invoice, I just need to get into the formula that's doing these calculations.
    Thank you so much.

    Hi, 
    Thanks for the reply. This is a view and [AmountDue] is supposed to be [CurrentDueAmount] + [PastDueAmount] - [PaidAmount]. The view is not calculating [PaidAmount] right . Below is the complete code of the view. Do you see anything wrong in the code ?
    Thanks. 
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [iff].[FacilityFeeID], [LoanID] = NULL, [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = [isis_fee].[SectionType], [Name]
    = [iff].[Name], [ReceivedAmount], [dates].[CurrentDueAmount], 
                          [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount],
    0) > 0 THEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply reset to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [pastdue].[PastDueFeeAmount]
    + ISNULL([ReceivedAmount], 0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [pastdue].[PastDueFeeAmount] < 0 THEN 0 ELSE
    [pastdue].[PastDueFeeAmount] END, [PaidAmount] = CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([pastdue].[PastDueFeeAmount]
    + ISNULL([ReceivedAmount], 0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [pastdue].[PastDueFeeAmount] < 0 THEN - [pastdue].[PastDueFeeAmount]
    ELSE 0 END, [AmountDue] = [unpaid].[UnpaidFeeAmount], [ID] = [iff].[FacilityFeeID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_FacilityFee] iff ON [if].[ID] = [iff].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_fee].[ID],
    [sis_fee].[SectionTypeCode], [SectionType] = [st_fee].[Name], [sis_fee].[INV_FacilityFeeID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_fee JOIN
                   [dbo].[INV_SectionType] st_fee ON [sis_fee].[SectionTypeCode] = [st_fee].[Code]
                                WHERE      [INV_FacilityFeeID]
    IS NOT NULL AND [StatusCode] = 'BILL') isis_fee ON [iff].[ID] = [isis_fee].[INV_FacilityFeeID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedFeeAmount]), 
                   [ReceivedAmount] = SUM([iffa].[ReceivedFeeAmount])
                                FROM      
       [dbo].[INV_FacilityFeeAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_fee].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     *
                                FROM      
       [dbo].[INV_FacilityFeeAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [SectionID],
    [PastDueFeeAmount] = SUM([PastDueFeeAmount])
                                FROM      
       [dbo].[INV_FacilityFeeAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]
    UNION
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = [isis_loan].[SectionType], [Name]
    = [il].[Name], [ReceivedAmount], [CurrentDueAmount], [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount], 
                          0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount],
    0) WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
    0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
    END, 
                          [PaidAmount] = CASE WHEN [isis_loan].[SectionTypeCode]
    = 'LOAN_PRIN' THEN 0 ELSE CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
    0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN - [PastDueAmount]
    ELSE 0 END END, 
                          [AmountDue] = CASE WHEN [isis_loan].[SectionTypeCode]
    = 'LOAN_PRIN' THEN [CurrentDueAmount] ELSE [unpaid].[AmountDue] END, [ID] = [il].[LoanID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_loan].[ID],
    [sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_loan JOIN
                   [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                                WHERE      [INV_LoanID]
    IS NOT NULL AND [StatusCode] = 'BILL') isis_loan ON [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[ExpectedPrincipalAmount]), 
                   [ReceivedAmount] = SUM([ReceivedPrincipalAmount])
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization] iffa
                                GROUP BY [iffa].[SectionID]
                                UNION
                                SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                  [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                  [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID]
                                UNION
                                SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                  [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                  [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     [AmountDue]
    = [UnpaidPrincipalAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization]
                                UNION
                                SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual]
                                UNION
                                SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [PastDueAmount]
    = SUM([PastDuePrincipalAmount]), [SectionID]
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization]
                                GROUP BY [SectionID]
                                UNION
                                SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual]
                                GROUP BY [SectionID]
                                UNION
                                SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]
    UNION
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = 'PIK Interest Applied', [Name]
    = [il].[Name], [ReceivedAmount], [CurrentDueAmount] = - [dates].[CurrentDueAmount], 
                          [PastDueAmount] = - CASE WHEN ISNULL([ReceivedAmount],
    0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
    0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
    END, [PaidAmount] = - CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
    0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN - [PastDueAmount]
    ELSE 0 END, [AmountDue] = - [AmountDue], [ID] = [il].[LoanID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_loan].[ID],
    [sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_loan JOIN
                   [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                                WHERE      [INV_LoanID]
    IS NOT NULL AND [StatusCode] = 'BILL' AND [sis_loan].[SectionTypeCode] = 'LOAN_INT_PIK') isis_loan ON 
                          [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                   [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]

  • Please! help me with this wrong code, where is mistake

    please! help me with this wrong code, where is mistake?
    import java.util.Stack;
    public class KnightsTour {
    Vars locs[];
    private int size, max=1, d=0, board[][];
    public KnightsTour(int x,int y, int newSize)
         size=newSize;
         locs=new Vars[size*size+1];
         for(int n=1;n<=size*size;n++)
              locs[n]=new Vars();
         board=new int[size+1][size+1];
         for(int n=1;n<=size;n++)
              for(int n2=1;n2<=size;n2++)
                   board[n][n2]=0;
         locs[max].x=x;
         locs[max].y=y;
         locs[max].d=1;
         board[x][y]=max;
         max++;
    class Vars{
         int x;
         int y;
         int d;
    public void GO()
         int n=0;
         while(max<=size*size)
              n++;
              d++;
              if(d>8)
                   max--;
                   board[locs[max].x][locs[max].y]=0;
                   d=locs[max].d+1;
              move();
         printBoard();
    public void move()
         int x=locs[max-1].x, y=locs[max-1].y;
         switch(d)
         case 1:x--;y-=2;break;
         case 2:x++;y-=2;break;
         case 3:x+=2;y--;break;
         case 4:x+=2;y++;break;
         case 5:x++;y+=2;break;
         case 6:x--;y+=2;break;
         case 7:x-=2;y++;break;
         case 8:x-=2;y--;break;
         //System.out.println(" X: "+x+" Y: "+y+" |"+max);
         if((x<1)||(x>size)||(y<1)||(y>size)){}
         else if(board[x][y]!=0){}
         else
              locs[max].x=x;
              locs[max].y=y;
              locs[max].d=d;
              board[x][y]=max;
              max++;
              d=0;
              //printBoard();
    public void printBoard()
         for(int n=1;n<=size;n++)
              for(int n2=1;n2<=size;n2++)
                   if(board[n2][n]<10)
                        System.out.print(board[n2][n]+" ");
                   else
                        System.out.print(board[n2][n]+" ");
              System.out.println();
         //System.out.println();
         System.out.println();
         public static void main (String[]args){
              KnightsTour k = new KnightsTour(1,1,8);
         }

    public class KnightsTour {
        Vars locs[];
        private int size,  max = 1,  d = 0,  board[][];
        public static void main (String[] args) {
            KnightsTour k = new KnightsTour (1, 1, 8);
            k.GO ();
        public KnightsTour (int x, int y, int newSize) {
            size = newSize;
            locs = new Vars[size * size + 1];
            for (int n = 1; n <= size * size; n++) {
                locs[n] = new Vars ();
            board = new int[size + 1][size + 1];
            for (int n = 1; n <= size; n++) {
                for (int n2 = 1; n2 <= size; n2++) {
                    board[n][n2] = 0;
            locs[max].x = x;
            locs[max].y = y;
            locs[max].d = 1;
            board[x][y] = max;
            max++;
        class Vars {
            int x;
            int y;
            int d;
        public void GO () {
            int n = 0;
            while (max <= size * size) {
                n++;
                d++;
                if (d > 8) {
                    max--;
                    board[locs[max].x][locs[max].y] = 0;
                    d = locs[max].d + 1;
                move ();
            printBoard ();
        public void move () {
            int x = locs[max - 1].x, y = locs[max - 1].y;
            switch (d) {
                case 1:
                    x--;
                    y -= 2;
                    break;
                case 2:
                    x++;
                    y -= 2;
                    break;
                case 3:
                    x += 2;
                    y--;
                    break;
                case 4:
                    x += 2;
                    y++;
                    break;
                case 5:
                    x++;
                    y += 2;
                    break;
                case 6:
                    x--;
                    y += 2;
                    break;
                case 7:
                    x -= 2;
                    y++;
                    break;
                case 8:
                    x -= 2;
                    y--;
                    break;
    //System.out.println(" X: "x" Y: "y" |"+max);
            if ((x < 1) || (x > size) || (y < 1) || (y > size)) {
            } else if (board[x][y] != 0) {
            } else {
                locs[max].x = x;
                locs[max].y = y;
                locs[max].d = d;
                board[x][y] = max;
                max++;
                d = 0;
    //printBoard();
        public void printBoard () {
            for (int n = 1; n <= size; n++) {
                for (int n2 = 1; n2 <= size; n2++) {
                    if (board[n2][n] < 10) {
                        System.out.print (board[n2][n] + " ");
                    } else {
                        System.out.print (board[n2][n] + " ");
                System.out.println ();
    //System.out.println();
            System.out.println ();
    }formatting ftw.
    If you call GO () you get in an infinite loop. max gets decreased, and it loops while max is smaller then or equal to size * size. Is your looping logic correct ?

  • HT3702 error please need help

    Dears,
    I want pay for gems from clash of clan but the msg error please need help this problem take long time with me please please help me.
    Regards,

    If you haven't already done so then you can contact iTunes Support via this link and ask them why the message is appearing (we are fellow users here on these forums, we won't know why it's appearing) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • Please, need help with a query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Take a look on the syntax :
    max(...) keep (dense_rank last order by ...)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
    Nicolas.

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Need help converting from 4.0 to 2011

    hello,
    Need help converting files from 4.0 to 2011.
    thank you
    Solved!
    Go to Solution.
    Attachments:
    noise source.vi ‏73 KB
    8673D.vi ‏30 KB
    8970 FREQ.vi ‏26 KB

    attached as 8.2, which you can open
    missing some subVIs - not sure if you already have them
    Attachments:
    8673D.vi ‏13 KB
    8970 FREQ.vi ‏11 KB
    noise source.vi ‏24 KB

  • Need help converting a PDF to excel

    Need help converting a PDF to excel, the icon to convert dissappeared suggestions?

    Open the file in Acrobat, use File --> Save As... --> Microsoft Word.
    Mylenium

  • Dummy Guide needed for converting AS2 code into AS3

    I have to convert my existing AS2 code into AS3, but I might as well be reading chinese. I never even began to learn AS3, it was still fairly new at the time and the class ended before we had an opportunity to even touch on it. My major was not web design, it was the print side of design. I took an additional class, after I graduated, to learn web design and our teacher told us, basically, that we were designers, not coders so we won't be getting much into actionscripting, beyond the basics. At the time I was relieved, but looking back, I really wish we would have gotten more into it. Bottom line, I need to learn now.
    Is there ANYONE that can help me out? I will list my code below, buy I am way beyond lost any help that can be provided, I would be so grateful!!!!
    On the main timeline I have the basic..
    stop(); -- I found the AS3 version, but I don't know what I'm looking at. I get "not_yet_set.stop()" and there are are 8 options I can choose from. I just want the timeline to stop until I tell it where to go next. And what is "not_yet_set"
    Then I have my buttons, which are, basically...
    on (release) {
    gotoAndStop("Home");
    Or "gotoAndPlay("Whatever");"
    I also have buttons for scrolling...
    on (press) {
    play();
    on (release) {
    stop();
    AND
    on (press) {
    _root.AboutMe_Controller.gotoAndPlay(…
    on (release) {
    _root.AboutMe_Controller.gotoAndStop(…
    For the on(release) command, this is what I found as the AS3 version: not_set_yet.dispatchEvent()

    because that's really as1 code, you have steeper learning curve than going from as2 to as3.
    first, remove all code from objects, assign instance names to your buttons and you can then start on as3:
    // so, if you name your home button, home_btn:
    home_btn.addEventListener(MouseEvent.CLICK,homeF);
    function homeF(e:MouseEvent):void{
    gotoAndStop("Home");
    p.s.  the not_yet_set stuff is there because you tried to use script assist or some other actionscript shortcut.

  • 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?

  • AS3 need help converting

    Hello everyone,
    i have a site im working on that uses as2 but i need to
    change it to as3, any help would be much appreciated.
    Thanks

    Hi again, so I'm still having a few issues, your help is much
    appreciated. The snippet you gave me for the movieclip buttons
    works great but there is no hand when you rollover the button ( i
    can probably figure that out ). Pretty much the swf is a navbar for
    an html site, when one of the movieclip buttons is pressed i need
    it to go to say "work.html" but I also need it to tell the SWF to
    go to a certain frame label for the down state of the button. Here
    is my website under construction
    www.lafrancemedia.com . and
    here is the code up to date:

Maybe you are looking for

  • Longstanding Exchange Calendar Sync Bug Persists in iOS 7 / 7.0.2

    For those who sync their iPhone / iPad / iPod touch to a Microsoft Exchange e-mail environment, you may be aware that there's a longstanding Exchange Calendar Sync bug (affecting iOS 4.x - 6.1.3).  An otherwise functional iDevice may suddenly remain

  • Not able to see the content of opened files (.jpg or .psd) in Photoshop CS6

    I recently downloaded Adobe Design and Web Premium CS6.  I am not able to see the content of any of the file I open (.psd or .jpg).  I do see the file has been opened as the file name appears on the open file tabs, I also see the preview of the file

  • DAte not available in infotype 0041(date specification)

    Hai All, In our place we are using 4 type of "date type" Z1 Hired date. Z2 Seperation Date Z3 Leave quota start Z4 Service entry date for all employees date specification maintain by dynamic action. for some employees date specification is not mainta

  • Please Help! More Capturing Problems.

    I'm having some trouble capturing footage from onto Final Cut Express HD. Whenever I try to capture, the footage plays on my screen for about a second, freezes and I get this error message, "Capture encountered a problem reading the data on your sour

  • Groupware Integration with Third party Email and calendar server

    Hi All, We are trying to integrate email, calender and other standard collaboration features with EP7.0. As per the standard provided by SAP, only Lotus Notes and Exchange transports are provided by SAP. I would appreciate if some one can guide on ho