The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: cannot convert flash.display::Sprite

  1. #1

    cannot convert flash.display::Sprite

    cannot convert flash.display::Sprite@39394a9 to flash.display.MovieClip.
    here is sample code
    var enemyArray:Array = new Array();
    var mySprite:Sprite;
    mySprite = new Sprite();
    var myEnemy:Enemy;
    myEnemy = new Enemy();
       for(var i in enemyArray)
          if(enemyArray[i] == e)
    enemy class: if anemy is offscreen he will call the deleteEnemy
    then it will delete the enemy from stage after that it will call removeChild() from the parent to remove the enemy from the array
    then it will get the error above

    i guess the problem is, enemy class cant access the removeEnemy() in parent class
    but when i remove the sprite like this:
    rather than this:
    then it will be ok, but my goal is, How can enemy call the removeEnemy() in parent while it is inside the sprite, tnx for the help in advance...
    Last edited by senocular; November 1st, 2010 at 07:09 PM. Reason: added [code] tags

  2. #2
    Use Object(parent).

    MovieClip(parent) is not the magic fix-all solution for parent referencing. Its a cast, and for a cast to succeed, it has to be the same type as the type of object being cast. If parent is not a movie clip, the cast will fail. Using Object, the cast will pass and you'll be able to use whatever reference you want since Object is a dynamic type.

    The most correct approach would be to cast to the actual type of what parent really is.

  3. #3

    Error #1069: Property removeEnemy not found on flash.display.Sprite

    still enemy cant find the removeEnemy() function in main while its in the sprite

    but when i remove him from the sprite, it can call the removeEnemy() on main

    how does enemy cant find the removeEnemy() while the enemy is inside the sprite?, tnx..

  4. #4
    Then removeEnemy is not in the parent

  5. #5
    Quote Originally Posted by senocular View Post
    Then removeEnemy is not in the parent
    its not in main its in the other movieClip ex: sample(MovieClip), sorry for the mistake ^_^

    here is the structure if no sprite

    main > sample > Enemy

    sample(MovieClip) is the parent of enemy where the enemy try to call the removeEnemy
    from the sample

    removeEnemy is inside the sample class..

    then if have sprite

    main > sample > sprite > enemy

    now enemy cant call the removeEnemy() in the sample
    Last edited by frogtoon; November 1st, 2010 at 07:52 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012