trying to understand classes having a hard time
I think I understand document class and the class that is directly connected to a movieClip. So I have a list of questions about other classes. In order to show this I have a sample code that I edited and stole from a tutorial. It is not connected to a movieclip or the document class. I did nothing but get a new .as file and put the code below and have it in the same folder as the swf. The code for the SWF is the bottom code which communicates with the .as file.
1. why does ColorThis(mov2,2222222) not work?
but this work
var author:Name = new Name();
author.SetFirstName("Charles");
author.SetLastName("Dickens");
trace(author.GetFullName());
but if I put ColorThis(mov2,2222222) document class it works? but it doesn't seem that useful there because
it would clutter up too fast
Call to a possibly undefined method ColorThis through a reference with static type Class.
I tried this too
//Name.ColorThis(mov2,2222222)
2. why wouldn't I put import Name at the top of the timeline
and if I move out of the main folder why won't import myfolder.Name work?
3. can I add multiple classes to a single MovieCLip and how would I go about this?
4. Is oop really better?
package {
import flash.display.MovieClip;
import flash.geom.ColorTransform;
import flash.display.MovieClip;
public class Name2 {
private var firstName:String;
private var lastName:String;
public function Name2() {
// constructor code
}
public function SetFirstName(val:String):void
{
firstName = val;
}
public function SetLastName(val:String):void
{
lastName = val;
}
public function GetFullName():String
{
return firstName + " " + lastName;
}
public function ColorThis(Pmov:MovieClip,mycolor:Number):void {
var newColorTransform_2:ColorTransform = new ColorTransform();
newColorTransform_2.color = mycolor;
Pmov.transform.colorTransform = newColorTransform_2;
}
}
}
//////////////////////////////////////////////////////////
/////this code is from the timeline/////////////////////////
//import Name
var author:Name = new Name();
author.SetFirstName("Charles");
author.SetLastName("Dickens");
trace(author.GetFullName());
//Name.ColorThis(mov2,2222222)
ColorThis(mov2,2222222)
