Actionscript 3.0 how to remove or stop movieclip.

Community Beginner ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

this is the coding, can someone spot me what wrong with the code. the picture 2 below show that the link and black button still. i hope someone can help me. im begging

 

import flash.display.MovieClip;
import flash.events.MouseEvent;

var num_linked:Number = 3;

var stat_line:Boolean = false;
var _stloop:Boolean = false;
var _stdone:Boolean = false;
var num_fra:Number = 0;
var num_loop:Number = 0;
var num_true:Number = 0;
var num_step:Number = 0;

var _loop:MovieClip = new MovieClip();
_loop.addEventListener(Event.ENTER_FRAME,enterLoop);

function start_linked():void
{
var ar_link:Array = [];
for (var i:Number = 1; i <= num_linked; i++)
{
ar_link[i] = true;
if (i >= num_linked)
{
ar_link[0] = false;
set_linked(ar_link);
}
}

var _check:MovieClip = getChildByName("bt_check") as MovieClip;
_check.buttonMode = true;
_check.st = false;
_check.alpha = .2;
_check.addEventListener(MouseEvent.CLICK,clickCheck);

var _refresh:MovieClip = getChildByName("bt_refresh") as MovieClip;
_refresh.buttonMode = true;
_refresh.st = false;
_refresh.alpha = .2;
_refresh.addEventListener(MouseEvent.CLICK,clickRefresh);
}

function randomNumber(_ar:Array):Number
{
var _num:Number = 0;
do
{
_num = Math.floor(Math.random() * (num_linked + 1));
} while (_ar[_num] == false);
return _num;
}

function set_linked(_ar:Array):void
{
var _num:Number;

var _linked:MovieClip;
var _lefted:MovieClip;
var left_drag:MovieClip;
var _righte:MovieClip;
var _express:MovieClip;
for (var i:Number = 1; i <= num_linked; i++)
{
_num = randomNumber(_ar);
_ar[_num] = false;
_linked = getChildByName("link_text"+i) as MovieClip;
_linked.gotoAndStop(_num);

_righte = getChildByName("right"+i) as MovieClip;
_righte.tgt = 0;
_righte.inm = _num;

_lefted = getChildByName("left"+i) as MovieClip;
left_drag = new point_mc();
left_drag.name = "drag" + i;
left_drag.x = _lefted.x;
left_drag.y = _lefted.y;
left_drag.stat = true;
left_drag.icd = i;
left_drag.drg = false;
addChild(left_drag);
left_drag.addEventListener(MouseEvent.MOUSE_DOWN,start_drag);
left_drag.addEventListener(MouseEvent.MOUSE_MOVE,move_drag);
left_drag.addEventListener(MouseEvent.CLICK,click_drag);

_express = new mv_exp();
_express.name = "exp" + i;
_express.gotoAndStop(1);
_express.x = _righte.x + (_righte.width / 2);
_express.y = _righte.y;
_express.visible = false;
addChild(_express);
}
}

function start_drag(e:MouseEvent):void
{
if (e.currentTarget.stat)
{
e.currentTarget.startDrag(true);
stat_line = false;
start_line(e.currentTarget.icd,true);

e.currentTarget.drg = true;
}
}

function start_line(a:Number,b:Boolean):void
{
var _line:MovieClip;
if (stat_line)
{
_line = getChildByName("line"+a) as MovieClip;
removeChild(_line);
stat_line = false;
}
if (b)
{
_line = new MovieClip();
_line.name = "line" + a;
addChild(_line);

var _left:MovieClip = getChildByName("left"+a) as MovieClip;
var left_drag:MovieClip = getChildByName("drag"+a) as MovieClip;
setChildIndex(left_drag,numChildren-1);

_line.graphics.lineStyle(4, 0x000000, .75);
_line.graphics.moveTo(_left.x,_left.y);
_line.graphics.lineTo(left_drag.x,left_drag.y);
stat_line = true;
}
}

function move_drag(e:MouseEvent):void
{
if (e.currentTarget.stat && e.currentTarget.drg)
{
start_line(e.currentTarget.icd,true);
}
}

