Sunday 22 February 2015

VISIBLE INVISIBLE FUNCTION


----------------------------------------------------------------------------------------------------------------
MAKE MOVIE CLIP INSIDE MOVIE CLIP INVISIBLE IN AS2
----------------------------------------------------------------------------------------------------------------


------------------------------------------------------------------------------------------------------------------
CODE:1
MAKE BUTTON WITH INSTANCE NAME = btn1
MAKE MOVIE CLIP WITH INSTANCE NAME = mc1
UNDER mc1 MAKE MOVIE CLIP  WITH INSTANCE NAME = mc2
-----------------------------------------------------------------------------------------------------------------
btn1.onPress=function(){
_root.mc1.mc2._visible = false;
}
---------------------------------------------------------------------------------------------------------------
CODE:2
MAKE BUTTON WITH INSTANCE NAME = btn1
MAKE MOVIE CLIP WITH INSTANCE NAME = mc1
UNDER mc1 MAKE MOVIE CLIP  WITH INSTANCE NAME = mc2
-------------------------------------------------------------------------------------------------------------
btn1.onPress=function(){
mc1.mc2._visible = false;
}
------------------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE
https://www.youtube.com/watch?v=Yt9Z-EQOgM0
https://www.youtube.com/watch?v=hhV9MVdya9s
http://rivercitygraphix.com/view-tutorial.php?id=60&sub=Flash&title=Text-Input-Component
--------------------------------------------------------------------------------------------------------------------------
button1.addEventListener(MouseEvent.CLICK, buttonClick);
function buttonClick(event:MouseEvent):void {
var myFirstVariable=boxOne.text;
boxTwo.text = "Input and Dynamic Text"+ myFirstVariable;
if(boxTwo.text == "Input and Dynamic Text"+ myFirstVariable){
button2.visible = false;
}}

----------------------------------------------------------------------------------------------------------

submit.label = "Submit";
myname.text = "Enter Your Name";
submit.addEventListener(MouseEvent.CLICK, namesubmit);
function namesubmit (event:MouseEvent):void{
nametxt.text = "Hello " + myname.text;
}

--------------------------------------------------------------------------------------------------------------

boxOne.text = "Enter Your Name";
button1.addEventListener(MouseEvent.CLICK, namesubmit);
function namesubmit (event:MouseEvent):void{
boxTwo.text = "Hello" + boxOne.text;
if(boxTwo.text == "Hello" + boxOne.text){
button2.visible = false;
}}
---------------------------------------------------------------------------------------------------------------------
WITHOUT VARIABLE WITH ONE TEXT BOX CODE
--------------------------------------------------------------------------------------------------------------------
boxOne.text = "";
button1.addEventListener(MouseEvent.CLICK, namesubmit);
function namesubmit (event:MouseEvent):void{
if(boxOne.text == "CAR" ){
button2.visible = false;
}}

----------------------------------------------------------------------------------------------------------------------

AS3: Enabling the user to submit the contents inside an input text field

http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d01.html#WS5b3ccc516d4fbf351e63e3d118a9b8f499-7ff8
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/Keyboard.html
http://www.trainingtutorials101.com/2011/01/as3-enabling-user-to-submit-contents.html
http://www.flashandmath.com/howtos/deal/
--------------------------------------------------------------------------------------------------------------------

function onKeyPressed(e:KeyboardEvent):void{
if(e.keyCode == Keyboard.ENTER){
myGreeting.text = "Hello, " + myInput.text + "!";
}}

--------------------------------------------------------------------------------------------------------------------
http://www.ilike2flash.com/2010/01/hiding-movie-clips-in-as3.html
--------------------------------------------------------------------------------------------------------------------

//Initially disable the show button.
show_btn.enabled = false;

//Adds an event listener to the button component with the mouse click event.
hide_btn.addEventListener(MouseEvent.CLICK, hideObject);
show_btn.addEventListener(MouseEvent.CLICK, showObject);

//This function hide the horse movie clip, and disables the hide button.
function hideObject (event:MouseEvent):void {
horse_mc.visible = false;
show_btn.enabled = true;
hide_btn.enabled = false;
}

//This function show the horse movie clip, and disables the show button.
function showObject(event:MouseEvent):void {
horse_mc.visible = true;
show_btn.enabled = false;
hide_btn.enabled = true;
}

---------------------------------------------------------------------------------------------------------------
http://www.passyworld.com/passyPDFs/ToggleButtonNotes.pdf
-----------------------------------------------------------------------------------------------------------------


myButton2.addEventListener(Event.CHANGE, changeHandler2);
function changeHandler2 (event:Event):void {
 if (event.currentTarget.selected == true) {
 my_mc2.visible = false;
 myButton2.label = "Show Charlie";
 } else {
 my_mc2.visible = true;
 myButton2.label = "Hide Charlie";
 }
}


--------------------------------------------------------------------------------------------------------------
http://www.kirupa.com/forum/showthread.php?372224-using-Array-inside-a-loop-to-make-some-objects-visible-invisible
----------------------------------------------------------------------------------------------------------------------
var firsts:Array = [Sharing,mano,face,exchan,mondrian];
var seconds:Array = [Sharingmovie,manomov,movieface,exchangemovie,mondrianmovie];
next, you have the clickPag1() method declared inside the loop and can be externalized - but there is also a way to use the information from the event object to achieve your objective - because the two arrays are 'parallel' so-to-speak, you can use the index of one element to get the corresponding one from the other array - so, for instance, examine the following:
Code:
var firsts:Array = [Sharing,mano,face,exchan,mondrian];
var seconds:Array = [Sharingmovie,manomov,movieface,exchangemovie,mondrianmovie];

function init():void {
    for( var i:int=0; i<firsts.length; i++ ) {
        firsts[i].buttonMode = true;
        firsts[i].addEventListener( MouseEvent.CLICK, clickPag1 );
    }

    for( var j:int=0; j<firsts.length; j++ ) {
        seconds[j].visible = false;
        seconds[j].buttonMode = true;
        seconds[j].addEventListener( MouseEvent.CLICK, clickPag2 );
    }
}

function clickPag1( e:MouseEvent ):void {
    seconds[ firsts.indexOf( e.currentTarget ) ].visible = true;
    e.currentTarget.visible = false;
}

function clickPag2( e:MouseEvent ):void {
    e.currentTarget.visible = false;
}


----------------------------------------------------------------------------------------------------------
http://www.search.com/search?q=matching+game+as2
http://gotoanswer.stanford.edu/?q=whats+wrong+with+this+code+for+flash+mx+2004
------------------------------------------------------------------------------------------------------------
card1.onRelease =function(){
this._visible=false;
}
var c1=c2=false
card1.onRelease =function(){
if(c1 && c2){
this._visible=false;
this._parent.card2._visible=false;
}
c1=true;
}
card2.onRelease =function(){
if(c1 && c2){
this._visible=false;
this._parent.card1._visible=false;
}
c2=true;
}
----------------------------------------------------------------------------------------------------------------
OR USE THIS CODE WITHOUT VARIABLE MENTION
----------------------------------------------------------------------------------------------------------------
card1.onPress = function(){
c1=true;
if(c1 && c2){
card1._visible=false;
card2._visible=false;
}}
card2.onPress = function(){
c2=true;
if(c1 && c2){
card1._visible=false;
card2._visible=false;
}}
----------------------------------------------------------------------------------------------------------------
THIS CODE WORK CORRECTLY IF VARIABLES  VALE EQUAL 
OR USE THIS CODE WITHOUT VARIABLE MENTION
----------------------------------------------------------------------------------------------------------------
card1.onPress = function(){
c1=true;
if(c1==c2){
card1._visible=false;
card2._visible=false;
}}
card2.onPress = function(){
c2=true;
if(c1==c2){
card1._visible=false;
card2._visible=false;
}}
--------------------------------------------------------------------------------------------------------------------------
THIS CODE WORK CORRECTLY IF VARIABLES  VALE EQUAL 
OR USE THIS CODE WITHOUT VARIABLE MENTION
OR USE BELOW CODE
--------------------------------------------------------------------------------------------------------------------------
card1.onPress = function(){
c1=0;
if(c1==c2){
card1._visible=false;
card2._visible=false;
}}
card2.onPress = function(){
c2=0;
if(c1==c2){
card1._visible=false;
card2._visible=false;
}}


