まずはmcObjectの書き直し
前回使用したmcObjectは問題だらけだし、勘違いだらけなので
変更しなくてはならなかった。詳しくは"おまけ"を見てね。
あとinit()を作ろう
今のままではフレーム数によってループしてしまうので、
ループしないようにする。ということでinit()を作ろう。
詳しくは おまけのinit付をみてもらうとして。
$Check = new mcObject();
$item =$Movie->add($Check->getMovieClip());
$item->setName("check");
$Movie->add(newSWFAction
("
onEnterFrame = function()
{
if(_root.check._x != 256)
{
init();
_root.check._x = 256;
}
}
"))
現在はいりませんが、Checkにはmovieclipを受け取ってinit()してあげる機能を持たせることにしましょう。
init()はCheckが受け持つことにします。
↓感じだけ
init = function( movieclip)
{
for(i = 0;i< movieclip_len;i++){
_root.check.init(movieclip[movieclip.name[i]]);
}
movieclip.init();
};
作ってみていないのでかりませんが、上みたいな感じでできないでしょうか?
おまけ
mcObject.php
実験する
<?php
class mcObject
{
protected $_movieclip; //SWFSprite
protected $_displayitem;//SWFDisplayitem
protected $_action;
protected $_figure;
protected $_name;
protected $_mcObjects;
function __construct($name)
{
print("mcObject const \n");
$this->_name = name;
$this->_action= null;
$this->_figure = null;
$this->_displayitem = null;
$this->_movieclip = new SWFSprite();
$this->_mcObjects = array();
}
function addmcObject($obj){
$this->_mcObjects[count($this->_mcObjects)+1] = $obj;
}
function setName($name)
{
$this->name = $name;
}
function getName()
{
return $this->_name;
}
function setDisplayitem($dis)
{
print("get".$this->_displayitem);
$this->$_displayitem = $dis;
}
function getDisplayitem()
{
// print("ge$this->_displayitem);
return $this->$_displayitem;
}
function setAction($pen)
{
$this->_action = $pen;
}
function setFigure($pen)
{
$this->_figure = $pen;
}
function getMovieclip()
{
return $this->_movieclip;
}
function compile()
{
if($this->_figure != null){
print("figure_compile");
$this->_movieclip->add($this->_figure);
}
for($i=0; $i < count($this->_mcObjects)+1;$i++)
{
if($this->_mcObjects[$i] != null)
{
$this->_mcObjects[$i]->compile();
$this->_mcObjects[$i]->setDisplayitem
(
$a = $this->_movieclip->add($this->_mcObjects[$i]->getMovieclip())
);
$this->_mcObjects[$i]->getDisplayitem()->setName($this->_mcObjects[$i]->getName());
$this->_mcObjects[$i]->getDisplayitem()->moveTo(0,0);
}
}
$this->_movieclip->nextFrame();
if($this->_action !=null){
$this->_movieclip->add($this->_action);
$this->_movieclip->nextFrame();
}
}
}
$spRet = new SWFShape();
$spRet->setLine(2,0,30,20);
$spRet->setRightFill(10,10,100,100);
$spRet->drawLine(0,50);
$spRet->drawLine(50,0);
$spRet->drawLine(0,-50);
$spRet->drawLine(-50,0);
$spRect = new SWFShape();
$spRect->setLine(2,0,30,20);
$spRect->setRightFill(10,10,10,100);
$spRect->drawLine(0,5);
$spRect->drawLine(5,0);
$spRect->drawLine(0,-5);
$spRect->drawLine(-5,0);
$via = new mcObject("mister");
$cla = new mcObject("love");
$cla->setFigure($spRet);
$via->setFigure($spRect);
$cla->addmcObject($via);
$cla->compile();
ming_useSWFVersion(6);
$Movie = new SWFMovie();
//$Movie->setDimension(10*5,10*5*5);
$Movie->add($cla->getMovieclip());
$Movie->save("Movie.swf");
?>
mcCircle.php
<?php
include_once("mcObject.php");
class mcCircle extends mcObject
{
function __construct($nam)
{
parent::__construct(nam);
print("mcCirle Const");
$spRect = new SWFShape();
$spRect->setLine(2,0,30,20);
$spRect->setLeftFill(10,10,10,100);
$spRect->movepento(10*cos(0),10*sin(0));
for($i = 0;$i<36;$i++){
$spRect->drawLineTo(10*cos($i/6),10*sin($i/6));
}
$spRect->drawLineTo(10*cos(0),10*sin(0));
$this->setFigure($spRect);
}
}
?>
mcRect
<?php
include_once("mcObject.php");
class mcRect extends mcObject
{
function __construct($nam)
{
parent::__construct($nam);
print("mcRect Const");
$spRect = new SWFShape();
$spRect->setLine(2,0,30,20);
$spRect->setRightFill(10,10,10,100);
$spRect->drawLine(0,5);
$spRect->drawLine(5,0);
$spRect->drawLine(0,-5);
$spRect->drawLine(-5,0);
$this->setFigure($spRect);
}
}
?>
おまけ
init付き
こんなのできます
<?php
include_once("mcRect.php");
include_once("mcCircle.php");
$Rect = new mcRect("rect");
$Circle = new mcCircle("circle");
$Check = new mcObject("check");
$Movie = new SWFMovie();
$Circle->setAction
(
new SWFAction(
"
var accel;
this.init = function(){
this.accel = 0;
};
this.onEnterFrame = function(){
this._x += this.accel;
this.accel +=1;
};
")
);
$Circle->getMovieclip()->setFrames(100);
$Rect->compile();
$Circle->compile();
/*
for($i = 0;$i <97;$i++){
$Circle->getMovieclip()->nextFrame();
}
*/
ming_useSWFVersion(5);
$Movie->setDimension(200,200);
$Movie->setFrames(100);
$item_check = $Movie->add($Check->getMovieclip());
$item_check->setName("check");
$item_rect = $Movie->add($Rect->getMovieclip());
$item_rect->setName("rect");
$item_rect->moveto(50,100);
$item_circle = $Movie->add($Circle->getMovieclip());
$item_circle->moveto(100,100);
$item_circle->setName("circle");
$Movie->nextFrame();
$Movie->add(new SWFAction
("
this.onEnterFrame =function()
{
_y +=1;
if(_root.check._x != 255){
_root.circle.init();
_root.check._x = 255;
}
};
"));
$Movie->nextFrame();
$Movie->save("Action.swf");
?>