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
gbala - Tricks in FLASH
Tricks in flash found by me...
Tuesday, August 3, 2010
Friday, April 17, 2009
Print a movie clip in flash
In this i like to tell about how to print a movie clip from flash AS2.0.
for this just create a movie clip what it has to print. name it as your wish.
and copy the below code and past it in the frame.
function print_page() {
var my_pj = new PrintJob();
var myResult = my_pj.start();
if (myResult) {
myResult = my_pj.addPage("img_mc2", null, {printAsBitmap:true}, 1);
my_pj.send();
delete my_pj;
trace("asdasdasdasd");
}
}
In the button put the code as
on(release){
print_page();
}
A sample file is in the below link
download rar file zip file
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
for this just create a movie clip what it has to print. name it as your wish.
and copy the below code and past it in the frame.
function print_page() {
var my_pj = new PrintJob();
var myResult = my_pj.start();
if (myResult) {
myResult = my_pj.addPage("img_mc2", null, {printAsBitmap:true}, 1);
my_pj.send();
delete my_pj;
trace("asdasdasdasd");
}
}
In the button put the code as
on(release){
print_page();
}
A sample file is in the below link
download rar file zip file
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
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
Subscribe to:
Posts (Atom)