The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:43 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 3 posts ] 
[Request] Script Problem 
Author Message
User avatar

Joined: Mon Aug 11, 2008 6:40 am
Posts: 1648
Location: ... Not America
Code:
onClipEvent (load) {
  speed = 0;
  maxmove = 15;
}

onClipEvent (enterFrame) {
  if (_root.dead) {
    this.gotoAndStop("dead");
  } else {
    speed *= .85;
    if (speed>0) {
      dir = "right";
    } else if (speed<0) {
      dir = "left";
    }
    if (dir == "right"){
      this._x += speed;
      _root._x -= speed;
    }
    if (dir == "left") {
      this._x += speed;
      _root._x -= speed;
    }
    if (Key.isDown(Key.LEFT)) {
      if (speed>-maxmove) {
        speed--;
      }
    this.gotoAndStop("run");
    this._xscale = -100;
  } else if (Key.isDown(Key.RIGHT)) {
    if (speed<maxmove) {
      speed++;
    }
    this._xscale = 100;
    this.gotoAndStop("run");
  }
  if (speed<1 && speed>-1 && !attacking) {
    speed = 0;
    this.gotoAndStop("idle");
  }
}
}


I get errors saying this action can only be played in a movie clip, while it is a movie clip.

Symbol=Character, Layer=Layer 1, Frame=1: Line 1: Clip events are permitted only for movie clip instances
onClipEvent (load) {

Symbol=Character, Layer=Layer 1, Frame=1: Line 5: Clip events are permitted only for movie clip instances
onClipEvent (enterFrame) {


Sat Dec 27, 2008 8:58 pm

Joined: Mon Aug 11, 2008 11:33 am
Posts: 22
Are you sure the symbol is a MC?Maybe its a button or graphic.


Sun Dec 28, 2008 4:54 am
User avatar

Joined: Mon Aug 11, 2008 1:09 pm
Posts: 166
Location: England lol
Gender: Male
Currently Playing: Minecraft
I have placed your code into code tags and properly indented it for clarity - not only is it easier to read by indenting it but it also helps to pick out any errors that may occur from misplacing {'s and }'s. I have corrected the code below for you - you basically inserted an extra } at the end of the second onClipEvent statement. Remember any code attached to a movie clip MUST be contained within an onClipEvent statement so in other words it wasn't.

I hope this works, this is the only obvious error I can see without actually reproducing the error in flash. If it doesn't then let me know

Code:
onClipEvent (load) {
  speed = 0;
  maxmove = 15;
}

onClipEvent (enterFrame) {
  if (_root.dead) {
    this.gotoAndStop("dead");
  } else {
    speed *= .85;
    if (speed>0) {
      dir = "right";
    } else if (speed<0) {
      dir = "left";
    }
    if (dir == "right"){
      this._x += speed;
      _root._x -= speed;
    }
    if (dir == "left") {
      this._x += speed;
      _root._x -= speed;
    }
    if (Key.isDown(Key.LEFT)) {
      if (speed>-maxmove) {
        speed--;
      }
    this.gotoAndStop("run");
    this._xscale = -100;
  } else if (Key.isDown(Key.RIGHT)) {
    if (speed<maxmove) {
      speed++;
    }
    this._xscale = 100;
    this.gotoAndStop("run");
  }
  if (speed<1 && speed>-1 && !attacking) {
    speed = 0;
    this.gotoAndStop("idle");
  }
}


Sun Dec 28, 2008 12:29 pm
WWW
Display posts from previous:  Sort by  
 [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.