FORUMS: list search recent posts

Action Script 3 submenu buttons wont work

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Allie Crawford
Action Script 3 submenu buttons wont work
on Jun 28, 2009 at 9:45:01 pm

Hello,

I'm having a little problem in action script 3 and I can't find the little solution to it. If anyone can help, I'd be so grateful.

I have 6 main buttons in my website. When you click one of them called 'introduction' then the sub buttons should appear (which will link to an flv called 'SynchronizedVideoPres_12_fla'). I coded the first sub-button called 'motivations' and it works fine when its placed in frame 1 on the timeline, along with the other main buttons. (action script is in frame one also)
BUT
Obviously, the sub button is not supposed to appear until the 'introduction' button has been pressed. So therefore, I moved the 'motivations' button to frame ten so when you click 'introduction' it will just go to frame ten and show the sub button'motivations'
.....but now the sub buttons dont work and the movie clips on the main buttons dont play either(although they do show the non-working sub buttons when clicked at least.)
Im thinking I need to change the action script for the 'motivations' button so it can find the button in the timeline but I dont have a clue what to type as this is all Chinese to me.

I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SynchronizedVideoPres_12_fla::MainTimeline/frame1()

Here is the code:
// *************************
// Stop the timeline
stop();

// *************************
import fl.video.*;
import flash.events.*;

// Button hilite graphic
var highlight_mc;

// Associate full screen button with FLVPlayback
display.muteButton = mute_btn;
display.volumeBar = volume_bar;
display.stopButton = stop_btn;
display.playPauseButton = play_btn;


// *************************
// Navigation buttons call this function to trigger a change
// in the video and the view of the content

function seekToCuePoint( cueName ) : void
{
// Find the cue point in the FLVPlayback component, seek
// to time, and highlight the next button for a quick redraw
var c = display.findCuePoint( cueName );
display.seekSeconds( c.time );
findNextButton( c.name );
}

// *************************
// The natural flow through the video or jumping by seeking
// forward and backward will trigger the following function

function synchVideoToInterace( cueName:String ):void
{
// Play if needed
if(!display.isRTMP && !display.playing ){
display.play();
}

// Show associated content on screens or labeled frames
gotoAndStop( cueName );

// Update the higlight position
findNextButton( cueName );
}

// Layout the button highlight when requested

function findNextButton( cueName:String ):void
{
// Look for buttons named with the current cue point
// name plus the letters '_btn' (i.e. studiomx_btn)
if( getChildByName(cueName+"_btn") != null )
{
var cueBtn = this[cueName+"_btn"];

// Attach the highlight clip if needed
if( this["highlight_mc"] == undefined ){
highlight_mc = new ThumbOutlineSelected();
addChild(highlight_mc);
}
highlight_mc.x = cueBtn.x;
highlight_mc.y = cueBtn.y;
}
}

// *************************
// Create event handler functions to catch events from
// the video component and update the interface...

function cuePointHandler( evt:MetadataEvent ):void
{
// Get the cue name from the event object
synchVideoToInterace( evt.info.name );
}
display.addEventListener(MetadataEvent.CUE_POINT,cuePointHandler);


// *************************
// Button Event Handlers:

// Introduction
function introductionHandler(evt:MouseEvent):void
{
gotoAndStop('introduction');
}
introduction.addEventListener(MouseEvent.CLICK,introductionHandler);

// Tell a Friend
function allThingsLegalHandler(evt:MouseEvent):void
{
// Seek to cue point
gotoAndStop( "allThingsLegal" );
}
allThingsLegal.addEventListener(MouseEvent.CLICK,allThingsLegalHandler);

// finance
function financeHandler(evt:MouseEvent):void
{
// Seek to cue point
gotoAndStop( "finance" );
}
finance.addEventListener(MouseEvent.CLICK,financeHandler);

// The Company
function theCompanyHandler(evt:MouseEvent):void
{
// Seek to cue point
gotoAndStop( "theCompany" );
}
theCompany.addEventListener(MouseEvent.CLICK,theCompanyHandler);

// buyingAndSelling
function buyingAndSellingHandler(evt:MouseEvent):void
{
// Seek to cue point
gotoAndStop( "buyingAndSelling" );
}
buyingAndSelling.addEventListener(MouseEvent.CLICK,buyingAndSellingHandler);

