blog.x-e.ro / code: page 5 of 39
here a nice little one liner. this function returns a random number between a user supplied range.
function randomizer (low:Number, high:Number):Number {
return Math.floor(low + (Math.random() * (high-low)));
}
example useage, will return a number between 5 - 50.
var x:Number = randomizer(5, 50);
today john grden of rockonflash.com has release his new papervision3D component.
this plugin for the flash cs3 ide allows you to...
- render and edit your 3d objects in Flash IDE at design time!
- it supports multiple material types
- you can create scenes and cameras
- management of resizing / centering of a papervision3D scene
- dynamic masking to constrain the viewable area to set bounds
- full api and access to scene, camera, and objects to code around
- automatically loads materials via collada file
- modification of rotation, camera zoom, camera focus, cameraZ
demos :: papervision3D torus knot demo
so i had the chance this weekend to create a few 3D models and export their geometry into papervision3D primitives. so i decided to create a demo, using both my as3 torusKnot primitives and the new flex accordion component. about the time i finished my demo i decided to re-sync my pv3d folder with the svn. at that exact same moment their was a slip-up. somehow one of the new dev materials got leaked into the public svn. the new material features dynamic lighting! so i decided to hack it into my new demo. so enjoy my custom primitive shadedColorMaterial demo created in flex3.
so i finally got a copy of adobe cs3 and flex builder2. flex is amazing, combining mxml and actionscript 3 together into a seamless package. now that im on the as3 tip, i decided to dive into papervision3D. pv3d is a set of actionscript classes that are used to create 3D objects within the flash environment. it's currently in beta and the source code is only available to osflash emailing list members. so if you want it signup here. thanx to carlos for creating pv3d, and to his girlfriend for convincing him to release the project open source!
as3 :: using the wiimote with as3
as i have been checking out the new features of actionscript 3 and flex, i stumbled upon fwiidom.org. this site is run by joa ebert + thibault imbert, and their mission is full flash wiimote integration.
currently wiiflash supports multiple wiimotes and nunchuks, the classic controller, as well as pc sensor bars. all you need is a bluetooth enabled pc (or adaptor) and a wiimote.
the newest version is available from wiiflash or googlecode or you could get on the mailing list
php :: using regular expressions
<?php
$email = 'someone@somewhere.com';
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
//invalid email
} else {
//valid email
}
?>
here's a simple SQL script that returns the last row created. this is great for when you add a new record that has an autogenerated id and you need that number.
mssql
CREATE PROCEDURE [dbo].[getLastLogin]
AS
SELECT TOP 1 *
FROM dbo.login
ORDER BY id DESC
GO
mysql
SELECT * FROM `login`
ORDER BY `id` DESC
LIMIT 1,1;