Blog Archives

Flash Tutorials

I have list out 2 websites links for flash tutorials collection and flash component collection. Here we can download the source files for flash and documents for components.
Its very useful for Flash component ….

http://www.sephiroth.it/

http://forum.sephiroth.it//index.php

Vinothkumar.P

Embedding the Specify font in Flash

1.Go to the Library and right click or choose the New Font,pop will appear on clicking the new font in this popup we can choose which font to embedding into flash give the size of the font,click the linkage Export for AS,Export in frame1 and finaly give the Identifier name for choosing font.For example give the Identifier name as myfont

2. Goto the actionscript panel paste the following codes.,
style = new Textformat();
style.font =”myfont”;

// create the dynamic text field and give the instance name for the text field,

For example we give the textfield instance name as txt

txt.setTextFormat(style);
txt.embedFonts=true;

3. Finally we go Timeline choose the dynamic textfield,go to the properties panel & click the Character Embedding,one pop will come in there we choose the UpperCase[A..Z] & LowerCase[a..z] click ok

4.Test the movie in various system,font will be embed into flash.

Video Creating Using NetStream

Three Classes to control video with actionscripts.

  1. Net Connection
  2. Netstream
  3. Video

Type of cuepoints

1.Navigation
2.Event
3. Frame accurate
var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
ns.client= this;
ns.play(“1254014.flv”);

function onMetaData(info:Object):void
{
trace(“Receving…”);
}

var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
vid.x=10;
vid.y=10;

play_btn.addEventListener(MouseEvent.CLICK,playHandler);
stop_btn.addEventListener(MouseEvent.CLICK,stopHandler);
pause_btn.addEventListener(MouseEvent.CLICK,pauseHandler);

function playHandler(e:MouseEvent):void
{
ns.resume();
}

function stopHandler(e:MouseEvent):void
{
ns.pause();
ns.seek(0);
}

function pauseHandler(e:MouseEvent):void
{
ns.pause();
}

VidepPlayer Creating Using Flash AS3

1.Create new fla file in flash using as3.0
2.Create the following buttons and give the instance name as per list

Play btn->play_btn
Stop button ->stop_btn
Pause button ->pause_btn

3.Create the volume bar for the custom video player (in inner movieclop the the volume slider bar instance name as slider) & over all volume bar to give the instance name as  vbar_mc

4. Using the import the FLVPlayback,we can import the player in runtime & load the movie using the following codes.

5.In slider bar we use the startDrag,stopDrag option for get the volume value.using the Rectangel values (first value is x, y valuse,width,height) in Darg option to set the volume values.

=================

import fl.video.FLVPlayback;

var flvplay = new FLVPlayback();
flvplay.source = “1254014.flv”;
addChild(flvplay);

flvplay.x =60;
flvplay.y= 0;
flvplay.width = 330;
flvplay.height = 330;

flvplay.volume =0;
//flvseekbar = SeekBar;
flvplay.seekBar =flvseekbar;
flvplay.bufferingBar = flbbuff;

play_btn.addEventListener(MouseEvent.CLICK,playhandler);
pause_btn.addEventListener(MouseEvent.CLICK,pausehandler);
stop_btn.addEventListener(MouseEvent.CLICK,stophandler);

function playhandler(e:MouseEvent):void
{
flvplay.play();
}

function pausehandler(e:MouseEvent):void
{
flvplay.pause();
}

function stophandler(e:MouseEvent):void
{
flvplay.stop();
flvplay.seek(0);
}

this.vbar_mc.slider.addEventListener(MouseEvent.MOUSE_DOWN,vdown);

function vdown(e:MouseEvent):void
{
vbar_mc.slider.startDrag(false,new Rectangle(0,12,50,0));

addEventListener(Event.ENTER_FRAME,vohandler);
stage.addEventListener(MouseEvent.MOUSE_UP,vrelease);

}
function vrelease(e:MouseEvent):void
{
this.vbar_mc.slider.stopDrag();
removeEventListener(Event.ENTER_FRAME,vohandler);

}

