• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ADOBE ANIMATE MATCH GAME

New Here ,
May 31, 2024 May 31, 2024

Copy link to clipboard

Copied

This code is currently set up to generate a random match answer. But i want to change the coding to have a specific match answer. can anyone help me on which part must I change?

 

import flash.display.MovieClip;
import flash.events.MouseEvent;
 
var num_linked:Number = 6;
 
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 = [1,2,3,4,5,6];
var counter:Number = 0;
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();

Views

181

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 Expert ,
Jun 23, 2024 Jun 23, 2024

Copy link to clipboard

Copied

i didn't answer you when you first posted because you're asking for a lot of work.  i won't do that for free.

 

so, i left it and watched to see if anyone else would do the work for free.  apparanetly, no.

 

therefore, if you still have a problem, you should probably hire someone to fix it.  you can send me a private message, if you're interested.

Votes

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 Expert ,
Jun 26, 2024 Jun 26, 2024

Copy link to clipboard

Copied

LATEST

Votes

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