English 中文(简体)
Flash AS3 - 添加反射/mirror 以拖动可拖动的电影剪
原标题:Flash AS3 - Adding reflection/mirror to draggable movieclip

我要创建一个闪光文件, 从 1 张图像中创建模式形状。 它需要反射或反射一个已装入的拖动的电影剪切, 并在您移动并拖动电影剪切时更新反射/ mirror 。

I had come across: http://active.tutsplus.com/freebies/actionscript-30-classes/dynamic-reflection-generator-class-for-as3/ which does very similar to what i m after. The demo seems ok but as in the comments there is lots of slowdown and lag in the dragging, especially when the image you drag starts off larger.

对不起,问什么似乎 似乎相当一点点, 我不在完全的解决方案之后, 我只需要首先知道,如果它能够做到, 我如何能够去实现它?

我希望以下图像能帮助解释:

Stage 1: Loading the users pattern image onto the stage as seen here:

http://www.tiltworld.co.uk/yhfus6fh/patten_1.png

Stage 2: Shows how i want the reflection to work - in 4 blocks on each side of the pattern:

.../模式_2.png

(与以上链接相同,仅与图案_ 2.png 结尾处相同)

Stage 3: Getting the reflection to adapt to where the user drags the pattern around on the stage. As in the image the reflection happens within the 4 blocks on each side rather than attached directly onto/next to the original movieclip.

.../模式3.png

(与以上 2 的链接相同, 结尾处有图案_ 3. png )

劳伦:

p. s. 下面我目前的代码显示目前阶段 1 - 我如何使用文件Reference. load 然后启动 Drag 将其拖动到舞台上 。

// Create FileReference.
var draggableMC:FileReference;

// Create Loader to hold image content
var draggable_mc_loader:Loader = new Loader();
var draggable_mc_content:Sprite = new Sprite();

// Select Button Function.
select_btn.addEventListener(MouseEvent.CLICK, onselect_btnClicked);

function onselect_btnClicked(event:MouseEvent):void {
draggableMC=new FileReference();
draggableMC.addEventListener(Event.SELECT, onFileSelected);
var imageTypeFilter:FileFilter = new FileFilter("JPG/PNG Files","*.jpeg; *.jpg;*.gif;*.png");
draggableMC.browse([imageTypeFilter]);
}

// File Selected Function.
function onFileSelected(event:Event):void {
draggableMC.addEventListener(Event.COMPLETE, onFileLoaded);
draggableMC.load();
}

// File Loaded Function.
function onFileLoaded(event:Event):void {
var fileReference:FileReference=event.target as FileReference;

var data:ByteArray=fileReference["data"];
var movieClipLoader:Loader=new Loader();
movieClipLoader.loadBytes(data);
movieClipLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMovieClipLoaderComplete);

draggableMC.removeEventListener(Event.COMPLETE, onFileLoaded);
}

// Load Image onto Stage Function.
function onMovieClipLoaderComplete(event:Event):void {
var loadedContent:DisplayObject=event.target.content;
draggable_mc_loader =event.target.loader as Loader;
draggable_mc_loader.x=10;
draggable_mc_loader.y=10;
draggable_mc_content.buttonMode=true;
draggable_mc_content.addChild(draggable_mc_loader);
addChild(draggable_mc_content);
}

// Drag
draggable_mc_content.addEventListener(MouseEvent.MOUSE_DOWN, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, drop);

function drag(event:Event):void {
draggable_mc_content.startDrag();
}
function drop(event:Event):void {
draggable_mc_content.stopDrag();
}
问题回答

这是完全可以完成的, 您是否尝试过使用他的组件 。 在查看您链接的组件的字符串中的代码时, 他将它更新在不理想的鼠标Move上, 多移动事件可以在一个框架环中发送( 默认框架速率为24, 所以每秒的1/ 24 次将是一个框架环, 以鼠标Move为基础的更新将会不必要地快 。 如果只是调整它来打开一个在对象点击后每秒10秒中键出一个计时器( 鼠标上下转, 或滚动), 而不是试图在鼠标每移动的事件上更新代码, 它会大大改善性能。 此外, 他得到了一个相当低的效率, 正如他所说的, 如果你需要优化某项任务的话, 以鼠标MouseMoveth 为基础, 他的代码中有些其他效率就是在方法调中创建对象, 可以拖进构建器中, 而过滤器的用途在您的例子中似乎是必要的。 刚刚从 AS3- 803- liversal3_ ma_ a pain hass hell_ hillations hillations. 83_ 83_ a- ma_ remaxill_ a- ligimals_ lical_ hillations hillations_ 83_ 83_ lical_ li





相关问题
c# reflection with dynamic class

I need to execute a method "FindAll" in my page. This method returns a list of the object. This is my method that I execute "FindAll". FindAll requires an int and returns an List of these class. ...

Performance overhead of using attributes in .NET

1.. Is there any performance overhead caused by the usage of attributes? Think for a class like: public class MyClass { int Count {get;set;} } where it has 10 attibutes (...

WPF GridView, Display GetType().Name in DisplayMemberBinding

I want include the Type name of each object in my collection from my GridView. I have a collection which has four different types in it that all derive from a base class. Call them, Foo, Bar, Fizz, ...

Testing private method of an abstract class using Reflection

How can I test a private method of an abstract class using reflection (using C#)? I am specifically interested in adapting the code found in this thread. I am aware of the discussion around the ...

Adding Items to ListBox, RadioList, Combobox using reflection

I m trying to add items to a listbox,combobox, radiolist using reflection. The code I have at the moment is as follows: public static Control ConfigureControl(Control control, ControlConfig ctrlconf)...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

热门标签