开发者

AS3 How to center MC + change background color?

开发者 https://www.devze.com 2022-12-31 16:49 出处:网络
I am quite new to AS3 and I have never worked with classes, so I am encountering a couple of problems.

I am quite new to AS3 and I have never worked with classes, so I am encountering a couple of problems.

开发者_运维问答

I'd like to center a movieclip, have it so that it doesn't scale. And then I'd like to add a background color that stays there no matter how I scale the browser.

Can someone please explain me this in babysteps? Since I don't know how to implement a class and make it work with my fla.

Thank you so much!

J.


If I've followed you correctly, you want to have your swf file in the centre of a webpage, to change the background colour, and to stop the swf from stretching if you drag the boundaries of the web browser around?

If so, your question is a more HTML related, as none of that can be accomplished through ActionScript. If what you want to do is position your swf inside an HTML file correctly, you can make Flash export the HTML file for you (assuming you're using the Flash IDE).

Here's a link that'll guide you through the process of doing that, it's very clearly written: http://www.w3schools.com/flash/flash_inhtml.asp

To change your web page's background colour, see this site: http://www.tizag.com/htmlT/bgcolor.php

Once you've got that HTML file exported from Flash, you can check how it will align your Flash swf to the rest of the webpage. Somewhere in the code should be something like align="left", and you can change that to centre, right, etc.

Hope that helps,

debu


to center it you can do:

var toCenterMc:MovieClip = new MovieClip();

toCenterMc.x = stage.stageWidth/2 - toCenterMc.width/2;
toCenterMc.y = stage.stageHeight/2 - toCenterMc.height/2;

backgroundcolor you can add with this tag (it has to be above the class header, that means the code line that says public class example extends exampleparent):

[SWF(backgroundColor="0xec9900")]
0

精彩评论

暂无评论...
验证码 换一张
取 消