From which file are you trying to access that function?
Did you put the function on your main timeline or on a timeline of a movie clip?
It’s really hard to tell something without seeing your code and project structure.
Im accessing the function from my class file. The function is on my maintimeline…when i ‘trace(root)’ it returns MainTimeline so i thought root.test(); may work but no luck?
MovieClip(parent).test(); didnt work.
I will try the other method listed when i get back to the office just out grabbing some lunch. thanks for the help will let u no how i get on. cheers
function eventHandler(e:Event):void
{
switch(e.type)
{
case "CALL_TEST":
test();
break;
}
}
Using a switch statement allows you to have many events listened for on many classes and deal with them all within the one handler Just add more cases for more events…
Make sure your class imports Event and extends eventDispatcher, Sprite or MovieClip so you can dispatch events
Its also best to use enumeration classes rather than hand typing the strings as I did but it should work
function eventHandler(e:Event):void
{
switch(e.type)
{
case "CALL_TEST":
test();
break;
}
}
Using a switch statement allows you to have many events listened for on many classes and deal with them all within the one handler Just add more cases for more events…
Make sure your class imports Event and extends eventDispatcher, Sprite or MovieClip so you can dispatch events
Its also best to use enumeration classes rather than hand typing the strings as I did but it should work
dude that is sick but im even having trouble just getting your snippets of code to work there, any chance u could whip a working version up for me in a zip file…would be much appreciated
dude i uploaded the .fla and class you used in your example. it doesnt work?
The reason it is not working is that you assigned MyClass as the document class of the FLA. If you are assigning a document class, then you are not supposed to put your code in the timeline. Only in the document class.
Stop putting AS3 code on your timeline. It's not a good AS3 coding practice. Use external AS files. Use linkage option in your movie clips.
I didnt know this- Thanks for the tip. quick question tho, so if i put all AS in its own AS folder can i put that folder in an assets folder in my library?
many Thanks,
Luciano
PS . also say i am encoding an AS3 mp3player which I am doing currently, Is it still best practice to include the AS as seperate files? Or In certain cases is it best practice to still use the timeline?
again Thankz In Advanze.
Luciano
dude i uploaded the .fla and class you used in your example. it doesnt work?
The reason it is not working is that you assigned MyClass as the document class of the FLA. If you are assigning a document class, then you are not supposed to put your code in the timeline. Only in the document class.
shit dude your right. thanks allot for the help man.