-----------------------------------------------------------------------------------------------------------------
http://edutechwiki.unige.ch/en/ActionScript_3_interactive_objects_tutorial
http://tecfa.unige.ch/guides/flash/ex6/action-script-3-intro/actionscript3-simple-object-manipulation.fla
actionscript3-simple-object-manipulation.fla
---------------------------------------------------------------------------------------------------------------


/* ----- Change cursor form
add a hand to cursor to each cat
This way a user understands that he/she can do something with the object.
*/
black_cat.buttonMode = true;
blue_cat.buttonMode = true;
red_cat.buttonMode = true;
brown_dog.buttonMode = true;
white_cat.buttonMode = true;
empty_cat.buttonMode = true;
grey_mouse.buttonMode = true;

/* ---- moving ---- */
black_cat.addEventListener(MouseEvent.CLICK, moveCat);
// cat can be in original position or not (true,false)
var black_cat_ori_pos = true;

function moveCat(event:MouseEvent):void {
if (black_cat_ori_pos == true)
{
black_cat.x += 200;
black_cat.y += 200;
black_cat_ori_pos = false;
}
else
{
black_cat.x -= 200;
black_cat.y -= 200;
black_cat_ori_pos = true;
}
}

/* ---- resizing ---- */
blue_cat.addEventListener(MouseEvent.MOUSE_DOWN, resizeCat);
var cat_size = 1;

function resizeCat(event:MouseEvent):void {
blue_cat.width =  blue_cat.width * 2;
blue_cat.height =  blue_cat.height * 2;
cat_size = 2;
}

// We have to test both mouse up and mouse out since user can
// press mouse and move out. Cat in this case would stay big.
// Also we have to test if cat is already big when user moves in.
blue_cat.addEventListener(MouseEvent.MOUSE_UP, resizeCat2);
blue_cat.addEventListener(MouseEvent.MOUSE_OUT, resizeCat2);

function resizeCat2(event:MouseEvent):void {
if (cat_size > 1)
{
blue_cat.width =  blue_cat.width / 2;
blue_cat.height =  blue_cat.height / 2;
cat_size = 1;
}
}

/* ---- dragging ---- */
red_cat.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
red_cat.addEventListener(MouseEvent.MOUSE_UP, stopDragging);

function startDragging(event:MouseEvent):void {
red_cat.startDrag();
}

function stopDragging(event:MouseEvent):void {
red_cat.stopDrag();
}

/* ---- Hiding ---- */
// can't see the dog for starters
brown_dog.visible=false;

brown_dog.addEventListener(MouseEvent.CLICK, hideShow);
white_cat.addEventListener(MouseEvent.CLICK, hideShow);

function hideShow(event:MouseEvent):void {
// instead of white_cat.visible = false; we just switch it to the opposite
white_cat.visible = !white_cat.visible;
brown_dog.visible =!brown_dog.visible;
}

/* ---- transforms ----
   This is a bit more difficult.... */
empty_cat.addEventListener(MouseEvent.CLICK, transformCatColor);
// R,G,B,A multipliers and R,G,B,A offsets
// We start with a light grey cat
var resultColorTransform = new ColorTransform (0.1,0.1,0.1,1,120,120,120,255);
empty_cat.transform.colorTransform = resultColorTransform;

function transformCatColor(event:MouseEvent):void {
var resultColorTransform = empty_cat.transform.colorTransform;
// Create a new color transform object and change it
// red color will peak at 255, blue color offset will cycle from +255 to -100
resultColorTransform.redOffset = Math.min(resultColorTransform.redOffset+10,255);
resultColorTransform.redMultiplier = Math.min(resultColorTransform.redMultiplier+0.1,1);
resultColorTransform.blueOffset += 10;
if (resultColorTransform.blueOffset >= 255)
{
resultColorTransform.blueOffset = -100;
}
resultColorTransform.blueMultiplier = 0.1;
// Copy that to the cat
empty_cat.transform.colorTransform = resultColorTransform;
//trace("redOffset="+resultColorTransform.redOffset +
//   " blueOffset="+resultColorTransform.blueOffset);
}

/* ---- permanent size change ---- */

grey_mouse.addEventListener(MouseEvent.MOUSE_WHEEL, changeMouse);

function changeMouse(event:MouseEvent):void {
grey_mouse.width += event.delta*3;
grey_mouse.height += event.delta*3;
}

-------------------------------------------------------------------------------------------------------------------
TWO ARRAY FUNCTION BUTTON AND MOVIE CLIP  AS3 
http://www.ciiycode.com/0zmy6qexxqxx/as3-array-containing-movieclips-indexof
indexOf(e.target);
-------------------------------------------------------------------------------------------------------------------

var mcArray:Array = new Array(mc1, mc2);
var btnArray:Array = new Array(btn1, btn2);
for(var i:uint = 0; i < mcArray.length; i++) {
btnArray[i].addEventListener(MouseEvent.CLICK, expandInfo);
}
function expandInfo(e:MouseEvent):void {
var index:uint = btnArray.indexOf(e.target);
mcArray[index].visible = false;
}

-----------------------------------------------------------------------------------------------------------------
http://www.ilike2flash.com/2011/04/drag-and-drop-in-as3-part-3.html
----------------------------------------------------------------------------------------------------------------

//Array to hold the target instances, the drop instances,
//and the start positions of the drop instances.
var hitArray:Array = new Array(hitTarget1,hitTarget2,hitTarget3);
var dropArray:Array = new Array(drop1,drop2,drop3);
var positionsArray:Array = new Array();


//This adds the mouse down and up listener to the drop instances
//and add the starting x and y positions of the drop instances
//into the array.
for (var i:int = 0; i < dropArray.length; i++) {
dropArray[i].buttonMode = true;
dropArray[i].addEventListener(MouseEvent.MOUSE_DOWN, mdown);
dropArray[i].addEventListener(MouseEvent.MOUSE_UP, mUp);

positionsArray.push({xPos:dropArray[i].x, yPos:dropArray[i].y});
}

//This drags the object that has been selected and moves it
//to the top of the display list. This means you can't drag
//this object underneath anything.
function mdown(e:MouseEvent):void {
e.currentTarget.startDrag();
setChildIndex(MovieClip(e.currentTarget), numChildren - 1);
}

//This stops the dragging of the selected object when the mouse is
//released. If the object is dropped on the corresponding target
//then it get set to the x and y position of the target. Otherwise
//it returns to the original position.
function mUp(e:MouseEvent):void {
var dropIndex:int = dropArray.indexOf(e.currentTarget);
var target:MovieClip = e.currentTarget as MovieClip;

target.stopDrag();

if (target.hitTestObject(hitArray[dropIndex])) {
target.x = hitArray[dropIndex].x;
target.y = hitArray[dropIndex].y;
}else{
target.x = positionsArray[dropIndex].xPos;
target.y = positionsArray[dropIndex].yPos;
}
}

-------------------------------------------------------------------------------------------------------------------
VISIBLE TRUE FALSE WITH IF CONDITION AND MOVIE PLAY
--------------------------------------------------------------------------------------------------------------------
Btn1.onPress = function(){
Mc1._visible = false;
}
Btn2.onPress = function(){
//HERE USE == INSIDE BRACKET
if(Mc1._visible == false){
Mc1._visible = true;
}
else{
_root.TryAginMc.play();
}
}

==================================================================== NEXT FRAME MOVIE CLIP VISIBLE FALSE AS2

1) TAKE GREEN MOVIE IN FRAME N0:1
2) CHANGE MOVIE SIZE HEIGHT AND WIDTH BECAUSE: WITHOUT THIS IT DO'ST NOT WORK ==================================================================== https://www.youtube.com/watch?v=Z4IU2qoXl7E
====================================================================

------------------------------------------------------------------------------------------------------------------------------------------------------------









EmoticonEmoticon