Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

RSS Feed Item

Flash Player 10 : rotation (x,y,z) properties example

One of the new ActionScript APIs include in Flash Player 10 are the addition of z based proprties (joining the existing x and y). The DisplayObject.z and DisplayObject.rotationZ properties allow you to manipulate your display object on the z axis (relative to the 3D parent container).

Below is a simple example that shows how changing the rotationX, rotationY and rotationZ properties affect a DisplayObject instance.

The UI is in Flex, but of course, the APIs also work in Flash Authoring. The example requires the Flash Player 10 RC release from labs.

Here is the code for the application (basically just sets the properties for the sprites):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	backgroundColor="0xFFFFFF"
	creationComplete="onCreationComplete()"
	>

	<mx:Script>
		<![CDATA[
			[Embed(source="graphics.swf", symbol="logo")]
			[Bindable]
			private var logoClass:Class;
			
			private function onCreationComplete():void
			{
				frameRateSlider.value = systemManager.stage.frameRate;
			}
			
			private function onValueChange(e:Event):void
			{
				var slider:HSlider = HSlider(e.target);
				switch(slider)
				{
					case rotationXSlider:
					{
						logo.rotationX = slider.value;
						break;
					}
					case rotationYSlider:
					{
						logo.rotationY = slider.value;
						break;
					}
					case rotationZSlider:
					{
						logo.rotationZ = slider.value;
						break;
					}
				}	
			}
			
			private function onAnimateSelect():void
			{
				if(animateXCB.selected || animateYCB.selected ||
						animateZCB.selected)
				{
					addEventListener(Event.ENTER_FRAME, onEnterFrame);
					return;
				}
				
				if(!animateXCB.selected && !animateYCB.selected &&
						!animateZCB.selected)
				{
					removeEventListener(Event.ENTER_FRAME, onEnterFrame);
					return;
				}
				
			}
			
			private var xDirection:int = 1;
			private function onEnterFrame(e:Event):void
			{
				if(animateXCB.selected)
				{
					animateSlider(rotationXSlider, "rotationX");
				}
				
				if(animateYCB.selected)
				{
					animateSlider(rotationYSlider, "rotationY");
				}
				
				if(animateZCB.selected)
				{
					animateSlider(rotationZSlider, "rotationZ");
				}
			}
			
			private function animateSlider(slider:HSlider, property:String):void
			{
				if(logo[property] == 180)
				{
					logo[property] = -180;
				}
				else
				{
					logo[property] += 2;
				}
				
				slider.value = logo[property];
			}
				
			private function onFrameRateChange():void
			{
				stage.frameRate = Math.ceil(frameRateSlider.value);
			}
		]]>
	</mx:Script>

	<mx:Panel layout="absolute" right="10" left="10" top="10" bottom="10"
										title="DisplayObject Z Properties Example"
																color="#000000" height="619">

		<mx:Label text="rotationX" left="10" bottom="4"/>
		<mx:Label text="rotationY" left="10" bottom="30"/>
		<mx:Label text="rotationZ" left="10" bottom="56"/>

		<mx:HSlider left="73" bottom="5" id="rotationXSlider" minimum="-180"
							maximum="180" allowTrackClick="true"
							value="0"
							change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
		<mx:HSlider left="73" bottom="36" id="rotationYSlider"
							allowTrackClick="true" minimum="-180" maximum="180"
							value="0"
							change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
		<mx:HSlider left="73" bottom="62" id="rotationZSlider"
							allowTrackClick="true" minimum="-180" maximum="180"
							value="0"
							change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
		<mx:VRule height="64" bottom="10" left="338"/>
		<mx:HRule bottom="82" left="10" right="10"/>
		<mx:Image width="200" height="200" id="logo"
					source="{logoClass}" horizontalCenter="0" top="150"/>
		<mx:Image width="200" height="200" right="9" horizontalCenter="0" top="150"
							alpha=".05"
			 				source="{logoClass}"/>
		<mx:CheckBox label="Animate" left="239" bottom="54" id="animateZCB" click="onAnimateSelect()"/>
		<mx:CheckBox label="Animate" left="239" bottom="28" id="animateYCB" click="onAnimateSelect()"/>
		<mx:CheckBox label="Animate" left="239" bottom="2" id="animateXCB" click="onAnimateSelect()"/>
		<mx:Label text="Framerate" bottom="4" left="348"/>
		<mx:HSlider left="418" bottom="5"
							id="frameRateSlider"
							liveDragging="true"
							allowTrackClick="true" minimum="1" maximum="70"
							change="onFrameRateChange()"/>
	</mx:Panel>

</mx:Application>

 

You can find more information on the z and rotationZ properties in the DisplayObject entry in the Flash Player 10 ActionScript APIs docs.

You can find more information on Flash Player 10 on labs.

Read the original blog entry...

IoT & Smart Cities Stories
Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.