flex实现鼠标跟随十字架

效果图

 

添加侦听事件

 

		canVas.addEventListener(MouseEvent.MOUSE_MOVE,mouseMove);
				canVas.addEventListener(MouseEvent.CLICK,ShowLabel);
 

 

鼠标移动事件

private function mouseMove(event:MouseEvent):void

			{

				dataX.x=event.stageX-25;

				dataX.y=canVasHeight+25;

				

				dataY.y=event.stageY;

				dataY.x=8*itemWidth+50;

				

				dataY.visible=true;

				dataX.visible=true;

				

				dataX.text=event.localX.toString();

				dataY.text=event.localY.toString();

			//dataY.text=IsXY.toString();

				

					canVol.graphics.clear();



				if(IsXY)

				{

			 	canVol.graphics.lineStyle(1,0xFFFFFF,.5);

                canVol.graphics.moveTo(0,event.localY);

                canVol.graphics.lineTo((8*itemWidth),event.localY);

                canVol.graphics.moveTo(event.localX,0);

                canVol.graphics.lineTo(event.localX,canVas.height); 



				}				

			}

鼠标单击改变是否显示状态

	private function ShowLabel(event:MouseEvent):void
			{

				if(IsXY)
				{
					IsXY=false;
					
				}
				else
				{
					IsXY=true;
				}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用flex布局制作十字架网页的示例代码: ```html <!DOCTYPE html> <html> <head> <title>Flex Cross Layout</title> <style type="text/css"> body { margin: 0; padding: 0; display: flex; flex-direction: column; min-height: 100vh; } header, footer { background-color: #333; color: #fff; padding: 10px; text-align: center; } main { display: flex; flex: 1; } aside { background-color: #f2f2f2; padding: 10px; flex-basis: 200px; } section { flex: 1; display: flex; flex-direction: column; } section > div { flex: 1; display: flex; flex-direction: row; } section > div > div { flex: 1; padding: 10px; } #left-top { background-color: #f2f2f2; } #left-bottom { background-color: #d9d9d9; } #right { background-color: #e6e6e6; } </style> </head> <body> <header> <h1>Header</h1> </header> <main> <aside> <h2>Aside</h2> <p>Some content here</p> </aside> <section> <div> <div id="left-top"> <h2>Left Top</h2> <p>Some content here</p> </div> <div id="right"> <h2>Right</h2> <p>Some content here</p> </div> </div> <div> <div id="left-bottom"> <h2>Left Bottom</h2> <p>Some content here</p> </div> <div id="right"> <h2>Right</h2> <p>Some content here</p> </div> </div> </section> </main> <footer> <h3>Footer</h3> </footer> </body> </html> ``` 这个示例代码使用了flex布局实现一个十字架网页,其中header和footer分别是顶部和底部的导航栏,main是整个页面的主体部分,包括aside和section两个部分。aside是左侧的导航栏,section是右侧的内容区域,包括两个div,每个div又包括左右两个子div。这个布局可以根据实际需要进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值