function vohandler(e:Event):void
{
flvplay.volume = vbar_mc.slider.x*2/100;
}

Flash Image Gallery with XML

1.Create one XML file for loading the images & title in the xml

Eg

<gallery>

<image ptext=”Title1.1” main=”test.jpg” />

<image ptext=”Title1.2” main=”test1.jpg” />

<image ptext=”Title1.3” main=”test2.jpg” />

end </gallery>



save the name in xmlphoto.xml

2.Create the new flash file save the file as photogallery.
3.In flash file create the movie clip & give the instancename as loader_mc
4.Create the dynamic text field and give the instance name caption
5.create the new layer & named it actions paste the code

//create the xml object

myphoto – new XML();
myphoto.ignoreWhitespace = true;
myphoto.load(“xmlphoto.xml”);

//create array for photos,text to store separately
toa = new Array();
photo = new Array();
Ptext = new Array();
var nx:Number;

myphoto.onLoad = function(success)
{
toa = myphoto.firstChild.childNodes;
// trace(toa);
loader_mc._alpha=0
trace(loader_mc._alpha);
for(i=0;i
{
photo.push(toa[i].attributes.main);
//trace(photo);
ptext.push(toa[i].attributes.ptexts);
//trace(ptext);
}
fadeef();
loader_mc.loadMovie(photo[0]);
caption.text =ptext[0];
nx=0;
//nextImage();
//trace(“Loaded Success….”);
}

function fadeef()
{

this.onEnterFrame=function(){
if(loader_mc._alpha<=100){
//increase the opacity on each frame
loader_mc._alpha+=6;
trace(loader_mc._alpha);
}else{
//once the opacity reaches 100, delete the on enter frame function
delete loader_mc.onEnterFrame;
//loader_mc._alpha+=4;

}
}
}
//setProperty(loader_mc,_alpha,0);
next_btn.onPress= function()
{
loader_mc._alpha=0
//trace(“nextImage loaded”);
if(nx
0)
{
nx–;
fadeef()
loader_mc.loadMovie(photo[nx]);
caption.text =ptext[nx];
next_btn._visible=true;
}
else
{
prev_btn._visible= false;
}
}

Volume Slider bar in Flash

1.Create new fla file save it as volumeslider.fla

2,create 4 new layer in that file name as it actions buttion slider bar

3.select the bar & create one bar in the layer & convert into movieclip give the instance name as bar_mc

4.select the slider layer & create the slider ,convert into the movieclip give the instance name as slider_mc

5.In button layer create the play,stop buttons,give the instance name for the buttons as play_btn,stop_btn

6.Import the song into library give the identifier name as “test” & select the linkage checkbox in the properties.

7.Finaly select the action layer & paste this code for the volume

slider slider_mc.onPress = function() { this.startDrag(true,_root.bar_mc._x,_root.bar_mc._y,_root.bar_mc._x+335,_root.bar_mc._y); } in this 335 indicate as the width of thebar .

slider_mc.onRelease = slider_mc.onReleaseOutside= function() {

this.stopDrag();

}

play_btn.onRelease = function() {

mySound = new Sound();

mySound.attachSound(“test”);

mySound.start(0,50);

}

stop_btn.onRelease = function() { stopAllSounds(); }

slider_mc.onMouseMove =function() {

np = new Object();

np.x= this._x;

np.y= this._y;

_root.bar_mc.globalToLocal(np);

_root.mySound.setVolume(-1*np.x);

}

Dynamic Text Effects in Flash

Loading the text using text file.

1.First we create a text file with one variable.
for example
myVariable=<p class=’header’>Welcome to brianwiltshire.net</p><p>In this example i will illustrate how to load an external text file into flash and then style it with an external stylesheet. Yes that’s right CSS,  dynamic text and Flash</p>
<p class=’footer’><a href=’http://www.brianwiltshire.net’>Click here for more info.</a></p>

2.After that we create the css file for the class which we apply in the text file

p{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color:#999999;
}

.header{
font-size: 18px;
font-weight:bold;
color:#FF9933;
}

.footer{
font-family:Geneva, Arial, Helvetica, sans-serif;
text-align:right;
}

a{
color:#FF0000;
text-decoration:underline;
font-weight:bold;
font-size: 10px;
}

3.Create the dynamic text field in flash.give the instance name as myText_txt
4.Convert this text field into movieclip & give the instance name as text_mc.
5.Double click the movieclip,create the new layer named as actions:
paste this code for loading the css file into flash,one function called for loading the data from that text file
(name.txt) file.

var myStyle = new TextField.StyleSheet();
myStyle.load(“myStyle.css”);
myStyle.onLoad = function() {
myText_txt.styleSheet = myStyle;
};

textLoader();

function textLoader() {
myData = new LoadVars();
myData.onLoad = function() {
myText_txt.html = true;
myText_txt.htmlText = this.myVariable;
};
myData.load(“name.txt”);
}

6.Go to the mail clip & create the new layer and names it actions,paste the following code into that layer
this code for transaction effect with scripts,
First 2 lines are include the tween,easing transition effects from library.

import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(text_mc, “_x”, Elastic.easeOut, Stage.width, 200, 3, true);

7. try this effect also for example only in same main actions layers to paste this code

var ball_tween:Tween = new Tween(text_mc, “_x”, Regular.easeIn, 0, 250, 3, true);
ball_tween.onMotionFinished = function() {
ball_tween.continueTo(200, 3);
};

8. Test the movie

Form submitting using flash

Form submitting using flash
1. First we create a three text fields like (Name,Email,Address),for address we choose the text area for multiple lines. Give the instance name for the text,text area fields (name1,email,address1)

2. Create new key frame on 10 lable it success & create 20 th key frame label it Error

3. On that keyframes give the success messagein 10th key frame & error message on 20th key frame

4. After that we add the button for submitting the form.(Create the button for submit & give the instance name as send_btn)

5. Create new layer name it Action script , in this layer create the loadvariable for sending the values to server(php,.Net.), retrieve the data in server
var sendLoad:LoadVars = new LoadVars(); // send the values to php
var recLoad:LoadVars = new LoadVars(); // retrieve the values

send_btn.onRelease = function() {
formSend();
}
function formSend() {
sendLoad.name1 = name1.text;
sendLoad.email = email.text;
sendLoad.message1 = message1.text;
sendLoad.sendAndLoad(“mail.php”,recLoad); }

Finally we create the php file to send mail For exp : In this sentOk is to send the message (mail send success or any error) And add this code in flash
recLoad.onLoad = function() {
if(this.sentOk) {
_root.gotoAndStop(“success”);
}
else {
_root.gotoAndStop(“erorr”); }
}
For checking success message or error message

Pop Up window within flash

1. Create button in flash.
2. paste the code for that button
on(release)
{
getURL(javascript:openNewWindow(‘somePage.html’,’thewin’,
‘height=100,width=250,toolbar=no,scrollbars=yes’);)
}
3. In Html page.,paste this code in HEAD section

<script>
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}
</script>

4. Embeded your swf file in html page

Flash- FLVPlayer

1. Include the FLVplayer component & give the instance name my_FLVPlybk

2. Create new layer name as action & paste the code.

my_FLVPlybk.volume = 10;

my_FLVPlybk.bufferTime = 10;

my_FLVPlybk.maintainAspectRatio = false;

my_FLVPlybk.width = 675;

my_FLVPlybk.height = 310;

my_FLVPlybk.contentPath = “http://demo.ephronsys.com/cias/is.flv&#8221;;

// creating complete object

var listener = new Object(); listener.complete = function(objetEvt) {

//loading the flv using the content path

my_FLVPlybk.contentPath = “http://demo.ephronsys.com/cias/is.flv&#8221;; my_FLVPlybk.play();

};

// define the complete object

my_FLVPlybk.addEventListener(“complete”,listener);