So the other day I spent 2hrs looking for how to and trying to do an alpha mask (I’ve done on once). So like an idiot I was trying to do it the Photoshop way with level of gray.
My method of thinking
- Black = 100 and White = 0
- but it doesn’t matter what color only the opacity.
If you have never mad a alpha mask in Flash before or CS3 it’s easy.
- open a fla
- draw a shape
- Make that shape a MovieClip
- name it maskee_mc
- draw a second shape
- use a linear gradient
- choose color
- set one linear color alpha at say, 40
- Make that second shape another MovieCilp
- name it mask_mc
[as]
this.mask_mc.cacheAsBitmap = true;
this.maskee_mc.cacheAsBitmap = true;
// as2 was maskee_mc.mask(mask_mc);
maskee_mc.mask = mask_mc;
[/as]
That’s it!
October 21st, 2007
I have been trying to understand Papervision 3d for the last couple of months, but all the examples are using collada or some elaborate functionality. I just wanted to test something simple. So I made a rotating box it rotates on the y axis.
Here how it goes in Flash CS3:
- add an image into the library
- set the linkage name to test.
- make sure width = 336 / height = 335 (for this example)
- and add this script
[as]
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
var container:Sprite = new Sprite();
container.x = stage.stageWidth * 0.5;
container.y = stage.stageHeight * 0.5;
addChild(container);
var scene:Scene3D = new Scene3D(container);
var camera:Camera3D = new Camera3D(p, 10);
var bam:BitmapAssetMaterial = new BitmapAssetMaterial(”test”)
bam.oneSide = false;
bam.smooth = true;
var p:Cube = new Cube(bam, 336, 335, 335, 5, 5, 5);
scene.addChild(p);
scene.renderCamera(camera);
addEventListener(Event.ENTER_FRAME, onFrame);
function onFrame(event:Event):void
{
p.rotationX % 360 == 0 ? p.rotationX = 1 : p.rotationX += 1;
trace(p.rotationX)
//p.rotationY = stage.mouseY – (stage.stageHeight * 0.5);
scene.renderCamera(camera);
}
[/as]
thats it
October 20th, 2007
I have noticed some times I’m an idiot spending an hour on something that would have take five minutes if I’d have paid attention. Well I’m going to start sharing some things I’ve learned from these times.
- in Flash/Flex when using the TextEvent.LINK make sure your textfield is set to selected = true.
the link is clickable even when selected = false, just nothing will happen. Very fishy that should be changed. It is very misleading.
October 18th, 2007
So at work we are experimenting with WebOrb to ditch XML. No for good but definatly when there will be a lot of parsing. Anyway, our PHP Programmer downloaded WebOrb and we looked at the examples but the example were either banking on you having previous Flex Data Services experience or they were not that good in my opinion. The most crucial info was not even on the tutorial application page. So I’m going to walk you through the tutorial with the modification I used to get it working from various Google Searches. Mainly no service-cofig.xml.
- Ok, first thing is go to WebOrb’s website http://www.themidnightcoders.com/weborb/php/index.htm
I’m using the PHP version, and make sure you have PHP5.
- Upload it to your server on put it in you localhost folder. We have it in a folder called “WebOrb” (http://YOUR_SITE/WebOrb)
- Create a new project in Flex.
- Go to the WebOrb tutorial. http://www.themidnightcoders.com/weborb/php/gettingstarted.htm skip down to the heading CONFIGURATION – FLEX BUILDER follow those directions. The remote config on our set up is http://YOUR_SITE/WebOrb/Weborb/WEB-INF/flex/remote-config.xml The last direction on the site is the server code (PHP) that goes in the Services folder located in http://YOUR_SITE/WebOrb/Services/InfoServices (with our current set-up)
- Now let’s go to another page and get the info on how this is connection to the service because that tutorial told me nothing about service-cofig.xml. Invoking PHP objects w/ Remote Object.
- don’t worry about this skip it (if you do worry go to the remote-config.xml to check it out http://YOUR_SITE/WebOrb/Weborb/flex):< <destination id=”destination-name”>
<properties>
<source>Your.PHP.ClassName</source>
</properties>
</destination>we will be using a GenericDestination which is already in the remote-config.xml:<destination id=”GenericDestination”>
<properties>
<source>*</source>
</properties>
</destination>
the source tag will be filled in the Flex code.
- now we will fill out the mxml RemoteObject:
< mx:RemoteObject id="InfoServiceObj" destination="GenericDestination"
endpoint="http://YOUR_SITE/WebOrb/Weborb/index.php" fault="onFault(event)" showbusycursor="true" fault="onFault(event)">
< mx:method name="getComputerInfo" result="onResult(event)">
mx:RemoteObject>
endpoint="http://YOUR_SITE/WebOrb/Weborb/index.php" and destination="GenericDestination" are what make this RemoteObject flexible. All you have to do is change you destination and your ready to go for another service. Endpoint is like you gateway in AMFPHP (to all the classes of weborb)
- Lastly here are the handlers for the modified example.mxml, dump this in over the old scripts
import mx.rpc.remoting.*;
import mx.controls.*;
import mx.rpc.events.*
public function onCreationComplete():void
{
InfoServiceObj.getComputerInfo.addEventListener("result", onResult);
}
public static function onFault(event:FaultEvent):void
{
Alert.show(event.fault.faultString, 'Error');
}
private function onResult(event:ResultEvent):void
{
var computerInfo:Object = event.result;
currentUserText.text = computerInfo.currentUser;
processIdText.text = computerInfo.phpProcessId;
osText.text = computerInfo.operatingSystem;
phpVersionText.text = computerInfo.phpVersion;
invokeButton.enabled = true;
}
private function getInfo():void
{
invokeButton.enabled = false;
currentUserText.text = "";
processIdText.text = "";
osText.text = "";
phpVersionText.text = "";
InfoServiceObj.getComputerInfo();
}
and put a click handler on the button click="getInfo()"
here is the code I hope it helps:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import mx.rpc.remoting.*;
import mx.controls.*;
import mx.rpc.events.*
public function onCreationComplete():void
{
InfoServiceObj.getComputerInfo.addEventListener("result", onResult);
}
public static function onFault(event:FaultEvent):void
{
Alert.show(event.fault.faultString, 'Error');
}
private function onResult(event:ResultEvent):void
{
var computerInfo:Object = event.result;
currentUserText.text = computerInfo.currentUser;
processIdText.text = computerInfo.phpProcessId;
osText.text = computerInfo.operatingSystem;
phpVersionText.text = computerInfo.phpVersion;
invokeButton.enabled = true;
}
private function getInfo():void
{
invokeButton.enabled = false;
currentUserText.text = "";
processIdText.text = "";
osText.text = "";
phpVersionText.text = "";
InfoServiceObj.getComputerInfo();
}
]]>
</mx:Script>
<mx:RemoteObject destination="GenericDestination" source="InfoService" id="InfoServiceObj" endpoint="http://YOUR_SITE/WebOrb/Weborb/index.php" fault="onFault(event)" showBusyCursor="true">
<mx:method name="getComputerInfo" result="onResult(event)" />
</mx:RemoteObject>
<mx:Panel x="10" y="10" width="329" height="189" layout="absolute" title="Info Service Example">
<mx:Label x="10" y="10" text="Current user:"/>
<mx:Label x="10" y="36" text="PHP Process ID:"/>
<mx:Label x="10" y="62" text="OS/Architecture:"/>
<mx:Label x="10" y="88" text="PHP Version:"/>
<mx:TextInput x="113" y="8" width="186" editable="false" id="currentUserText"/>
<mx:TextInput x="113" y="34" width="186" editable="false" id="processIdText"/>
<mx:TextInput x="113" y="60" width="186" editable="false" id="osText"/>
<mx:TextInput x="113" y="86" width="186" editable="false" id="phpVersionText"/>
<mx:Button id="invokeButton" x="166" y="116" label="Get Computer Info" click="getInfo()" />
</mx:Panel>
</mx:Application>
October 1st, 2007