两个Flash cc动画在同一个HTML页面 [英] Two Flash cc Animations in the same HTML Page

查看:229
本文介绍了两个Flash cc动画在同一个HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在同一个HTML页面中保存两个或更多的flash cc create.js动画?



问题是第一个消失,第二个动画来了到第一个动画地方。真奇怪。



它包含< script> < / script> 两次。

 < script> 
var canvas,stage,exportRoot;
函数init(){
}
< / script>

这里是链接:
任何人都可以解决这个问题?



您也可以更改图像对象的名称,但您不必。留下CreateJS参考。



接下来,您需要确保每个动画的画布具有唯一的名称。默认情况下,它只是命名为canvas。更改其中一个用法中的画布ID,然后更改创建阶段的相关ID。

 < canvas id =canvaswidth =550height =400style =background-color:#FFFFFF>< / canvas> 

  canvas = document.getElementById(canvas); 

我还建议更改诸如舞台名称,exportRoot和其他变量之类的东西,以防您计划与他们做任何事情如果你不这样做,一切都会以正确的顺序发生。


[更新] :如果您有任何资产加载,您将需要来更改
这些变量的名称。加载资产使模板中的
handleComplete 方法异步 - 意味着
它将始终引用第二个canvas / stage / etc。 >

最后,确保您只定义必需元素一次。您应该只导入一次CreateJS库。有些东西可能不受支持,例如,您只能有一个Ticker帧率。另请注意,在您提供的链接中,您有2个HEAD和BODY标签。你应该将它们整合成一个。



我希望能提供一些有用的方向。


Is there any way to keep two or more flash cc create.js animations in the same HTML page?

The problem is first one goes away and second animation comes to the first animation place. It's strange.

It contains <script> </script> twice.

<script> 
var canvas, stage, exportRoot;
function init() {
}
 </script>

Here is the link: Can anyone solve this? http://canvas.byethost11.com/two/size.html

解决方案

This is possible, but will take some editing on your part. First, you should change the library name for one of your movies. You will need the lib properties object to remain (containing your image manifest, and other FLA properties). Additionally, if you have any similar names of symbols, you might run into collisions, and the first libraries items will be overridden.

You can change the library name in the publish settings. The default is "lib", which generates a window-level object that all symbols are defined on. You can see how the lib is generated in your js files created by Flash CC. .

You may want to change the name of the images object as well, but you don't have to. Leave the CreateJS reference alone.

Next, you need to ensure that the canvas for each animation has a unique name. By default, it is just named "canvas". Change the canvas id in one of the usages, and then change the associated ID where the Stage is created.

<canvas id="canvas" width="550" height="400" style="background-color:#FFFFFF"></canvas>

and

canvas = document.getElementById("canvas");

I also recommend changing things like the name of the stage, exportRoot, and other variables in case you plan on doing anything with them. If you don't it will be fine, provided everything happens in the right order.

[UPDATE]: If you have any assets loading, you will need to change the names of these variables. Loading assets makes the handleComplete method in the template fire asynchronously -- meaning it will always reference the second canvas/stage/etc.

Lastly, make sure you are only defining necessary elements once. You should only import the CreateJS libs once. There are some things that may not be supported, for example, you can only have one Ticker framerate. Also note that in your link you provided, you have 2 HEAD and BODY tags. You should consolidate them into one.

I hope that provides some useful direction.

这篇关于两个Flash cc动画在同一个HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