A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: a quick delete function question

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    a quick delete function question

    I'm wondering about using the delete function in MX 2004. I can write a delete fuction for an on frame function ie:

    Code:
    _root.myButton.onRelease = function (){
        _root.gotoAndPlay("myFrame");
        delete _root.myButton.onRelease;
    }
    but i cant quite figure out how to do it with code on the MC, if I try

    delete on(release);

    I get and error stating there is an unexpected "on"

    what is the syntax?

    thanks in advance

    Mark

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    delete this.onRelease
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    119
    this.onRelease doesnt work for code on the MC
    this is what im using.
    Code:
    on(press){
    	startDrag(this);
    }
    on(release){
    	stopDrag();
    	if (_root.dog.hitTest(_root.table_top)){
    	_root.table_top2.gotoAndPlay(2);
    	delete this.onRelease;
    	
    }
    }
    on(release){
    	if(!_root.dog.hitTest(_root.table_top)){
    		_root.table_top2.gotoAndPlay("wrong");
    		delete this.onRelease;
    	}
    }
    and it doesn't work.....
    any thoughts?

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    why are u putting the actionscript on the mc, rather than controlling it via an instance name?

    Not sure of the sytnax for on(release) since i never attach code to an mc
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  5. #5
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    you would have to assign the actions using the 2.0 syntax. You can't delete actions whe you code them that way. You would have to change your script:

    yourMovieClip.onPress = function (){
    startDrag(this);
    }
    yourMovieClip.onRelease = function (){
    stopDrag();
    if (_root.dog.hitTest(_root.table_top)){
    _root.table_top2.gotoAndPlay(2);
    delete this.onRelease;
    }else{
    _root.table_top2.gotoAndPlay("wrong");
    delete this.onRelease;
    }
    }
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  6. #6
    Senior Member
    Join Date
    May 2006
    Posts
    119
    I usually do code on the timeline but as a newbie, I could never get my drag and drops to work with hit test when I code them on the time line. But now Kortex has shown me what to do, so I'll be alright

    Thanks Kortex. I will give it a go tomorrow and let you know.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center