Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

assigning script to symbols - new user

New Here ,
May 25, 2015 May 25, 2015

Hi,

I used to use flash mx 2004, can not believe it was over 10 years ago. I got really into making games at the time and recently realised I want to use flash for a project im working on. Tried installing my old program but its not very well supported on windows 8 understandably, so i got CC.

My question is really about how you can write actionscript. in the old version you could write script on frames or on symbols. so for buttons I would select the symbol and the actionscript panel would show different code to the frame, then everything you wrote would be related to this button, eg.

on (release) {

     stop();

}

i cant figure out how to do this in the new version, has it all been moved to the frame?

so in that case would you write something into the frame that is along the lines of:

buttonname.on (relase) {

     stop();

}

thanks for the help! i am asking really because i drew out how i plan to make my project based on using symbol - assigned script, and changing method will be a bit of work. does it make sense to write all the code into a separate layer with only one keyframe?

all the best,

Andy

TOPICS
ActionScript
196
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2015 May 25, 2015

:

buttonname.addEventListener(MouseEvent.CLICK,buttonF);

function buttonF(e:MouseEvent):void{

stop();

}

p.s. it's best to use class files. ie, it makes things easier to edit if you use class files. but that's a big change for you so if you're going to add code to timelines, it's best to limit the location(s) of your code.  except for stop(),play() and goto's one layer of one frame is the 2nd best.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2015 May 25, 2015
LATEST

The CC version of Flash does not support the version(s) of Actionscript you are familiar with.  Flash CC only supports Actionscript 3.  In AS3 you can only have code in the timeline or in separate AS files.

The equivalent code for what you show would be...

buttonname.addEventListener(MouseEvent.CLICK, stopTimeline);

function stopTimeline(evt:MouseEvent):void {

    stop();

}

The user-named elements of that code are shown as blue text.  The rest is AS3 code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines