Hi Guys ,
In this post i am going to tell a basic way to load a movie clip from library.
Step 1: Add a movie Clip in stage so that it will get added to your library.
Step 2: Delete from the stage so it will be available in the library.
Step 3: Now open the library (ctr+l) right click the movie clip and give Export for Action script and give a name
Step 4: link the stage property to the class file addmc.
Step 5: create a flash script file name it as addmc.as.
Step 6:Now in the as file
package {
import flash.display.MovieClip;
public class addmc extends MovieClip{
public function addmc(){
//creating a object for the movie clip we created and placed in the library.
var male_mc:male;
male_mc = new male;
//setting the position.
male_mc.x=100;
male_mc.y=100;
//adding the movieclip to the stage
addChild(male_mc);
}
}
}
This is a basic example how to add a library file to stage.
you can download the sample file from addMC
Do u want to search anything in my site just try out the Google search Above next to the head. Don't forget to leave a comment about this
Showing posts with label AS3. Show all posts
Showing posts with label AS3. Show all posts
Tuesday, August 3, 2010
Tuesday, April 14, 2009
Link a url in AS3.0
extension of the old post if you have not read the old one follow the link
button event in AS3.0
In this one i like to explain how to link a url in AS3.0
Step 1:
Create a button with the event and the function. if you are not aware plz read the previous post button event in AS3.0
Step 2:
inside the function write the code to link the URL
You need to create a URLRequest object in the Syntax
var <url_oblect>:URLRequest = new URLRequest(<url string>);
in our example the code will look like
var url:URLRequest = new URLRequest("http://gbala.com/");
Where url is the object and http://gbala.com/ is my website url
once it is done
Step 3:
ask the url to load the site.
navigateToURL(<url string>);
in our example
navigateToURL(url);
Where this line ask to go to the url specified in the URLRequest.
where navigateToURL can have 2 parameter and the second one can be either of this 4
The whole code is as followes...
function button_click(event:MouseEvent):void
{
var url:URLRequest = new URLRequest("http://gbala.com/");
navigateToURL(url);
}
b1.addEventListener(MouseEvent.CLICK, button_click);
in AS2.0 it is just one line code getURL("url");
but in AS3.0 they changed a bit.
Download source code file : Navigate.zip
Do u want to search anything in my site just try out the Google search Above next to the head.
Don't forget to leave a comment about this
button event in AS3.0
In this one i like to explain how to link a url in AS3.0
Step 1:
Create a button with the event and the function. if you are not aware plz read the previous post button event in AS3.0
Step 2:
inside the function write the code to link the URL
You need to create a URLRequest object in the Syntax
var <url_oblect>:URLRequest = new URLRequest(<url string>);
in our example the code will look like
var url:URLRequest = new URLRequest("http://gbala.com/");
Where url is the object and http://gbala.com/ is my website url
once it is done
Step 3:
ask the url to load the site.
navigateToURL(<url string>);
in our example
navigateToURL(url);
Where this line ask to go to the url specified in the URLRequest.
where navigateToURL can have 2 parameter and the second one can be either of this 4
"_self" specifies the current frame in the current window""_blank" specifies a new window. "_parent" specifies the parent of the current frame. "_top" specifies the top-level frame in the current window. The whole code is as followes...
function button_click(event:MouseEvent):void
{
var url:URLRequest = new URLRequest("http://gbala.com/");
navigateToURL(url);
}
b1.addEventListener(MouseEvent.CLICK, button_click);
in AS2.0 it is just one line code getURL("url");
but in AS3.0 they changed a bit.
Download source code file : Navigate.zip
Do u want to search anything in my site just try out the Google search Above next to the head.
Don't forget to leave a comment about this
AS3.0 button event
Hi,
In this i like to specify a simple button example in AS3.0.
Most people says we cant wright code in frame That is FALSE... We can... In this example i has written the code in the frame.
Step 1:
Create a button and place it in the stage... Give the instance name for it In my example i has specified as b1.
Step 2:
Go to the frame Now and add a event listener for that button.
like
Syntax:
<button>.addEventListener(<eventname>, <function_name>);
in our example
b1.addEventListener(MouseEvent.CLICK, button_click);
Step 3:
Write the code for function
Syntax
function <function_name>(<event object>:<event>):<return type>
{
//code for the function
}
in our example
function button_click(event:MouseEvent):void
{
trace("button is clicked");
}
where
button_click is the function Name
event is the object of the MouseEvent
MouseEvent is the event name.
You are done.
Run the file You made a button to work in AS3.0
Hear is the whole code...
function button_click(event:MouseEvent):void
{
trace("button is clicked");
}
b1.addEventListener(MouseEvent.CLICK, button_click);
Do u want to search anything in my site just try out the Google search Above next to the head.
Don't forget to leave a comment about this
In this i like to specify a simple button example in AS3.0.
Most people says we cant wright code in frame That is FALSE... We can... In this example i has written the code in the frame.
Step 1:
Create a button and place it in the stage... Give the instance name for it In my example i has specified as b1.
Step 2:
Go to the frame Now and add a event listener for that button.
like
Syntax:
<button>.addEventListener(<eventname>, <function_name>);
in our example
b1.addEventListener(MouseEvent.CLICK, button_click);
Step 3:
Write the code for function
Syntax
function <function_name>(<event object>:<event>):<return type>
{
//code for the function
}
in our example
function button_click(event:MouseEvent):void
{
trace("button is clicked");
}
where
button_click is the function Name
event is the object of the MouseEvent
MouseEvent is the event name.
You are done.
Run the file You made a button to work in AS3.0
Hear is the whole code...
function button_click(event:MouseEvent):void
{
trace("button is clicked");
}
b1.addEventListener(MouseEvent.CLICK, button_click);
Do u want to search anything in my site just try out the Google search Above next to the head.
Don't forget to leave a comment about this
Thursday, December 4, 2008
Class and Function in AS3
Hi Guys,
This is my first tutorial in AS3.
The big change in AS2 and AS3 is Object Oriented Programming.
In AS3 all are considered as Object, Class. In this let me say What is Class ? , What is Object? , What is Package and their syntax.
Package:
Package is the collection of class. Class needs to be specified with in a package.
Syntax:
package
{
....
...
}
Class:
Class is the collection of function and variables.
Syntax:
class
{
...
...
}
type can be of 4 types : dynamic, final, internal, public where internal id default.
Object:
Object is the instance of class. Hear is the power of Object oriented programming by creating a single class we can create multiple objects.
var: = new ();
Example with all package, class, object...
//sample.as
package
{
class sample
{
sample()
{
trace("Hi");
}
}
}
//main.fla
var my_obj:sample = new sample();
Note : Both main.fla and sample.as must be in the same place.
Note : AS3 is case sensitive.
This is my first tutorial in AS3.
The big change in AS2 and AS3 is Object Oriented Programming.
In AS3 all are considered as Object, Class. In this let me say What is Class ? , What is Object? , What is Package and their syntax.
Package:
Package is the collection of class. Class needs to be specified with in a package.
Syntax:
package
{
....
...
}
Class:
Class is the collection of function and variables.
Syntax:
{
...
...
}
type can be of 4 types : dynamic, final, internal, public where internal id default.
Object:
Object is the instance of class. Hear is the power of Object oriented programming by creating a single class we can create multiple objects.
var
Example with all package, class, object...
//sample.as
package
{
class sample
{
sample()
{
trace("Hi");
}
}
}
//main.fla
var my_obj:sample = new sample();
Subscribe to:
Posts (Atom)
