Create Snowfall Easily in Flash CS4

Posted by druva | Flash, as3, utils | Thursday 31 December 2009 1:51 pm

This code show how to create snowfall in flash cs4

u can also use the code for cs3

package {

	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import druva.NumberUtil;
	import flash.utils.Timer;
	import flash.events.*;

	public class snowfall extends MovieClip {

		private var t:Timer;

		public function snowfall():void {
			t=new Timer(80);
			t.addEventListener(TimerEvent.TIMER, createParticle);
			t.start();
		}

		private function createParticle(e:TimerEvent) {

			var mc_particle:MovieClip =new MovieClip();
			mc_particle.graphics.beginFill(0xFFFFFF,1);
			mc_particle.graphics.drawCircle(0, 0, NumberUtil.getRand(3,5));
			mc_particle.graphics.endFill();

			mc_particle.x=NumberUtil.getRand(-60,600);
			mc_particle.wind = (NumberUtil.getRand(0,1) == 1) ?  'left' : 'right';
			mc_particle.filters=[new BlurFilter(10,10,2)];
			mc_particle.addEventListener(Event.ENTER_FRAME, moveParticle);
			addChild(mc_particle);

		}

		function moveParticle(e:Event):void {
			var targ:MovieClip=MovieClip(e.target);

			if (targ.y>400) {
				targ.removeEventListener(Event.ENTER_FRAME,moveParticle);
				removeChild(targ);
				return;
			}

			targ.y += 1;

			if (targ.wind=='left') {
				targ.x += 0.4;
			} else if (targ.wind== 'right') {
				targ.x -= 0.4;

			}

		}

	}
}

This movie requires Flash Player 9

 

CS4 caretIndex(point position) in textField using action script

Posted by druva | Flash, as3, utils | Wednesday 30 December 2009 6:26 am

The caretIndex means the index of the point(caret) position.


import fl.controls.TextInput;
import fl.controls.Label;

var textfield:TextField = new TextField();
textfield.x = textfield.y = 100;
textfield.width = textfield.height = 100;
textfield.text = "blog.totusinfo.com";

addChild(textfield);
textfield.addEventListener(MouseEvent.CLICK, caretindex);

function caretindex(event:MouseEvent):void {

	var textfield:TextField = TextField(event.target);

	var myLabel:Label = new Label();
	myLabel.text = "Caret Index";
	myLabel.x = 10;
	myLabel.y = 10;
	addChild(myLabel);

	var textInput:TextInput = new TextInput();
	textInput.x = 75;
	textInput.y = 10;
	textInput.text = String(textfield.caretIndex);
	addChild(textInput);

}
 

CS4 condenseWhite in textField using action script

Posted by druva | Flash, as3, utils | Tuesday 29 December 2009 8:07 am

The condenseWhite means removing extra spaces and html tags like \n,\t.


import fl.controls.*;

var checkBox:CheckBox = new CheckBox();
checkBox.label = "condenseWhite";
checkBox.labelPlacement = ButtonLabelPlacement.RIGHT;
checkBox.addEventListener(Event.CHANGE, checkBox_action);
checkBox.move(20,5);
checkBox.width = 150;
addChild(checkBox);

var tf:TextField = new TextField();
tf.x = 20;
tf.y = 30;
tf.width = tf.height = 250;

function checkBox_action(evt:Event):void {
	tf.condenseWhite = checkBox.selected;
	tf.htmlText = "http://   \n\t  blog.totusinfo.com";

}
addChild(tf);
 

How to pop filters using cs4 action script

Posted by druva | Flash, as3, utils | Wednesday 23 December 2009 8:01 am

CS4 condenseWhite in textField using action script

This code shows how to apply filters and how to pop filter using action script.


addChild(glowFilter);			   

var glow:GlowFilter = new GlowFilter(0x5C947C, 1, 20, 20);
var dropShadow:DropShadowFilter = new DropShadowFilter();

glowFilter.filters = [glow,dropShadow];

filters = glowFilter.filters;
filters.pop();
glowFilter.filters = filters;
 

Determine Easily What Image Formats the Target Device Supports

Posted by druva | Flash, as2, as3, utils | Tuesday 22 December 2009 1:12 am

You can check before loading the image with System.capabilities

if (System.capabilities.imageMIMETypes["image/png"]) {
 loadMovie("images/image.png", "mc_myPngImage");
}
 

Flash as3 TextField alpha Tweening

Posted by druva | Flash, as2, as3, utils | Monday 21 December 2009 10:15 am
var tf:TextField = new TextField();
tf.text = "Hello Hello";
tf.width = 650;

var format1:TextFormat = new TextFormat();
format1.color = 0xFF0000;
format1.size = 80;

tf.setTextFormat(format1);

addChild(tf);
tf.alpha = .1;

import flash.display.BlendMode;
tf.blendMode = BlendMode.LAYER;

import fl.transitions.Tween;
import fl.transitions.easing.*;
new Tween(tf, "alpha", Elastic.easeOut, 0, 1, 200, false);
 

CS4 glowfilter and dropshadow filter using action script

Posted by druva | Flash, as3, utils | Sunday 20 December 2009 7:37 am

addChild(glowFilter);			   

var glow:GlowFilter = new GlowFilter(0x5C947C, 1, 20, 20);
var dropShadow:DropShadowFilter = new DropShadowFilter(10,45);

glowFilter.filters = [glow,dropShadow];

This movie requires Flash Player 9

 

CS4 glow filter using action script

Posted by druva | Flash, as3, utils | Saturday 19 December 2009 7:45 am

addChild(glowFilter);			   

var glow:GlowFilter = new GlowFilter(0x5C947C, 1, 20, 20);

glowFilter.filters = [glow];

This movie requires Flash Player 9

 

CS4 dropshadow filter using action script

Posted by druva | Flash, as3, utils | Friday 18 December 2009 7:52 am

addChild(glowFilter);			   

var dropShadow:DropShadowFilter = new DropShadowFilter(10, 270, 0x5C947C, 1, 6, 6, 1, 1, false, false);

glowFilter.filters = [dropShadow];

This movie requires Flash Player 9

 

Flex doubleClickEvent

Posted by Vineela | Uncategorized | Thursday 17 December 2009 11:40 am
<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Image_doubleClick_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
        	import mx.controls.Alert;

            private function img_doubleClick(evt:MouseEvent):void {
               Alert.show('double click event');
            }
            private function img_singleClick(evt:MouseEvent):void {
               Alert.show('single click event');
            }
        ]]>
    </mx:Script>

    <mx:Image id="img1"
            source="colorpicker.JPG"
            doubleClickEnabled="true"
            doubleClick="img_doubleClick(event);" />

    <mx:Image id="img2"
            source="colorpickerwheel.JPG"
            click="img_singleClick(event)" />

</mx:Application>

This movie requires Flash Player 9

 
Next Page »