-------------------------------------------------------------------------------------------------------
MOVIE NEXT FRAME FUNCTION IN AS3
CREATE TWO FRAME MOVIE CLIP WITH STOP FUNCTION stop();
GIVE INSTANCE NAME IN MOVIE1
MOVIE1.addEventListener(MouseEvent.CLICK, MOVIE1Click);
function MOVIE1Click(ev:MouseEvent):void{
MOVIE1.nextFrame();
}
-------------------------------------------------------------------------------------------------------
MOVIE NEXT FRAME FUNCTION WITH BUTTON ARRAY IN AS3
1-CREATE TWO FRAME MOVIE CLIP WITH STOP FUNCTION stop();
GIVE INSTANCE NAME IN MOVIE1
2- CREATE TWO BUTTONS
3-GIVE INSTANCE NAME IN BUTTON1, BUTTON2,
var clicked = MouseEvent.CLICK
var ButtonArray = new Array(BUTTON1,BUTTON2);
for (var i:int = 0; i < ButtonArray.length; i++) {
ButtonArray[i].addEventListener(MouseEvent.CLICK,MovieNextFrame);
}
function MovieNextFrame(event:MouseEvent):void {
MOVIE1.nextFrame();
}
---------------------------------------------------------------------------------------------------
OR UPPER CODE WRITE THIS WAY
---------------------------------------------------------------------------------------------------
var ButtonArray = [BUTTON1,BUTTON2]
for (var i:int = 0; i < ButtonArray.length; i++) {
ButtonArray[i].addEventListener(MouseEvent.CLICK,MovieNextFrame);
}
function MovieNextFrame(event:MouseEvent):void {
trace("Hello!");
MOVIE1.nextFrame();
}
OR UPPER CODE WRITE THIS WAY
---------------------------------------------------------------------------------------------------
var ButtonArray = [BUTTON1,BUTTON2]
for (var i:int = 0; i < ButtonArray.length; i++) {
ButtonArray[i].addEventListener(MouseEvent.CLICK,MovieNextFrame);
}
function MovieNextFrame(event:MouseEvent):void {
trace("Hello!");
MOVIE1.nextFrame();
}
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
//SET TIME LINE LABEL
var myMenuArray = [home,portfolio,about,services,contact];
for each (var btn In myMenuArray){
btn.addEventListener(MouseEvent.CLlCK, onBtnCllck);
}
function onBtnClIck (event:MouseEvent):voId{
pages.gotoAndStop(event.target.name]
}
-------------------------------------------------------------------------------------
6 IMAGE UPLOAD AND PASTE CODE
CRATE BUTTON AND GIVE INSTANCE NAME
BUTTON INSTANCE NAME = random_btn
http://flashcollege.blogspot.co.uk/2014/12/random-function-in-as3.html
http://www.rivercitygraphix.com/view-tutorial.php?id=44&sub=Flash&title=Generate-a-Random-Frame-with-AS3
---------------------------------------------------------------------------------------------
stop();
random_btn.addEventListener(MouseEvent.CLICK, choose);
function choose(event:MouseEvent):void{
var pic_number : Number = 6;
var randomFrame:Number = Math.ceil(Math.random() * pic_number);
trace(randomFrame);
gotoAndStop(randomFrame);
}
-------------------------------------------------------------------------------------------------------------
RANDOM FRAME ARRAY FUNCTION
-------------------------------------------------------------------------------------------------------------
var ButtonArray = [BUTTON1,BUTTON2]
var FrameNumber : Number = 6;
var RandomFrame:Number = Math.ceil(Math.random() * FrameNumber);
for (var i:int = 0; i < ButtonArray.length; i++) {
ButtonArray[i].addEventListener(MouseEvent.CLICK,MovieNextFrame);
}
function MovieNextFrame(event:MouseEvent):void {
trace("Hello!");
MOVIE1.gotoAndStop(RandomFrame);
}
------------------------------------------------------------------------------------------------------------
MOVIE DRAG AND DROP WITH ARRAY FUNCTION AS2
CRATE TEXT BOX WITH MOVIE1 MOVIE2 MOVIE3 AND CHANGE INTO BITMAP
AFTER ALL BITMAP IMAGS CHANGE INTO MOVIE CLIPS AND GIVE
INSTANCE NAME MOVIE1,MOVIE2,MOVIE3
https://www.youtube.com/watch?v=zQNQcqfFJuI
https://www.youtube.com/watch?v=DpUoVSOahq0
-----------------------------------------------------------------------------------------------------------
var MovieArray = [MOVIE1,MOVIE2,MOVIE3]
for (i = 0; i < MovieArray.length; i++){
MovieArrayFunction(MovieArray[i]);
}
function MovieArrayFunction(MovieArray){
MovieArray.onPress = function (){
MovieArray.startDrag();
}
MovieArray.onRelease = function (){
MovieArray.stopDrag();
}}
------------------------------------------------------------------------------------------------------------
MOVIE DRAG AND DROP WITH ARRAY FUNCTION AS3
CRATE TEXT BOX WITH MOVIE1 MOVIE2 MOVIE3 AND CHANGE INTO BITMAP
AFTER ALL BITMAP IMAGS CHANGE INTO MOVIE CLIPS AND GIVE
INSTANCE NAME MOVIE1,MOVIE2,MOVIE3
https://www.youtube.com/watch?v=zQNQcqfFJuI
https://www.youtube.com/watch?v=DpUoVSOahq0
-----------------------------------------------------------------------------------------------------------
var MovieArray = [MOVIE1,MOVIE2,MOVIE3];
for (var i:int = 0; i < MovieArray.length; i++){
MovieArray[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
MovieArray[i].addEventListener(MouseEvent.MOUSE_UP, drop);
}
function drag(event:MouseEvent):void {
event.currentTarget.startDrag();
}
function drop(event:MouseEvent):void {
event.currentTarget.stopDrag();
}
----------------------------------------------------------------------------------------------------------------
SWAP ARRAY FOR BUTTON
http://myas3.blogspot.co.uk/2013/03/swap-movieclip-in-as3-setchildindex.html
--------------------------------------------------------------------------------------------------------------
Swap MovieClip in as3 (setchildindex)
//swap movieclip using "setchildindex" in as3.
//create three movie Clips redMc,blueMc,yellowMc on the stage and copy past the script in first timeline.
import flash.events.MouseEvent;
import flash.display.MovieClip;
var btarray:Array = [redMc,blueMc,yellowMc];
for(var i:int = 0; i<btarray.length; i++)
{
btarray[i].addEventListener(MouseEvent.CLICK,swapme);
btarray[i].buttonMode = true;
}
function swapme(e:MouseEvent):void
{
this.setChildIndex(e.target as MovieClip,(numChildren-1));
}
The Result.
When click blueMc:
When click redMc:
When click YellowMc:
//create three movie Clips redMc,blueMc,yellowMc on the stage and copy past the script in first timeline.
import flash.events.MouseEvent;
import flash.display.MovieClip;
var btarray:Array = [redMc,blueMc,yellowMc];
for(var i:int = 0; i<btarray.length; i++)
{
btarray[i].addEventListener(MouseEvent.CLICK,swapme);
btarray[i].buttonMode = true;
}
function swapme(e:MouseEvent):void
{
this.setChildIndex(e.target as MovieClip,(numChildren-1));
}
The Result.
When click blueMc:
When click redMc:
When click YellowMc:
---------------------------------------------------------------------------------------------------------------
EmoticonEmoticon