A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Help - ActionScripting

  1. #1
    Underdog to the Babes Coven
    Join Date
    May 2003
    Location
    Lincoln, England, UK
    Posts
    110

    Help - ActionScripting

    Me again,

    Tried every possible combination but the right one for this. Basically, whenever the specified player called "hacker" MC object touches the MC called "laser", it should bring a new MC to the middle of the screen. This is done using the function "hack".

    Here's the script for the Laser:

    onClipEvent (load) {
    if (this.hitTest( _root.hacker ) ){
    hack();

    }
    }

    Here's the script for the function:

    onClipEvent (load) {

    function hack(){
    this._x=117;
    this._y=68.5;
    this.gotoAndStop(1);
    }

    }

    Problem is, "hacker" can run over "laser" repeatedly without the function going on.

    Anyone help?

  2. #2
    magnetologicus Magnetos_II's Avatar
    Join Date
    Jan 2004
    Location
    real date May 2001
    Posts
    572
    try

    onClipEvent (enterFrame) {
    if (this.hitTest( _root.hacker ) ){
    hack();

    }


  3. #3
    Senior Member
    Join Date
    Jan 2004
    Posts
    366

    Re: Help - ActionScripting

    Originally posted by krisinyork
    Me again,

    Tried every possible combination but the right one for this. Basically, whenever the specified player called "hacker" MC object touches the MC called "laser", it should bring a new MC to the middle of the screen. This is done using the function "hack".

    Here's the script for the Laser:

    onClipEvent (load) {
    if (this.hitTest( _root.hacker ) ){
    hack();

    }
    }

    Here's the script for the function:

    onClipEvent (load) {

    function hack(){
    this._x=117;
    this._y=68.5;
    this.gotoAndStop(1);
    }

    }

    Problem is, "hacker" can run over "laser" repeatedly without the function going on.

    Anyone help?

    change onClipEvent (load) to onClipEvent(enterFrame)

    load = do only once its loaded.
    enterFrame = on every frame enter.

    otherwise your code looks correct, if it still dotn work post I'll look more into it.

  4. #4
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Even with enterFrame event the code will still move the Laser mc to those coordinates. If you want to bring new mc to those coordinates, then you need to add attachMovie command.

  5. #5
    Underdog to the Babes Coven
    Join Date
    May 2003
    Location
    Lincoln, England, UK
    Posts
    110
    Changed, with no luck

    Sorry, shouldve said its a different MC, like a console that appears over the top of the screen. Still, doesnt really help though...

  6. #6
    Ihoss
    Guest
    put a trace("im hist"); in the first line of the function. then you can see if the function is called or not. the problem might be that you call the function hack() from the laser, and there is no function in laser called hack. instead you should call _root.console.hack(); (change console to the name of the mc with the function).

  7. #7
    Underdog to the Babes Coven
    Join Date
    May 2003
    Location
    Lincoln, England, UK
    Posts
    110
    doesnt seem to want to call it

    edited the script to put in that _root. line

    doesn't seem to work either. Hmmm :/

    AHA! Foolish one... forgot to put _root. before the "hacker" MC name is the hitTest()... duh... lol

    Thanks guys. It's for a team strategy game.

    Bank Robbery :P lol hence the hacker etc Will explain more soon.

    It's I.D
    Last edited by krisinyork; 03-16-2004 at 06:15 PM.

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