我正在使用MediaMind使用ActionScript 2处理SmartVersioning广告(发布商不允许使用AS3)。
跳过它的实现方式 - 基本上我所拥有的是主时间轴上包含可交换图像(通过智能版本控制服务)的MovieClip集合。如果对象位于主时间轴上,则只能将对象定义为智能版本控制对象。
我正在做的是使用BitmapData将主时间轴上的资源用作整个动画中图形的来源。
应该如此简单:
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(143, 230, true, 0);
bmd.draw(_root.person1);
attachBitmap(bmd, getNextHighestDepth());
然而,加载智能版本控制资产(即整个动画中所需的图像)会有延迟 - 因此如果资产未及时加载,这可能导致上述代码失败。
然后我继续将上面的代码修改为:
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(143, 230, true, 0);
onEnterFrame = function():Void
{
bmd.draw(_root.person1);
}
attachBitmap(bmd, getNextHighestDepth());
工作,但有明显的问题,编码很差。那么,有没有办法检查是否有任何图形被绘制到MovieClip这个代码是否在其中运行?类似的东西:
onEnterFrame = function():Void
{
if(<hasNoGraphicsYet>)
bmd.draw(_root.person1);
else
delete(onEnterFrame);
}
答案 0 :(得分:1)
您可以查看width
的{{1}}和height
MovieClip
如果没有任何内容,则应0
。
答案 1 :(得分:1)
使用这些enterFrame检查是不对的是错误的编码。为什么不使用SmartVersioning组件中的COMPLETE事件来确定何时加载资产XML?
来自mediamind的C&amp; P:// wait until all of the Smart Items have been loaded
stop();
import eyeblaster.events.EBSmartVersioningEvent;
// Register to the XML_LOADED event in order to update the Smart Items
SVComp.addEventListener(EBSmartVersioningEvent.XML_LOADED,onXMLloaded);
// Register to the COMPLETE event in order to continue movie playback after all items are updated
SVComp.addEventListener(EBSmartVersioningEvent.COMPLETE,onComplete);
function onXMLloaded(event)
{
// update all Smart Items
SVComp.updateAllItems();
}
function onComplete(event)
{
// check that the Complete event is for all items
if (event.item==null)
{
play();
}
}