// Top Tips
function topTipsHandler(evt:MouseEvent):void
{
// Seek to cue point
gotoAndStop( "topTips" );
}
topTips.addEventListener(MouseEvent.CLICK,topTipsHandler);


// Rewind
function rewindHandler(evt:MouseEvent):void
{
// Seek to cue point
seekToCuePoint( "rewind" );
}
rewind.addEventListener(MouseEvent.CLICK,rewindHandler);


// Extra Information
function extraInformationHandler(evt:MouseEvent):void
{
// Seek to cue point
seekToCuePoint( "motivations" );
gotoAndStop( "motivations" );
}
extraInformation.addEventListener(MouseEvent.CLICK,extraInformationHandler);


// Motivations
function motivationsHandler(evt:MouseEvent):void
{
// Seek to cue point
seekToCuePoint( "motivations" );
gotoAndStop( "motivations" );
}
motivations.addEventListener(MouseEvent.CLICK,motivationsHandler);

// Ideas
function ideasHandler(evt:MouseEvent):void
{
// Seek to cue point
seekToCuePoint( "ideas" );
gotoAndStop( "ideas" );
}
ideas.addEventListener(MouseEvent.CLICK,ideasHandler);




import com.afcomponents.common.display.*;
import com.afcomponents.common.graphics.*;

function onRollover(pEvt:MouseEvent):void{
pEvt.currentTarget.gotoAndPlay("rollover");
}
function onRollout(pEvt:MouseEvent):void{
pEvt.currentTarget.gotoAndPlay("rollout");
}

//reflection
var style:ReflectionStyle = new ReflectionStyle();
style.distance = 2;
style.alpha = 0.6;
style.matrixRatio = 1;
//blue buttons
var r1:BitmapReflection = new BitmapReflection(rewind,style);
addChild(r1);
var r2:BitmapReflection = new BitmapReflection(stop_btn,style);
addChild(r2);
var r3:BitmapReflection = new BitmapReflection(play_btn,style);
addChild(r3);
var r4:BitmapReflection = new BitmapReflection(bt04,style);
addChild(r4);
var r11:BitmapReflection = new BitmapReflection(pause_btn,style);
addChild(r11);



//blue buttons
rewind.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
rewind.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
stop_btn.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
stop_btn.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
play_btn.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
play_btn.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
bt04.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
bt04.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
pause_btn.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
pause_btn.addEventListener(MouseEvent.MOUSE_OUT,onRollout);

rewind.buttonMode = true;
stop_btn.buttonMode = true;
play_btn.buttonMode = true;
bt04.buttonMode = true;
pause_btn.buttonMode = true;
rewind.mouseChildren = false;
stop_btn.mouseChildren = false;
play_btn.mouseChildren = false;
bt04.mouseChildren = false;
pause_btn.mouseChildren = false;


//pink buttons
finance.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
topTips.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
introduction.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
allThingsLegal.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
theCompany.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
buyingAndSelling.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
motivations.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
extraInformation.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
ideas.addEventListener(MouseEvent.MOUSE_OUT,onRollout);
finance.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
topTips.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
introduction.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
allThingsLegal.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
theCompany.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
buyingAndSelling.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
motivations.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
extraInformation.addEventListener(MouseEvent.MOUSE_OVER,onRollover);
ideas.addEventListener(MouseEvent.MOUSE_OVER,onRollover);

finance.buttonMode = true;
topTips.buttonMode = true;
introduction.buttonMode = true;
allThingsLegal.buttonMode = true;
theCompany.buttonMode = true;
buyingAndSelling.buttonMode = true;
motivations.buttonMode = true;
extraInformation.buttonMode = true;
ideas.buttonMode = true;
finance.mouseChildren = false;
topTips.mouseChildren = false;
introduction.mouseChildren = false;
allThingsLegal.mouseChildren = false;
theCompany.mouseChildren = false;
buyingAndSelling.mouseChildren = false;
motivations.mouseChildren = false;
extraInformation.mouseChildren = false;
ideas.mouseChildren = false;


Return to posts index

sandra schmitt
Re: Action Script 3 submenu buttons wont work
on Sep 30, 2009 at 6:55:14 pm

Hello!

I am having the same problem were you ever able to fix it? If so could you post or shed some light? Or at least point me in correct direction of what to look up and try and to understand.

Thank you... if I figure out I will post too :)

thx s


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]