Solved

Newbie AS3 question

Posted on 2009-04-05
8
287 Views
Last Modified: 2013-11-11
I am a newbie with AS3. I am trying to convert my old AS1 and AS2 files to AS3.

I want to create a function that will place movieClips on the stage and add listeners as needed so that they act as buttons. I have a call from a file named "indexAS3.fla" that is the following:
addIndexNavigation("filmInfoButton", "filmInfo", 84.1, 69.1); The name of the .as file is "indexAS3.as" and the code is pasted below.

The name of the first movieClip is: "filmInfo" and the linkage Class is set to "filmInfo", the Base class is set to "flash.display.MovieClip" and the Export for ActionScript and Export in first frame are both checked.

I get the following error message when I try to compile:
1180: Call to a possibly undefined method addIndexNavigation.
package {

	import flash.display.*;

	import flash.events.*;

	import flash.text.*;
 

	public class indexAS3 extends MovieClip {

		private var buttonName, movieClipName:String;

		private var xLoc, yLoc:Number;
 

		public function addIndexNavigation(buttonName:String, movieClipName:String, xLoc:Number, yLoc:Number) {

			//

			var buttonName:movieClipName = new movieClipName();

			buttonName.x = xLoc;

			buttonName.y = yLoc;

			addChild(buttonName);

		}

	}

}

Open in new window

0
Comment
Question by:msukow
  • 5
  • 3
8 Comments
 

Author Comment

by:msukow
ID: 24073006
Originally, my code looked like the following (which is attached), and I wasn't using the "indexAS3.as" file. The code was placed in the first frame.
addIndexNavigation();
 

//----------------------- FUNCTIONS --------------------------//

function addIndexNavigation():void  {

	// constant for position of navigation elements

	var navHeight:Number = 69.1;

	//

	var filmInfoButton:filmInfo = new filmInfo();

	filmInfoButton.x = 84.1;

	filmInfoButton.y = navHeight;

	addChild(filmInfoButton);

	//filmInfoButton.addEventListener(MouseEvent.CLICK,updateDisplay(filmInfo));

	//

	}

Open in new window

0
 

Author Comment

by:msukow
ID: 24073015
And the code worked as expected. The code above was my initial attempt at AS3 code . I think I should use classes somehow for better code practices and flexibility.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24076212
ok so now you've sorted our your error or not?

in terms of using classes - personally i believe it depends if you need it or not. i.e. is this something that has a lot going on; are you going to want to reuse the code at a later stage for something else etc.

0
 

Author Comment

by:msukow
ID: 24076372
I still have the error - just wanted to clarify that I had a working solution without classes, but when I try to implement using classes, I do not. Primarily, I want to make all my code reusable.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 39

Expert Comment

by:blue-genie
ID: 24076675
ok the error means that you're trying to access the method before it exists.

when do you call your method?
0
 

Author Comment

by:msukow
ID: 24106935
Maybe I'm thinking about this all wrong. I have programmed a site (http://www.americanlegacy-themovie.com/) that is a very simple flash AS 1/2 site. I want to re-do the site in AS 3.0 and I want to use only one frame in my .fla file. I also want to use classes as much as possible to program the site. I realize this may not be the most efficient way of doing it, but I really am having problems understanding the transition from 2.0 to 3.0 and think this would be the best way to understand it well. Is there a good link or book out there that would show me how to do this?
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24129050
there's a wealth of information on AS3 on the web - check out the adobe site.
it would probably be best to learn about packages and classes before you go and try and change the code.

it's odd to me how people are suddenly wanting to go and change everything to AS3 - my question is why.
if it was working leave it alone and by all means use AS3 for new projects - but if it ain't broke dont' fix it.
i'm not going to go redo all my old projects to AS3 just because.
0
 

Author Comment

by:msukow
ID: 24220655
The reason I am re-working the code is to get a better understanding of AS3. I understand AS2 well, but am having a hard time updating my thinking to AS3 workflow logic. I am also trying to understand Flex which is obviously non-timeline-based.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML 5 or Flash 7 480
Flash being Disabled - help! 20 338
Advertising design for my own Purpose 5 74
embedding a media live encoder stream 3 119
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now