Away3D in Flex 4 – Phase 2 – Positioning components

本文介绍了一个使用Away3D与Flex4容器类进行交互的测试案例。该测试中,通过将Panel转换为Canvas容器,实现了Flex组件间的重叠,并通过鼠标悬停事件使3D立方体跳转到文本组件的中间位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Phase 2

First working test of Away3D within Flex 4 container class, interacting with other containers. The main significant change is simple - convert from Panel to Canvas container. Canvas allows Flex component to overlap each other.

Code:

The new Away3DCube.mxml file. Once it's running, pass your mouse over each of the text components, and watch the cube jump to the middle of each line:

<?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"
			   xmlns:local="com.st.mediator.*" minWidth="955" minHeight="600">

	<fx:Script>
		<![CDATA[
			protected function move3DHnd(event:MouseEvent):void
			{
				// TODO Auto-generated method stub
				var obj:* = event.target.parent;
				var opt:Point = new Point(obj.x + (obj.width * .5), obj.y + (obj.height * .5));
				
				trace(event.target.parent.name + ": " + opt);
				
				object3DScene.x = opt.x - (object3DScene.width * .5);
				object3DScene.y = opt.y - (object3DScene.height * .5);
			}
		]]>
	</fx:Script>

	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:BorderContainer width="100%" height="100%" backgroundColor="#D1F0FF">
		<mx:Text id="textTest1" x="175" y="175" text="This is a sample component underlay" mouseOver="move3DHnd(event)" />
		<local:Away3DCube id="object3DScene" width="50%" height="50%" x="100" y="100" />
		<mx:Text id="textTest2" text="This is a sample component overlay." x="200" y="200" mouseOver="move3DHnd(event)" />
	</s:BorderContainer>
</s:Application>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值