rotationX in Flash player 10

Posted by druva | Flash, as3, utils | Wednesday 31 December 2008 3:27 am

This examples shows how to use rotationX available in Flash player 10


import fl.controls.Slider;
import fl.controls.SliderDirection;
import fl.events.SliderEvent;

var slide:Slider = new Slider();
slide.direction = SliderDirection.HORIZONTAL;
slide.minimum = 0;
slide.maximum = 360;
slide.value = 45;
slide.tickInterval = 45;
slide.snapInterval = 1;
slide.liveDragging = true;
slide.addEventListener(SliderEvent.CHANGE,

slide_change);
slide.move(10, 10);
addChild(slide);

var sp:Sprite = new Sprite();
sp.graphics.lineStyle(2, 0xFF0000);
sp.graphics.drawRect(0, 0, 100, 80);
sp.x = Math.round((stage.stageWidth - sp.width)/2);
sp.y = Math.round((stage.stageHeight -

sp.height)/2);
sp.rotationX = 45;
addChild(sp);

function slide_change(evt:SliderEvent):void {
 spr.rotationX = evt.value;
}
 

cs4 sort an array using action script

Posted by druva | Flash, as3, utils | Tuesday 30 December 2008 10:51 am

var array:Array = new Array(  );
array.push({id: 2, alphabet: "d"});
array.push({id: 4, alphabet: "a"});
array.push({id: 3, alphabet: "c"});
array.push({id: 1, alphabet: "b"});

array.sortOn("id");

for (var i:int = 0; i < array.length; i++) {
  trace(array[i].alphabet + "\t" + array[i].id);
}
 

custom text format on a TextArea using flash actionscript

Posted by Vineela | Flash, as3, utils | Monday 29 December 2008 9:38 am

import fl.controls.TextArea;

var tF:TextFormat = new TextFormat();
tF.color = 0x0000FF;
tF.italic = true;
tF.bold = true;
tF.font = "Monotype Corsiva";
tF.size = 15;

var tI:TextArea = new TextArea();
tI.setStyle("textFormat", tF);
addChild(tI);
 

restricting which characters a TextInput can accept using flash actionscript

Posted by Vineela | Flash, as3, utils | Sunday 28 December 2008 9:33 am

import fl.controls.TextInput;

function textValid(  ) {
  var field:TextInput = new TextInput(  );
  field.restrict = 'a-z';
  addChild(field);
}

textValid();
 

stopAllSounds() in as3

Posted by druva | Flash, Flex, as2, as3, utils | Saturday 27 December 2008 3:50 am

stopAllSounds() is used in as3

in as3 you have to import the class

import flash.media.SoundMixer;

and call when required

SoundMixer.stopAll();
 

to restrict the number of characters in TextInput using flash actionscript

Posted by Vineela | Flash, as3, utils | Friday 26 December 2008 5:20 am
import fl.controls.TextInput;

var tI:TextInput = new TextInput();
tI.maxChars = 10;
tI.width = 200;
tI.move(10, 10);
addChild(tI);
 

How to know Frame Rate of the stage using cs4 action script

Posted by druva | Flash, as3, utils | Thursday 25 December 2008 4:32 am

The below code show how to know the frame rate of the stageusing action script.


var t:TextField = new TextField();
t.text = stage.frameRate.toString();
addChild(t);
 

How to remove html tags from given text using PHP

Posted by druva | HTML, php, utils | Wednesday 24 December 2008 7:42 am

function stripHtmlTags($text){

	$strippedtext = preg_replace(
					array(
						'@<head[^>]*?>.*?</head>@siu','@<style[^>]*?>.*?</style>@siu','@<script[^>]*?.*?</script>@siu','@<object[^>]*?.*?</object>@siu',
						'@<embed[^>]*?.*?</embed>@siu','@<applet[^>]*?.*?</applet>@siu','@<noframes[^>]*?.*?</noframes>@siu',
						'@<noscript[^>]*?.*?</noscript>@siu','@<noembed[^>]*?.*?</noembed>@siu',

						'@<((br)|(hr))@iu','@</?((address)|(blockquote)|(center)|(del))@iu','@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
						'@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu','@</?((table)|(th)|(td)|(caption))@iu',
						'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu','@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
						'@</?((frameset)|(frame)|(iframe))@iu',
					),
					array(
						' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0","\n\$0", "\n\$0",
					),
					$text );

	return strip_tags($strippedtext);
}

echo stripHtmlTags("<div><strong>blog.totusinfo.com</strong></div>");
 

email validation using regular expression with PHP

Posted by druva | CSS, php, utils | Tuesday 23 December 2008 7:05 am

<?php
if(!empty($_POST['email'])){
	$regularexp = "^[A-Za-z0-9\.|-|_]*[@]{1}[A-Za-z0-9\.|-|_]*[.]{1}[a-z]{2,5}$";
	$email = $_POST['email'];
	$validemail = ereg($regularexp, $email);
	if ($validemail)
	{
		echo "<div style='color:green;'> <b>'$email'</b> is a valid email</div>";
	}
	else
		echo "<div style='color:red;'> <b>'$email'</b> is not a valid email</div>";
}else{
	echo "<div style='color:red; font-weight:bold;'> Please enter email</div>";
}
?>
<html>
	<body>
	<h2>Email Validator</h2>
	<form method="post">
		<div style="width:50px; font-family:Verdana, Arial, Helvetica, sans-serif; float:left; padding-top:3px;">
			Email:
		</div>

		<div style="width:300px">
			<input type="text" name="email" />
		</div>

		<input type="submit" />
	</form>
	</body>
</html>
 

sliderEvent properties using flash action script

Posted by Vineela | Flash, as3, utils | Monday 22 December 2008 5:42 am
import fl.events.SliderEvent;
import fl.controls.Slider;

var slider:Slider = new Slider();

function sliderProperties():void {
	slider.addEventListener(SliderEvent.CHANGE, sliderChanged);
	slider.addEventListener(SliderEvent.THUMB_DRAG, sliderDrag);
	slider.addEventListener(SliderEvent.THUMB_PRESS, sliderPress);
	slider.addEventListener(SliderEvent.THUMB_RELEASE, sliderRelease);

	slider.move(sliderLabel.x, sliderLabel.y + (1.5*sliderLabel.height));
	addChild(slider);
}

function sliderDrag(e:SliderEvent):void {
	sliderLabel.text = "Slider dragging: " + e.target.value;
}

function sliderPress(e:SliderEvent):void {
	sliderLabel.text = "Slider pressed";
}

function sliderRelease(e:SliderEvent):void {
	sliderLabel.text = "Slider released";
}

function sliderChanged(e:SliderEvent):void {
	sliderLabel.text = "Slider changed: " + e.target.value;
}
sliderProperties();
 
Next Page »