3 Replies - 2952 Views - Last Post: 08 October 2012 - 09:24 AM

#1 hcs0112358  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-September 12

Dynamic Button Problems

Posted 01 October 2012 - 12:17 PM

I'm working on modifying a current program, and I want to create a button that directs to 2 different URLs, according to user input.

Specifically, there is a movie clip of a planet, and I want to make a button that goes to URL (A) while you see the front side of the planet. When the user clicks a separate button to spin the planet, I want to link to a different URL (B).

Current code:
stop();
var currentPlanetSide;

import flash.events.MouseEvent;
btn_MainMenu.addEventListener(MouseEvent.CLICK, clickMainMenu_btn);
btn_FullScreen.addEventListener(MouseEvent.CLICK, goFull);

//------------------btn_Spin
btn_Spin.addEventListener(MouseEvent.CLICK, click_Spin );
function click_Spin(event:MouseEvent):void
{
	if (planet_mc.currentFrame == 1 || planet_mc.currentFrame == 27 ){
		planet_mc.play();
	}
	
}

//------------------btn_selectPlanetSide
btn_selectPlanetSide.addEventListener(MouseEvent.CLICK, click_PlanetSide );
function click_PlanetSide(event:MouseEvent):void
{
	
	if (currentPlanetSide == "front" ){
		var targetURL:URLRequest = new URLRequest("www.google.com"); 
	} else if (currentPlanetSide == "back"){
		var targetURL:URLRequest = new URLRequest("www.google.com");
	}
    navigateToURL(targetURL, "_blank"); 
	
}



I'm currently getting this error:

TypeError: Error #2007: Parameter request must be non-null.
at global/flash.net::navigateToURL()
at PRINT_menu_fla::MainTimeline/click_PlanetSide()

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic Button Problems

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: Dynamic Button Problems

Posted 01 October 2012 - 01:03 PM

It means that your targetURL is null i.e. the control neither enter the if block nor the else block which is turn means that the value of currentPlanetSide is neither front nor back.

Check the value of currentPlanetSide inside the click listener function.
Was This Post Helpful? 0
  • +
  • -

#3 GabeTHEGeek  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 31-August 12

Re: Dynamic Button Problems

Posted 08 October 2012 - 09:18 AM

View Posthcs0112358, on 01 October 2012 - 12:17 PM, said:

I'm working on modifying a current program, and I want to create a button that directs to 2 different URLs, according to user input.

Specifically, there is a movie clip of a planet, and I want to make a button that goes to URL (A) while you see the front side of the planet. When the user clicks a separate button to spin the planet, I want to link to a different URL (B).

Current code:
stop();
var currentPlanetSide;

import flash.events.MouseEvent;
btn_MainMenu.addEventListener(MouseEvent.CLICK, clickMainMenu_btn);
btn_FullScreen.addEventListener(MouseEvent.CLICK, goFull);

//------------------btn_Spin
btn_Spin.addEventListener(MouseEvent.CLICK, click_Spin );
function click_Spin(event:MouseEvent):void
{
	if (planet_mc.currentFrame == 1 || planet_mc.currentFrame == 27 ){
		planet_mc.play();
	}
	
}

//------------------btn_selectPlanetSide
btn_selectPlanetSide.addEventListener(MouseEvent.CLICK, click_PlanetSide );
function click_PlanetSide(event:MouseEvent):void
{
	
	if (currentPlanetSide == "front" ){
		var targetURL:URLRequest = new URLRequest("www.google.com"); 
	} else if (currentPlanetSide == "back"){
		var targetURL:URLRequest = new URLRequest("www.google.com");
	}
    navigateToURL(targetURL, "_blank"); 
	
}



I'm currently getting this error:

TypeError: Error #2007: Parameter request must be non-null.
at global/flash.net::navigateToURL()
at PRINT_menu_fla::MainTimeline/click_PlanetSide()


From the looks of it currentPlanetSide is never set to anything before you make your call in the if statement. That's why you are getting a "null" error.
Was This Post Helpful? 0
  • +
  • -

#4 GabeTHEGeek  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 7
  • Joined: 31-August 12

Re: Dynamic Button Problems

Posted 08 October 2012 - 09:24 AM

View Posthcs0112358, on 01 October 2012 - 12:17 PM, said:

I'm working on modifying a current program, and I want to create a button that directs to 2 different URLs, according to user input.

Specifically, there is a movie clip of a planet, and I want to make a button that goes to URL (A) while you see the front side of the planet. When the user clicks a separate button to spin the planet, I want to link to a different URL (B).

Current code:
stop();
var currentPlanetSide;

import flash.events.MouseEvent;
btn_MainMenu.addEventListener(MouseEvent.CLICK, clickMainMenu_btn);
btn_FullScreen.addEventListener(MouseEvent.CLICK, goFull);

//------------------btn_Spin
btn_Spin.addEventListener(MouseEvent.CLICK, click_Spin );
function click_Spin(event:MouseEvent):void
{
	if (planet_mc.currentFrame == 1 || planet_mc.currentFrame == 27 ){
		planet_mc.play();
	}
	
}

//------------------btn_selectPlanetSide
btn_selectPlanetSide.addEventListener(MouseEvent.CLICK, click_PlanetSide );
function click_PlanetSide(event:MouseEvent):void
{
	
	if (currentPlanetSide == "front" ){
		var targetURL:URLRequest = new URLRequest("www.google.com"); 
	} else if (currentPlanetSide == "back"){
		var targetURL:URLRequest = new URLRequest("www.google.com");
	}
    navigateToURL(targetURL, "_blank"); 
	
}



I'm currently getting this error:

TypeError: Error #2007: Parameter request must be non-null.
at global/flash.net::navigateToURL()
at PRINT_menu_fla::MainTimeline/click_PlanetSide()


To be more specific, you have var currentPlanetSide; which is an empty, and your trying to pass it a string, which you never declared currentPlanetSide as such.
var currentPlanetSide:String = "front";


Than make the call in your if statement.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1