将网站放在 flex 中 [英] center a website in flex

查看:29
本文介绍了将网站放在 flex 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个 flex 网站.我面临的问题是我的网站页面未居中.我已经搜索了 google 但还没有成功.

我试图将 <s:Application> 放在我的网络浏览器上,而不是从左手开始我该怎么做?

解决方案

据我了解:-

1) 您正在尝试将 swf 嵌入到 HTML 中,如果您希望您的 swf 位于 HTML 的中心,则必须将 swf 嵌入到 HTML 端的一个容器中.通过为其提供 x、y、高度和宽度,将您的容器位置置于中心.

如果您使用的是 HTML,您可以通过以下方式进行:-其中 width="400" height="300" 作为您的 Flex 应用程序 swf 宽度和高度或保持 swf width="100%" height="100%"您可以将 AreaChart.swf 替换为您的 swf 名称.

我认为这可以解决您的问题.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><头><title>Title Here</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><style type="text/css" media="screen">html, body { 高度: 100%;保证金:0;填充:0;文本对齐:居中;}div#center {边框:0;高度:50%;宽度:50%;位置:绝对;左:25%;顶部:25%;颜色:黑色;}</风格><script type="text/javascript" src="swfobject.js"></script><script type="text/javascript">swfobject.registerObject("myId", "8.0.0", "expressInstall.swf");<身体><div id="居​​中"><object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300"><param name="电影" value="AreaChart.swf"/><param name="scaleMode" value="showAll"/><param name-"quality" value="best"/><!--[if !IE]>--><object type="application/x-shockwave-flash" data="AreaChart.swf" width="400" height="300"><!--<![endif]--><div id="altContent"><h1>您需要升级 Flash 播放器.</h1><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="获取 Adob​​e Flash 播放器"/></a></p>

<!--[if !IE]>--></对象><!--<![endif]--></对象>

</html>

其他

2) 如果您想将 Flex 内容集中在 Flex 应用程序中,那么您必须创建一个容器,并在其中移植所有逻辑,包括可视组件等.

例如:-

</fx:脚本><fx:声明><!-- 在此处放置非可视元素(例如,服务、值对象)--></fx:声明><local:MainContainer id="mainContainer" width="50%" height="50%" creationComplete="creationComp()"/></s:应用程序>

MainContainer.mxml 将包含所有可视组件/元素.

这可能对您有所帮助.

可能有更好的解决方案.

I am trying to make a websites in flex. I am facing the problem that my website page is not centered. I Have searched google but haven't succeeded yet.

I am trying to center <s:Application> on my web browsers instead of starting from left hand How can i do that?

解决方案

As per my understanding: -

1) you are trying to embed swf in to HTML, if you want your swf to be at the center of HTML you have to embed swf in to one container on HTML side. Place your container position at center by providing x, y, height and width to it.

If you are using HTML you can do in this below way: - Where as width="400" height="300" as your Flex Application swf width and height or keep swf width="100%" height="100%" You can replace AreaChart.swf with your swf name.

I think this can solve your problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>Tittle Here</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

        <style type="text/css" media="screen">
            html, body { height: 100%; margin:0; padding:0; text-align: center; }
            div#centered { border:0; height: 50%; width: 50%; position: absolute; left: 25%; top: 25%; color: black; }
        </style>        
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
        swfobject.registerObject("myId", "8.0.0", "expressInstall.swf");
        </script>
    </head>
    <body>
        <div id="centered">    
            <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300">
            <param name="movie" value="AreaChart.swf" />
            <param name="scaleMode" value="showAll" />
            <param name-"quality" value="best" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="AreaChart.swf" width="400" height="300">
                <!--<![endif]-->
                <div id="altContent">
                    <h1>You need to upgrade your Flash player.</h1>
                    <p>
                    <a href="http://www.adobe.com/go/getflashplayer">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                    </a>
                    </p>
                </div>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>

else

2) If you are trying to center your Flex content inside of your Flex application than you have to create one container and inside that you have to port your all logic including visual component etc.

Ex: -

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*"
               width="800" height="600" >
    <fx:Script>
        <![CDATA[
            import mx.core.FlexGlobals;

            private function creationComp():void
            {
                mainContainer.x = FlexGlobals.topLevelApplication.width/2 - mainContainer.width/2;
                mainContainer.y = FlexGlobals.topLevelApplication.height/2 - mainContainer.height/2;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <local:MainContainer id="mainContainer" width="50%" height="50%" creationComplete="creationComp()"/>

</s:Application>

Where as MainContainer.mxml will contain for all visual component/elements.

This may help you.

There might be better solution to this.

这篇关于将网站放在 flex 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