<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Deyan Vitanov portfolio &#187; Software</title>
	<atom:link href="http://bgdevs.com/?cat=3&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://bgdevs.com</link>
	<description>Deyan Vitanov portfolio, CV and blog</description>
	<lastBuildDate>Fri, 06 Jun 2025 13:11:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Flex 4.6 + Alternativa3D 8 spark problem</title>
		<link>http://bgdevs.com/?p=113</link>
		<comments>http://bgdevs.com/?p=113#comments</comments>
		<pubDate>Wed, 25 Jul 2012 22:36:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://bgdevs.com/?p=113</guid>
		<description><![CDATA[Recently I&#8217;ve been playing around with alternativa3D and I could not figure out why when I set up flex nativeproject using SDK 4.6 and Alternativaplatform 8 &#8211; notthing is displayed on the stage.. After A while I figured out what is going on. It turned out that the flex background is drew above the 3D [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been playing around with alternativa3D and I could not figure out why when I set up flex nativeproject using SDK 4.6 and Alternativaplatform 8 &#8211; notthing is displayed on the stage..</p>
<p>After A while I figured out what is going on. It turned out that the flex background is drew above the 3D stages. My fix is simple &#8211; just setting backgroundAlpha style to be 0 and the 3D appears.</p>
<p>Here you can see my test code:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;s:Application xmlns:fx=&#8221;http://ns.adobe.com/mxml/2009&#8243;<br />
xmlns:s=&#8221;library://ns.adobe.com/flex/spark&#8221;<span style="color: #ff0000;"><strong> backgroundAlpha=&#8221;0&#8243;</strong></span><br />
xmlns:mx=&#8221;library://ns.adobe.com/flex/mx&#8221; xmlns:alternativaplatform=&#8221;http://alternativaplatform.com&#8221;<br />
applicationComplete=&#8221;initApplication(event)&#8221; backgroundColor=&#8221;black&#8221;<br />
minWidth=&#8221;950&#8243; minHeight=&#8221;550&#8243; xmlns:controller=&#8221;bg.lan.chess.controller.*&#8221; xmlns:local=&#8221;*&#8221;&gt;</p>
<p>&lt;fx:Declarations&gt;<br />
&lt;controller:Controller id=&#8221;control&#8221; /&gt;<br />
&lt;/fx:Declarations&gt;</p>
<p>&lt;fx:Style source=&#8221;css/styles.css&#8221; /&gt;</p>
<p>&lt;fx:Script&gt;<br />
&lt;![CDATA[<br />
import alternativa.engine3d.controllers.SimpleObjectController;<br />
import alternativa.engine3d.core.Camera3D;<br />
import alternativa.engine3d.core.Object3D;<br />
import alternativa.engine3d.core.Resource;<br />
import alternativa.engine3d.core.View;<br />
import alternativa.engine3d.materials.FillMaterial;<br />
import alternativa.engine3d.primitives.Box;</p>
<p>import bg.lan.chess.events.InitApplicationEvent;<br />
import bg.lan.chess.init.ResourceLoader;<br />
import bg.lan.chess.view.MainView;</p>
<p>import flash.display3D.Context3D;<br />
import flash.display3D.Context3DRenderMode;</p>
<p>import mx.events.FlexEvent;</p>
<p>public var mainView:MainView;<br />
protected var rootContainer:Object3D = new Object3D();<br />
protected var camera:Camera3D;<br />
protected var box:Box;<br />
private var stage3D:Stage3D;</p>
<p>private function initApplication(e:Event):void {<br />
initEngine();<br />
initScene();</p>
<p>}</p>
<p>protected function initEngine():void<br />
{<br />
camera = new Camera3D(0.1, 50000);<br />
camera.view = new View(800, 500);<br />
alternativa3DSprite.addChild(camera.view);<br />
alternativa3DSprite.addChild(camera.diagram);</p>
<p>camera.z = -1000;</p>
<p>rootContainer.addChild(camera);</p>
<p>alternativa3DSprite.addEventListener(Event.ENTER_FRAME, onEnterFrame);<br />
}</p>
<p>protected function initScene():void<br />
{<br />
stage3D = alternativa3DSprite.stage.stage3Ds[0];<br />
stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContextCreate);<br />
stage3D.requestContext3D();<br />
box = new Box(500, 500, 500, 5, 5, 5);<br />
var material:FillMaterial = new FillMaterial(0xFF7700, 1);<br />
box.setMaterialToAllSurfaces(material);<br />
rootContainer.addChild(box);</p>
<p>}</p>
<p>private function onContextCreate(e:Event):void {<br />
stage3D.removeEventListener(Event.CONTEXT3D_CREATE, onContextCreate);<br />
for each (var resource:Resource in rootContainer.getResources(true)){ // all resources are loaded in context3D<br />
resource.upload(stage3D.context3D);<br />
}<br />
}</p>
<p>protected function onEnterFrame(e:Event):void<br />
{<br />
camera.view.width = stage.stageWidth;<br />
camera.view.height = stage.stageHeight;<br />
camera.render(stage3D);<br />
}</p>
<p>]]&gt;<br />
&lt;/fx:Script&gt;</p>
<p>&lt;s:SpriteVisualElement id=&#8221;alternativa3DSprite&#8221; width=&#8221;100%&#8221; height=&#8221;100%&#8221; /&gt;<br />
&lt;s:Label text=&#8221;Test Label above the 3D. Note that the box is visible. It is because of the backgroundAlpha=&#8217;0&#8242; style&#8221; color=&#8221;white&#8221; horizontalCenter=&#8221;0&#8243; verticalCenter=&#8221;0&#8243; /&gt;<br />
&lt;/s:Application&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://bgdevs.com/?feed=rss2&#038;p=113</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