function click_drag(e:MouseEvent):void
{
if (e.currentTarget.stat)
{
e.currentTarget.stopDrag();
e.currentTarget.drg = false;

var left:MovieClip = getChildByName("left"+e.currentTarget.icd) as MovieClip;
var _line:MovieClip;
for (var i:Number = 1; i <= num_linked; i++)
{
var _right:MovieClip = getChildByName("right"+i) as MovieClip;
if (e.currentTarget.hitTestObject(_right))
{
if (_right.tgt == 0)
{
_right.tgt = e.currentTarget.icd;
e.currentTarget.x = _right.x;
e.currentTarget.y = _right.y;
e.currentTarget.stat = false;
start_line(e.currentTarget.icd,true);
check_placed();
break;
}
}
if (i >= num_linked)
{
e.currentTarget.x = left.x;
e.currentTarget.y = left.y;
start_line(e.currentTarget.icd,false);
break;
}
}
}
}

function check_placed():void
{
var _num:Number = 0;

var _right:MovieClip;
for (var i:Number = 1; i <= num_linked; i++)
{
_right = getChildByName("right"+i) as MovieClip;
if (_right.tgt != 0)
{
_num++;
}
if (i >= num_linked)
{
var _check:MovieClip = getChildByName("bt_check") as MovieClip;
_check.st = false;
_check.alpha = .2;
if (_num >= num_linked)
{
_check.st = true;
_check.alpha = 1;
}
break;
}
}
}

function clickCheck(e:MouseEvent):void
{
if (e.currentTarget.st)
{
e.currentTarget.st = false;
e.currentTarget.alpha = .2;
e.currentTarget.gotoAndStop(1);

num_true = 0;

var _right:MovieClip;
for (var i:Number = 1; i <= num_linked; i++)
{
_right = getChildByName("right"+i) as MovieClip;

var _express:MovieClip = getChildByName("exp"+i) as MovieClip;
setChildIndex(_express,numChildren - 1);
trace(_right.tgt+" - "+_right.inm);
if (_right.tgt == _right.inm)
{
_express.gotoAndStop(1);
num_true++;
}
else
{
_express.gotoAndStop(20);
}
if (i >= num_linked)
{
num_fra = 5;
num_loop = 1;
_stloop = true;
break;
}
}
}
}

function enterLoop(e:Event):void
{
if (_stloop)
{
var _refresh:MovieClip = getChildByName("bt_refresh") as MovieClip;

if (num_fra <= 0)
{
var _express:MovieClip = getChildByName("exp"+num_loop) as MovieClip;
_express.visible = true;
setChildIndex(_express,this.numChildren - 1);
_express.play();
num_loop++;
num_fra = 25;
if (num_loop > num_linked)
{
if (num_true < num_linked)
{
_refresh.alpha = 1;
_refresh.st = true;
}
else
{
_stdone = true;
}
_stloop = false;
}
}
else
{
num_fra--;
}
}
}

function clickRefresh(e:MouseEvent):void
{
if (e.currentTarget.st)
{
e.currentTarget.st = false;
e.currentTarget.alpha = .2;
e.currentTarget.gotoAndStop(1);

num_step++;

var _express:MovieClip;
var left_drag:MovieClip;
for (var i:Number = 1; i <= num_linked; i++)
{
left_drag = getChildByName("drag"+i) as MovieClip;
removeChild(left_drag);

stat_line = true;
start_line(i,false);

_express = getChildByName("exp"+i) as MovieClip;
removeChild(_express);
if (i >= num_linked)
{
start_linked();
break;
}
}
}
}

start_linked();

 

a.jpgb.jpg

Views

170

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

In two places you make new objects. Do those objects extend MovieClip? You could change the lines so that the objects are created as MovieClip. Like this:

 

_express = new mv_exp() as MovieClip;

left_drag = new point_mc() as MovieClip;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

yess the object extend movieclip. i already change the line, but the output same. the object still extend. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

can someone else help me with this prob ??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

pliss someone??? help me to solve this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

thanks. but nothing can helps me. :'(

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

Hi.

 

Sorry for the long delay.

 

It's a rather complex code. Would you mind sharing the FLA?

 

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 28, 2021 Apr 28, 2021

Copy link to clipboard

Copied

Thanks for the file.

 

The first errors that I found are duplicated variable definitions and functions declarations. In AS3, variables and functions must have unique names even if they are in different frames.

 

I fixed these and now the game at least starts and it is navigable. I also did some really quick housekeeping so that your code is easier to understand.

https://drive.google.com/file/d/19AODq9k_RDTxntIE3lX9EAd94iJVIKgJ/view?usp=sharing

 

In addition to the errors mentioned above, what exactly do you need to fix?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

ohh actually my mistake put two fla. the correct is RECOVER_Game Diet. that has something wrong which as u can see at the picture above. for the second picture, actually i need to stop the movieclip.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

Your current version is your RECOVER backup?!?

 

This will end well.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

LATEST

no, the recover not current version. then i use current version but still a problem. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines