A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Help with creating an if/then function for a flash banner

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    10

    Help with creating an if/then function for a flash banner

    Hello, I have a flash banner that needs to have some interactivity. it needs to function thusly.. there are 3 "zones" (buttons) that reveal a message. after the message is fully revealed (all 3 buttons moused over) the banner should continue to the secondary animation "playFrm2". If no buttons are interacted with.. then the banner would just got to "playFrm2" after a set amount of time.. say 10 seconds. I know it needs a timer.. but I don't know how to make a "bucket" for the 3 buttons to throw a "yes" into for it to advance to the next frame of animation. I will revisit the 2 scenarios for the functioning of the banner..

    A. the user does not interact with the banner and the banner goes to "playFrm2" after 10 secoonds

    B. the user interacts with the banner.. mousing over the 3 "reveal zones" (buttons) upon revealing the 3rd zone.. the banner would go to "playFrm2". now if only 1 or 2 of the buttons were moused over.. it would still wait for the timer to expire before going to "playFrm2".



    Code:
    /*************************************************
    **  INCLUDES
    *************************************************/
    #include "lmc_tween.as"
    
    
    /*************************************************
    **  VARS
    *************************************************/
    
    
    /*************************************************
    **  FRAME ACTIONS
    *************************************************/
    openingAni();
    stop();
    
    
    
    /*************************************************
    **  ANIMATIONS
    *************************************************/
    
    function openingAni():Void {
    
    	middlescratch.alphaTo(100, .3, 'easeInOutSine', 3.5);
    	leftscratch.alphaTo(100, .3, 'easeInOutSine', 5);
    	rightscratch.alphaTo(100, .3, 'easeInOutSine', 6, playFrm1);
    }
    
    function playFrm1():Void {
    
    	whiteblock.tween('_x', 0, .0, 'easeInOutSine', 3);
    	ribb.alphaTo(100, .2, 'easeInOutSine', 3.2);
    	orangeblink.alphaTo(0, .5, 'easeInOutSine', 4);
    	blackbox.alphaTo(100, .3, 'easeInOutSine', 4);
    	ticket.alphaTo(100, .5, 'easeInOutSine', 4.1);
    	ribb.scaleTo(24, .3, 'easeInOutSine', 4.2);
    	ribb.tween('_y', 146, .3, 'easeInOutSine', 4.2);
    	ribb.tween('_x', 142, .3, 'easeInOutSine', 4.2);
    	ribb.alphaTo(0, .4, 'easeInOutSine', 4.4, playFrm2);
    }
    
    function playFrm2():Void {
    
    
    	ticket.scaleTo(54, .3, 'easeInOutSine', 2);
    	ticket.tween('_y', 14, .3, 'easeInOutSine', 2);
    	ticket.tween('_x', 153, .3, 'easeInOutSine', 2);
    	logoagain.alphaTo(100, .5, 'easeInOutSine', 2.5);
    	endtext.alphaTo(100, .5, 'easeInOutSine', 3);
    	bb.tween('_y', 0, .0, 'easeInOutSine', 3);
    	bb.tween('_x', 0, .0, 'easeInOutSine', 3);
    	
    }
    
    
    /**********************************************************
    * BUTTONS
    **********************************************************/
    
    leftscratch.onRollOver= function():Void {
    		leftscratch.alphaTo(100, .3, 'easeInOutSine');
    }
    
    middlescratch.onRollOver= function():Void {
    		middlescratch.alphaTo(100, .3, 'easeInOutSine');
    }
    
    rightscratch.onRollOver= function():Void {
    		rightscratch.alphaTo(100, .3, 'easeInOutSine');
    }
    
    
    
    bb.onRelease = function():Void {
    getURL(clickTag, "“_blank”");
    }
    here is code I have for a banner to continue to the next frame after a timer times out.. or the user interacts with the banner.. but i need this banner to move on after 3 interactions...


    Code:
    var isPlaying:Boolean    //create a variable to set whether the playFrm1 is playing or not
    isPlaying=false;
    openingAni();    //execute this
    
    //timer, do an action when inactive for X secs
    function timer(){   
    if(isPlaying==true){
    //do nothing
    }  
    else {
      playFrm1();  //when passed X seconds, then execute playFrm1
    isPlaying=true;  //set  that playFrm1  is playing
    }
    clearInterval(tim)
    } var tim=setInterval(timer, 11000); //1000 milliseconds is 1 second
    
    //and in the button
    actionbb.onPress= function():Void {
    if(isPlaying==true){
    //do nothing
    }
    else {
     playFrm1(); //execute  playFrm1 on  button action
    isPlaying=true;  //set that  playFrm1  is playing
    }
        
            openribgrp.scaleTo(200, .5, easeoutelastic, .1);
            openribgrp.tween('_x', -200, .5, easeoutelastic, .1);
            openribgrp.tween('_y', -252, .5, easeoutelastic, .1);
    		freeill.alphaTo(100, 1, easeInOutSine, 	.1);
            openribgrp.alphaTo(0, .9, easeInOutSine, .1);
            actionbb.tween('_x', -400, .5, easeInOutSine, .1);
            calltobb.tween('_x', -6.65, .5, easeInOutSine, .1);
    		curtaintwo.rotateTo(-183, 1.7, easeInSine, .1);
            curtaintwo.tween('_y', -45, 2, easeInOutSine, .1);      
    		curtain.rotateTo(1, 1.7, easeInSine, .1);
            curtain.tween('_y', -45, 2, easeInOutSine, .1, playFrm2);         
    
    }
    
    
    function playFrm1():Void {
    
    
            openribgrp.scaleTo(200, .5, easeoutelastic, .1);
            openribgrp.tween('_x', -200, .5, easeoutelastic, .1);
            openribgrp.tween('_y', -252, .5, easeoutelastic, .1);
    		freeill.alphaTo(100, 1, easeInOutSine, 	.1);
            openribgrp.alphaTo(0, .9, easeInOutSine, .1);
            actionbb.tween('_x', -400, .5, easeInOutSine, .1);
            calltobb.tween('_x', -6.65, .5, easeInOutSine, .1);
    		curtaintwo.rotateTo(-183, 1, easeInSine, .1);
            curtaintwo.tween('_y', -45, 3.2, easeInOutSine, .1);      
    		curtain.rotateTo(1, 1, easeInSine, .1);
            curtain.tween('_y', -45, 3.2, easeInOutSine, .1, playFrm2);      
    
            isPlaying=false;  //set playFrm1 is not playing anymore
    }

    thanks for any help.

  2. #2
    Senior Member
    Join Date
    Mar 2006
    Posts
    139
    could you not do something like:


    Code:
    leftscratch.onRollOver= function():Void {
    		leftscratch.alphaTo(100, .3, 'easeInOutSine'); button_check_mc.nextFrame();
    }
    
    middlescratch.onRollOver= function():Void {
    		middlescratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }
    
    rightscratch.onRollOver= function():Void {
    		rightscratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }

    and create a moveClip called button_check_mc with a stop() on the first frame, nothing on the second or third, and then on the fourth a bit of script to go to and play playFrm2?

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    10
    well, all 3 need to be "activated" before it would go to the next frame.. i'm trying to do this all via AS.. without any timeline AS.. as the banner loads a timer starts to count.. i was thinking all it needed was a variable that ticks up as each zone is moused over.. upon reaching "3" the banner would go tot he next set of instructions.. if the variable does not = "3" by the time the timer runs out.. then it would advance to the next set of instructions.

    does that make sense? i'm just stuffing animations into functions and then calling to those functions... i understand programming.. but i'm nowhere near being a developer.. just trying to figure this stuff out.

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    You can do this.
    Code:
    var button1activated=false;
    var button2activated=false;
    var button3activated=false;
    And on the buttons:
    Code:
    
    leftscratch.onRollOver= function():Void {
    button1activated=true;
    		leftscratch.alphaTo(100, .3, 'easeInOutSine'); button_check_mc.nextFrame();
    }
    
    middlescratch.onRollOver= function():Void {
    button2activated=true;
    		middlescratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }
    
    rightscratch.onRollOver= function():Void {
    button3activated=true;
    		rightscratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }
    
    
    onEnterFrame=function(){
    if (button1activated==true && button2activated==true && button3activated==true ){
    //GO TO THIS FRAME OR DO THIS
    }
    }
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  5. #5
    Junior Member
    Join Date
    May 2012
    Posts
    10
    Thanks. That looks like the ticket. I will see how this works.

  6. #6
    Junior Member
    Join Date
    May 2012
    Posts
    10
    well, i seem to have a targeting issue. as in i placed the code where i think it works.. but it does not. i have provided the full code as i tried it.. i don't know how to make it go to the next frame.. (but i'll keep trying)

    Code:
    /*************************************************
    **  INCLUDES
    *************************************************/
    #include "lmc_tween.as"
    
    
    
    /*************************************************
    **  VARS
    *************************************************/
    
    var button1activated=false;
    var button2activated=false;
    var button3activated=false;
    
    
    /*************************************************
    **  FRAME ACTIONS
    *************************************************/
    
    openingAni();
    stop();
    
    
    
    /*************************************************
    **  ANIMATIONS
    *************************************************/
    
    function openingAni():Void {
    
    	middlescratch.alphaTo(100, .3, 'easeInOutSine', 3.5);
    	leftscratch.alphaTo(100, .3, 'easeInOutSine', 5);
    	rightscratch.alphaTo(100, .3, 'easeInOutSine', 6, playFrm1);
    }
    
    function playFrm1():Void {
    
    	whiteblock.tween('_x', 0, .0, 'easeInOutSine', 3);
    	ribb.alphaTo(100, .2, 'easeInOutSine', 3.2);
    	orangeblink.alphaTo(0, .5, 'easeInOutSine', 4);
    	blackbox.alphaTo(100, .3, 'easeInOutSine', 4);
    	ticket.alphaTo(100, .5, 'easeInOutSine', 4.1);
    	ribb.scaleTo(24, .3, 'easeInOutSine', 4.2);
    	ribb.tween('_y', 146, .3, 'easeInOutSine', 4.2);
    	ribb.tween('_x', 142, .3, 'easeInOutSine', 4.2);
    	ribb.alphaTo(0, .4, 'easeInOutSine', 4.4, playFrm2);
    }
    
    function playFrm2():Void {
    
    
    	ticket.scaleTo(54, .3, 'easeInOutSine', 2);
    	ticket.tween('_y', 14, .3, 'easeInOutSine', 2);
    	ticket.tween('_x', 153, .3, 'easeInOutSine', 2);
    	logoagain.alphaTo(100, .5, 'easeInOutSine', 2.5);
    	endtext.alphaTo(100, .5, 'easeInOutSine', 3);
    	bb.tween('_y', 0, .0, 'easeInOutSine', 3);
    	bb.tween('_x', 0, .0, 'easeInOutSine', 3);
    	
    }
    
    
    /**********************************************************
    * BUTTONS
    **********************************************************/
    leftscratch.onRollOver= function():Void {
    button1activated=true;
    		leftscratch.alphaTo(100, .3, 'easeInOutSine'); button_check_mc.nextFrame();
    }
    
    middlescratch.onRollOver= function():Void {
    button2activated=true;
    		middlescratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }
    
    rightscratch.onRollOver= function():Void {
    button3activated=true;
    		rightscratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }
    
    
    onEnterFrame=function(){
    if (button1activated==true && button2activated==true && button3activated==true ){
    //GO TO THIS FRAME OR DO THIS
    }
    }
    
    bb.onRelease = function():Void {
    getURL(clickTag, "“_blank”");
    }

  7. #7
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    /*************************************************
    ** INCLUDES
    *************************************************/
    #include "lmc_tween.as"



    /*************************************************
    ** VARS
    *************************************************/

    var button1activated=false;
    var button2activated=false;
    var button3activated=false;


    /*************************************************
    ** FRAME ACTIONS
    *************************************************/

    openingAni();
    stop();



    /*************************************************
    ** ANIMATIONS
    *************************************************/

    function openingAni():Void {

    middlescratch.alphaTo(100, .3, 'easeInOutSine', 3.5);
    leftscratch.alphaTo(100, .3, 'easeInOutSine', 5);
    rightscratch.alphaTo(100, .3, 'easeInOutSine', 6, playFrm1);
    }

    function playFrm1():Void {

    whiteblock.tween('_x', 0, .0, 'easeInOutSine', 3);
    ribb.alphaTo(100, .2, 'easeInOutSine', 3.2);
    orangeblink.alphaTo(0, .5, 'easeInOutSine', 4);
    blackbox.alphaTo(100, .3, 'easeInOutSine', 4);
    ticket.alphaTo(100, .5, 'easeInOutSine', 4.1);
    ribb.scaleTo(24, .3, 'easeInOutSine', 4.2);
    ribb.tween('_y', 146, .3, 'easeInOutSine', 4.2);
    ribb.tween('_x', 142, .3, 'easeInOutSine', 4.2);
    ribb.alphaTo(0, .4, 'easeInOutSine', 4.4, playFrm2);
    }

    function playFrm2():Void {


    ticket.scaleTo(54, .3, 'easeInOutSine', 2);
    ticket.tween('_y', 14, .3, 'easeInOutSine', 2);
    ticket.tween('_x', 153, .3, 'easeInOutSine', 2);
    logoagain.alphaTo(100, .5, 'easeInOutSine', 2.5);
    endtext.alphaTo(100, .5, 'easeInOutSine', 3);
    bb.tween('_y', 0, .0, 'easeInOutSine', 3);
    bb.tween('_x', 0, .0, 'easeInOutSine', 3);

    }


    /************************************************** ********
    * BUTTONS
    ************************************************** ********/
    leftscratch.onRollOver= function():Void {
    button1activated=true;
    leftscratch.alphaTo(100, .3, 'easeInOutSine'); button_check_mc.nextFrame();
    }

    middlescratch.onRollOver= function():Void {
    button2activated=true;
    middlescratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }

    rightscratch.onRollOver= function():Void {
    button3activated=true;
    rightscratch.alphaTo(100, .3, 'easeInOutSine');button_check_mc.nextFrame();
    }


    onEnterFrame=function(){
    if (button1activated==true && button2activated==true && button3activated==true ){
    gotoAndStop(2); //if is a frame number put a number there,
    //if is a frame label put gotoAndStop("YourLabelNameHere"); with quotes
    }
    }

    bb.onRelease = function():Void {
    getURL(clickTag, "“_blank”");
    }
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center