![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
Регистрация: Aug 2005
Сообщений: 64
|
Проблема в следующем.
Если на кадре пишу применение полученого Motion всё отлично работает, вот код: import fl.motion.Animator; var motion2:Motion2=new Motion2(); this.addChild(motion2); var motion2_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*"> <source> <Source frameRate="12" x="12.25" y="6.5" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="s1"> <dimensions> <geom:Rectangle left="0" top="0" width="24.5" height="13"/> </dimensions> <transformationPoint> <geom:Point x="0.5" y="0.5"/> </transformationPoint> </Source> </source> <Keyframe index="0"> <tweens> <SimpleEase ease="0"/> </tweens> </Keyframe> <Keyframe index="29" x="130"/> </Motion>; var motion2_animator:Animator = new Animator(motion2_xml, motion2); motion2_animator.play(); package {
import flash.display.*;
import flash.events.*;
import fl.motion.Animator;
import fl.motion.Motion;
public class Temp extends MovieClip{
public var motion2_xml:XML;
public var motion2:Motion2;
public function Temp(){
trace("Temp");
motion2_xml=<Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="12" x="12.25" y="6.5" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="s1">
<dimensions>
<geom:Rectangle left="0" top="0" width="24.5" height="13"/>
</dimensions>
<transformationPoint>
<geom:Point x="0.5" y="0.5"/>
</transformationPoint>
</Source>
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease="0"/>
</tweens>
</Keyframe>
<Keyframe index="29" x="130"/>
</Motion>;
motion2=new Motion2();
this.addChild(motion2);
motion2.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e:MouseEvent):void{
trace("click");
var motion2_animator:Animator = new Animator(this.motion2_xml, this.motion2);
motion2_animator.play();
}
}
}
|
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Исходник в студию.
|
|
|||||
|
Регистрация: Aug 2005
Сообщений: 64
|
А вот исходник
http://newman.at.tut.by/temp.zip |
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Фиг его знает, чего он не хочет ехать, пришлось ручками заставить:
package {
import flash.display.*;
import flash.events.*;
import fl.motion.*;
[SWF(width="910", height="650", backgroundColor="#cccccc", frameRate="12")]
public class Temp extends Sprite{
private var animator:Animator;
private var motion:Motion;
public function Temp(){
var motion2_xml:XML =<Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="12" x="12.25" y="6.5" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="motion2">
<dimensions>
<geom:Rectangle left="0" top="0" width="24.5" height="13"/>
</dimensions>
<transformationPoint>
<geom:Point x="0.5" y="0.5"/>
</transformationPoint>
</Source>
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease="0"/>
</tweens>
</Keyframe>
<Keyframe index="29" x="130"/>
</Motion>;
var motion2:Motion2 = new Motion2();
motion2.name = 'motion2';
animator = new Animator(motion2_xml);
motion = new Motion(motion2_xml);
animator.target = motion2;
this.addChild(motion2);
motion2.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e:MouseEvent):void{
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
private function enterFrameHandler(e:Event):void {
if (animator.time<motion.duration) {
animator.time++;
} else {
removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
}
}
}
|
|
|||||
|
Регистрация: Aug 2005
Сообщений: 64
|
Спасибо!!!!
Попробовал вот так, тоже работает package {
import flash.display.*;
import flash.events.*;
import fl.motion.*;
[SWF(width="910", height="650", backgroundColor="#cccccc", frameRate="12")]
public class Temp extends Sprite{
private var animator:Animator;
private var motion:Motion;
public function Temp(){
var motion2_xml:XML =<Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
<source>
<Source frameRate="12" x="12.25" y="6.5" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="motion2">
<dimensions>
<geom:Rectangle left="0" top="0" width="24.5" height="13"/>
</dimensions>
<transformationPoint>
<geom:Point x="0.5" y="0.5"/>
</transformationPoint>
</Source>
</source>
<Keyframe index="0">
<tweens>
<SimpleEase ease="0"/>
</tweens>
</Keyframe>
<Keyframe index="29" x="130"/>
</Motion>;
var motion2:Motion2 = new Motion2();
motion2.name = 'motion2';
animator = new Animator(motion2_xml);
motion = new Motion(motion2_xml);
animator.target = motion2;
this.addChild(motion2);
motion2.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e:MouseEvent):void{
animator.play();
}
}
}
|
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Тогда motion не нужен.
|
|
|||||
|
А если у меня начальные и конечные координаты хранятся в переменных, как их подставить в motion_XML ?
|
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Отредактировать или собрать XML в рантайме.
|
|
|||||
|
Регистрация: Nov 2006
Сообщений: 155
|
Извиняюсь, что пишу в столь древней теме, но вчера долго долбался с этой же проблемой.
Оказалось все дело в том, что объект animator объявляется в методе. В этом случае, он будет играть только один кадр, поскольку скорее всего ссылка на объект убивается. Поэтому animator нужно сделать параметром документ класса. Надеюсь, кому-то поможет
__________________
Нет ничего невозможного |
![]() |
![]() |
Часовой пояс GMT +4, время: 23:18. |
|
|
« Предыдущая тема | Следующая тема » |
|
|