Copy link to clipboard
Copied
I'll try and be clear about my problem. I'm working on a site and have a MovieClip, named "form" on the main timeline that I want to play when a button is clicked. I keep getting this error and it's driving me crazy, I'm obiously missing something. The button instance name is "sub_btn". Below is my code , it's the subscription button code, but not quite sure what's up, I'm not an actionscript guru but am gaining a small understanding of it. If anyone can help that be awesome. Also I have a close button on that movie clip is there a simple close script I can attach. Thanks again.
Dt
stop();
import flash.events.MouseEvent;
var getHCSG:URLRequest = new URLRequest("http://www.houstonceliacs.org");
var twitter:URLRequest = new URLRequest("http://www.dggrafix.com/glutenfree/twitter.html");
// --- Page Button navigation --- \\
home_btn.addEventListener(MouseEvent.CLICK, hClick);
glutenfree_btn.addEventListener(MouseEvent.CLICK, gClick);
menu_btn.addEventListener(MouseEvent.CLICK, mClick);
restaurant_btn.addEventListener(MouseEvent.CLICK, rClick);
contact_btn.addEventListener(MouseEvent.CLICK, cClick);
function hClick(event:MouseEvent):void{
gotoAndPlay("home");
}
function gClick(event:MouseEvent):void{
gotoAndPlay("glutenfree");
}
function mClick(event:MouseEvent):void{
gotoAndPlay("menu");
}
function rClick(event:MouseEvent):void{
gotoAndPlay("restaurants");
}
function cClick(event:MouseEvent):void{
gotoAndPlay("contact");
}
// -- Get URL Button -- \\
supportgrp_btn.addEventListener(MouseEvent.CLICK, hcClick);
function hcClick(event:MouseEvent):void{
navigateToURL(getHCSG);
}
twitter_btn.addEventListener(MouseEvent.CLICK, tClick);
function tClick(event:MouseEvent):void{
navigateToURL(twitter);
}
// --- Subcribtion Button navigation --- \\
sub_btn.addEventListener(MouseEvent.CLICK, clClick);
function clClick(event:MouseEvent):void{
form.play();
}
Copy link to clipboard
Copied
Can you provide the complete error message?
Copy link to clipboard
Copied
Thanks for responding, the full error message is:
Symbol 'Main', Layer 'actions', Frame 1, Line 46 1120:Acess of undefined property sub_btn.
I think I checked that the instance name is correct but just can't get it.
Dt
Copy link to clipboard
Copied
Thanks, Ned for responding the complete error message which I posted
back on the forum is.
Symbol 'Main', Layer 'actions', Frame 1, Line 46 1120: Access of
undefined property sub_btn.
Hope you can help.
Dt
Copy link to clipboard
Copied
in the frame that causes that error to appear, if you click on an empty part of the stage and then click on sub_btn, do you see exactly sub_btn in the properties panel?
if not, that's the problem. if so, post a link to your fla or upload it after changing its extension.
Copy link to clipboard
Copied
Thanks for replying,
yes, sub_btn is the instance name I used for the button. So I'm
assuming that is what you were speaking on. I will post the FLA file
to take a look at. Thanks.
Dt
Copy link to clipboard
Copied
The code for sub_btn looks okay, so it'll be a matter of going thru the usual suspects.
The primary suspect is always the instance name. So if you click on the button on the stage to select it, the instance name in the properties panel needs to be the same as the one you use in the code. If there's any doubt, actually change the name in both places just to insure it's the same.
Another suspect regards the location of code versus the location of the object. Is sub_btn present in frame 1?
Along a similar line, targeting can sometimes be the issue... is sub_btn a standalone object, not contained in some other object?
If none of these lead to a resolution, can you make the fla file available for a look-see (I'm limited to Flash CS3 and below though).
Copy link to clipboard
Copied
Ned, thanks for replying again. I don't think it's the instance name,
that was the first thing I checked. They are both the same. It maybe
what you said about where it's located. The form that I want it to
open is on the main timeline but the button itself is inside another
movieclip on the timeline.
I'm going to try and post the FLA file so you can have a look, Thanks.
Dt
Copy link to clipboard
Copied
Can you send me an email address, I wanted to post my FLA file for you to take a look but the max size is 5 MB and my file zipped is over that so it's not going to post. Please send me an email that i can send it to you directly. Thanks
Dt
Copy link to clipboard
Copied
I suggest you strip the file down of unrelated content so that you can post it somewhere. I don't hand out my email for having files sent to me--making it available to the general public is to your benefit. I may not be around to look at it, but someone else may.
Copy link to clipboard
Copied
Thanks, I will do that.
Dt
Copy link to clipboard
Copied
I'm going to post my native FLA file in a little bit. Ned, I noticed you mentioned it may be the location of the code, I have the code on the main timeline where the movieclip I want to open i, the button sub_btn is actually inside another movieclip on the maintimeline. Should the code be in the same movieclip as the button. Which may go along with the other thing you mention, targeting. Do I need to make reference of the parent of the button, or the movieclip the button is housed in?
Thanks.
Don
Copy link to clipboard
Copied
Yep... targeting may be the problem. You don't necessarily need to have the code in the movieclip that the button is in. You can target the code for the button from the maintimeline if you preclude it with the instance name of the movieclip it's sitting in...
movieName.sub_btn.addEventListener....
Copy link to clipboard
Copied
Ned, I think that may be the case, I didn't preclude it with the movie clip it's in. I'm going to try that and I will let you know.
Dt
Copy link to clipboard
Copied
Hey Ned,
You're the man!! That bit of advice worked liked a charm, it was the targeting. It really cleared up a lot of things for me too, now I know. Once again thanks for your help.
Don
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
I'm having a similar problem. I have in my project four flv video inside of a movieclip. I have a custom play/pause buttons for each of the four vids (well one generic playBtn & pauseBtn, instance names different for each vid on the generic play/pause buttons) The actionscript I have to play/pause video is this:
fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);
function pauseHandler(e:MouseEvent):void{
fishyVid.pause();
}
function playHandler(e:MouseEvent):void{
fishyVid.play();
}
This works fine & it stops & plays the video when there are pressed. But when I use the same script on other video it doesn't work I get this:
function pauseHandler(e:MouseEvent):void{ when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted
function playHandler(e:MouseEvent):void{ when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted
I then renamed the pauseHandler & playHandler to pauseHanddler_B, playHanddler_B, this stops the above error but it doesn't pause or play another
video, I get this message in the output panel:
I've tired scripting all the buttons to play & pause the video's in one script like so:
fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);
mashedPauseBtn.addEventListener(MouseEvent.CLICK, playHandler)
mashedPlayBtn.addEventListener(MouseEvent.CLICK, playHandler)
function pauseHandler(e:MouseEvent):void{
fishyVid.pause();
mashVid.pause();
}
function playHandler(e:MouseEvent):void{
fishyVid.play();
mashVid.play();
}
I've tired putting the script at each section in the timeline where the video is playing and it doesn't work it will pause & play one of the videos. Can anybody bring me out of the darkness, please I'm going mad by this! Thanks
Copy link to clipboard
Copied
Ned, this totally saved my butt on a school project where I had my buttons moving in a movie clip file.
Thanks bro!
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
hello, im having a problem in my project i want to make a start menu and a game over, but ive been stuck on many issues can you help me with it, here's my actions till now:
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
Mouse.hide();
var score:Number=0;
var layer1:MovieClip = new MovieClip();
var layer2:MovieClip = new MovieClip();
stage.addChild(layer1);
stage.addChild(layer2);
var myShip:Ship = new Ship();
layer2.addChild(myShip);
var myCoinsArray : Array = new Array();
var myAsteroidsArray : Array = new Array();
var myBonusCoinsArray : Array = new Array();
for(var i:int = 0; i < 10; i++){
var myCoin:Coin = new Coin();
myCoin.x = Math.random() * stage.stageWidth;
myCoin.y = Math.random() * stage.stageHeight;
layer1.addChild(myCoin);
myCoinsArray.push(myCoin);
}
for(var f:int = 0; f < 3; f++){
var myAsteroid:Asteroid = new Asteroid();
myAsteroid.x = Math.random() * stage.stageWidth;
myAsteroid.y = Math.random() * stage.stageHeight;
layer1.addChild(myAsteroid);
myAsteroidsArray.push(myAsteroid);
}
for(var g:int = 0; g < 1; g++){
var myBonusCoin:BonusCoin = new BonusCoin();
myBonusCoin.x = Math.random() * stage.stageWidth;
myBonusCoin.y = Math.random() * stage.stageHeight;
layer1.addChild(myBonusCoin);
myCoinsArray.push(myBonusCoin);
}
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(e:Event){
myShip.x = mouseX;
myShip.y = mouseY;
Scoretext.text=score;
for(var i:int = 0; i< myCoinsArray.length; i++){
if(myShip.hitTestObject(myCoinsArray)){
if(layer1.contains(myCoinsArray)){
layer1.removeChild(myCoinsArray);
//increase the score
score++;
//Display the score in the text field
//Scoretext.text=score;
}
}
}
for(var f:int = 0 ; f< myAsteroidsArray.length; f++){
if(myShip.hitTestObject(myAsteroidsArray
if(layer1.contains(myAsteroidsArray
layer1.removeChild(myAsteroidsArray
//decrease the score
score-=3;
//Display the score in the text field
//Scoretext.text=score;
}
}
}
for(var g:int = 0; g< myBonusCoinsArray.length; g++){
if(myShip.hitTestObject(myBonusCoinsArray
if(layer1.contains(myBonusCoinsArray
layer1.removeChild(myBonusCoinsArray
//increase the score
score+=5;
//Display the score in the text field
//Scoretext.text=score;
}
}
}
}
Copy link to clipboard
Copied
pleas start a new discussion as it's a new issue thanks
Copy link to clipboard
Copied
Hi.
There is an error in this line:
Scoretext.text = score;
The text property expects a string. So it should be something like:
Scoretext.text = String(score);
Is there any other error you're getting? What are you not being able to accomplish?
Regards,
JC
Copy link to clipboard
Copied
Hi,
I also have almost similar problem to this. Mine is going to a frame "reservationpage". I set a button on frame 3 in "treatmentspage" that should call on "reservationpage" in frame 8.
I have been using this code:
myreserve_btn.addEventListener(MouseEvent.CLICK, onReservClick);
function onReservClick(evt:MouseEvent):void {
gotoAndStop("reservation page");
myreserve_btn.removeEventListener(MouseEvent.CLICK, onReservClick);
}
but keep getting:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SpaLuvicebestmassageoptionintown_fla::MainTimeline/frame3()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at SpaLuvicebestmassageoptionintown_fla::innnerbody_25()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::MovieClip/gotoAndStop()
at SpaLuvicebestmassageoptionintown_fla::MainTimeline/bodymassagebtn_clicked()
can I get help on this please?