Just so you know because this tripped me up.
When you are trying to get crypto to work by doing something as simple as erlang:sha_mac(Key, String) and erlang:md5(String) and getting nothing but a port_control/3 error. Don’t freak out, it’s just an error communicating with the call to the c library that is crypto. So before you freak out (like I did), recompile erlang 2 or 3 times trying different versions and configurations (hipe, smp etc like I did), go through the source (like I did), and waste hours(like I did), stop drop and remember erlang loves long running processes and just do.
|
application:start(crypto) |
Then palm to face (like I did).
This one can be pretty nifty. In my certain case I had a bunch of on screen items that I continually updating their alpha property but when there was a mouse over I didn’t want to update that property anymore and peg it right at 1 so it stood out. In this case it was a text field so here is a class with the not important parts taken out.
|
package{
import flash.text.TextField;
import flash.events.MouseEvent;
public class Tag extends TextField{
private var alpha_locked:Boolean;
public function Tag():void{
this.alpha_locked = false;
this.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
this.addEventListener(MouseEvent.MOUSE_OUT, mouse_out);
}
private function mouse_over(e:MouseEvent):void{
this.alpha = 1;
this.alpha_locked = true;
}
private function mouse_out(e:MouseEvent):void{
this.alpha_locked = false;
}
override public function set alpha(a:Number):void{
if(!alpha_locked) super.alpha = a;
}
}
} |
The magic happens with the super.alpha, super which refers to the parent class that Tag inherits from. It checks the alpha_locked variable and if things are ok it sets it, otherwise it’s ignored. Then the alpha locked variable is controlled by the MouseOver and MouseOut events.
I’ve run into this problem a few times I want to rotate and object by an arbitrary point. First off actionscript doesn’t let you change you point from which you rotate when you change the rotation attribute of an object. By default when you rotate using the rotation attribute flash rotates the objects at it’s index point (0, 0). Simple solution move the object so it’s center point is at the index point of it’s container move clip then rotate it, then move it back it’s original position. To make things easier you can of course wrap this up in a function inside of an object or use this snippet.
|
function rotate(item:DisplayObject, angle:Number, point:Point) {
var matrix:Matrix = item.transform.matrix.clone();
matrix.translate(-point.x, -point.y);
matrix.rotate (angle*(Math.PI/180));
matrix.translate(point.x, point.y);
item.transform.matrix = matrix;
} |
Simple enough to use just pass the function the moveclip you want to rotate the angle just like you would with the rotation attribute and the point from the index point that you want to rotate your clip.
rotate(thing, 90, new Point(50, 50));
wow time flies I totally forgot I even put this up. Since my last post I’ve since made a flash game and it’s currently on a commercial site, not really there yet so I’m not going to mention it.
Otherwise I started on yet another tower defense game with has been a learning experience. I’d say I’ll post it soon but I’d been lying so I’ll just post it next time I think about it.
How are you? I’m ok things haven’t been going that well I’m burried under student loan debt, oh it’s my fault I know but I dpay you off lobby you in their best interest. So just for your reference here some things going on in the world and in the Untied State besides some copyright infringement. You can start with these things feel free to add more though.
Voting machines that don’t work, Global warming, alternative energy, dwindling oil supply, quality of education, highest proportion of citizens incarcerated in the world( 7 million), War in Iraq, coming war in iran, failing education system, obesity, health care cost, lack of funding for education, lobbyist, economy, inflation, rising food cost, federal reserve, human rights violations, Massive stealing accidental over billing of money by companies such as KBR and Haliburton(not to mention no bid contracts, and a certain man in a high position of power that was formerly employed by them)
Like I said feel free to add more I probably will.
Not much to say other than I’ve played with it and it’s the coolest thing ever. I’m thinking a crazy ec2 setup using these is in order. More later.
I took a trip a few years back with my sister. She was living in Hong Kong at the time and I was at her place and she mentioned that she could take some time off and if I could go some place, where would I want to go? Some of the choices that were thrown out there where like Main Land China or New Zeland. Then it hit me…. Tibet.
So a few days later off we went to Tibet. It was a fun trip on the way there we had two layovers so I got to see some parts of Main Land China.
Tibet was beautiful the air smelled fresh all the time, you could get a coke and some M&Ms but there was not a McDonald’s in sight. Where else can you get an 80 degree temperature swing from day to night. It was beautiful but at 10,000+ feet above sea level breathing becomes a problem. Simple task such as walking up two stairs, not two flights but two stairs while carrying some luggage, was a like running a marathon, at the least it was the first night we got there. Eventually things got slightly easier. I did resist the urge to rent an oxygen tank, because they were available, but I didn’t want to hang on to that crutch the whole time I was there, plus what kind of jack ass would I look like walking around with that thing in tow.
The food was wonderful pretty much all meat there was yak. I really enjoyed yak and I figured, outside of coming back to Tibet I probably wouldn’t get that many chances to try yak, so I lived it up. Too bad I’m allergic to yak. Stomach pains constant feeling I’m going to vomit, and all my muscle were sore. For most normal people they might catch on after eating something that does this to them maybe after 2 or 3 times. Not me took me 5 miserable days of just toughing it out.
We saw a bunch of palaces met a bunch of cool people, had lots of rice tea. It was over all a wonderful experience, despite the constant feeling I’m suffocating and the yak meat making me want to vomit, I would do it all over again in a heart beat.
Heres some random pictures from around Lhasa, not that many I’ll post more, but I at least want to say something about each picture rather than just a mass post of all that I have.

Ahhh a sandbox violation if you are stating to pull content from other sites or even pull external content period to your SWF get used to them. They really do suck and at first it is overwhelming when you get them all the time, take it from me though after some time getting your hands dirty with Actionscript these things become a thing of the past.
First up, why do I get these errors?
Easy it’s to protect everyone on out there in the tubes.
These cross domain scripting errors happen because code from one domain is not allowed to modify content from another domain. This is so that say you are browsing your bank’s site doing your normal bank things but at the same time you are also browsing Matt Evilphen’s site. He has some code on there that detects that you are your banking site and transfer all your money to his account, oh no, you’re broke. Well fortunately you cannot do this, oh course there are million other ways to have you bank account drained, this is not one of them.
It’s very strict too. www.charlescfenwick and blog.charlescfenwick.com are not the same and neither is www.charlescfenwick.com:8080
So how does one get around this?
well first off you need a crossdomain.xml file on the server which the remote is being accessed from.
|
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy> |
This is an example of course you’ll probably want to change the * to what ever domain the swf is coming from.
then as usual load your content, but take special note of the LoaderContext class
|
// don't forget these
import flash.system.LoaderContext;
import flash.net.URLLoader;
import flash.net.URLRequest;
// create your request to the resource
var request:URLRequest=new URLRequest("http://www.somesite.com/someresource");
// create the loader to do the actual load
var loader:URLLoader=new URLLoader();
// this is the loader context
var context:LoaderContext = new LoaderContext();
// set the check policy flag in the loader context
context.checkPolicyFlag=true;
// add the handler for when the event completes
loader.addEventListener(Event.COMPLETE, completeHandler);
// retrieve the resource
loader.load(request, context); |
Why a Photo Mosaic?
Seems like there have been more and more photo mosaics popping up on digg lately. I figured I could make one, but one up the other people and actually write the program to make them instead of using some program I found online.
(more…)
Oh it’s my birthday, I almost forgot…
