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

Adding action script to instances...

Community Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

I'm pretty frustrated and am done searching the site. Awful...just awful. Anyway...

Using Flash CS3 for the first time since upgrading. I'm not able to add action script to instances. Certainly this isn't a change. I've created a button symbol. I've named the instance upon dragging it on the stage. Now it tells me I can't apply actions to it.

I hope I'm just missing a step.
TOPICS
ActionScript

Views

3.2K

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

How are you applying actions?

Votes

Translate

Translate

Report

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
Guest
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

You're not missing anything. In AS3 with CS3 and CS4 this feature has been removed from Flash. Yes, it sucks.

If you want to continue using AS3, you will need to give the button an instance name, and assign an action on the timeline which will look something like this:

myButton.addEventListener('click',myButtonClick);
function myButtonClick(event){
// do stuff
}

Frankly, you probably want to just use AS2. You can set this in the publish settings or when creating a new document, choose the option which says "Flash File (ActionScript 2.0)"

Votes

Translate

Translate

Report

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
Guest
Jan 24, 2012 Jan 24, 2012

Copy link to clipboard

Copied

LATEST

>>Yes, it sucks.

No, it doesn't. It was poor style to ever do that and good developers didn't anyway. Now, you're forced to produce cleaner code, as it's more consolidated, and not scattered over a bunch of objects.

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Is there a reason why they went away from the VERY EASY method of applying actions to instances?

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Bloom, are you talking about writing actions INSIDE the symbols? If so - they went with a more robust approach of writing classes for the symbols. It takes not such a big effort to change the ways. In essence it is the same thing but gives one much bigger flexibility.

Also, are you familiar with AS3 event model?

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Andrei, I'm willing to learn, but most of my use is recreational so using 2.0 isn't a big deal. (Of course I'm having troubles getting it to work too.) It's just been awhile.

I am not familiar with the AS3 event model. I am talking about clicking on an Instance and being able to apply actions to it.



Meanwhile, I'm trying to apply the following using AS2:

on (rollOver) {stageRoster.loadMovie("playerMovies/hahnJordan09.swf");
}

This doesn't appear to be working AS2. I have my stage instance labeled, and I have my external SWF file uploaded.

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

As abeall said you need to indicate to CS3 that you use AS2

When you refer to an instance in AS2 on the time line where the instance is
you code should be:

myButton.onRollOver = function()
{stageRoster.loadMovie("playerMovies/hahnJordan09.swf");}



Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

As abeall said you need to indicate to CS3 that you use AS2

When you refer to an instance in AS2 on the time line where the instance is your code should be:

myButton.onRollOver = function() {stageRoster.loadMovie("playerMovies/hahnJordan09.swf");}

Your original code should work from withing the instance in AS2. But you will have to change reference to stageRoaster if it is located on the main timeline.

Votes

Translate

Translate

Report

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
Guest
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Andrei1, Bloom is not referring to class/symbol-definition code, but instance code. There is no IDE solution as of CS3 and CS4 for AS3.

Bloom, are you sure the path is correct? Note that the path "playerMovies/hahnJordan09.swf" is relative to the embedding HTML page, not the swf.

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

I made the change in the path, but it's still not working. The code now reads:

on (rollOver) {stageRoster.loadMovie("roster/2011/playerMovies/hahnJordan09.swf");
}


Here is the PHP page in question:

http://spieceselect.org/roster/2011/index2.php

Click on Jordan Hahn's name. It's the only one I've done so far.

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

I made the change in the path, but it's still not working. The code now reads:

on (rollOver)
{stageRoster.loadMovie("roster/2011/playerMovies/hahnJordan09.swf");
}


Here is the PHP page in question:

http://spieceselect.org/roster/2011/index2.php

Click on Jordan Hahn's name. It's the only one I've done so far.



Votes

Translate

Translate

Report

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
Guest
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Bloom,

I think you had it right the first time, I just didn't know where you had your files and it's a common misunderstanding. But the correct relative url should indeed be "playerMovies/hahnJordan09.swf"

If you want to try an absolute url you can use "/roster/2011/playerMovies/hahnJordan09.swf"

Are you sure stageRoster is correct? What happens if you do this:
on (rollOver){
trace(stageRoster);
stageRoster.loadMovie("playerMovies/hahnJordan09.swf");
}

Andrei1, MovieClip.onRollOver is not the syntax Bloom is using, in AS2 you can attach code directly to symbol instances using the on() and onClipEvent() syntax (not putting the code in the timeline.)

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

So if I do what Andrei says, it should be using AS3, correct?

Right now I'm set up to use AS2.


Abeall,

Right now I have 2009.swf on the linked page. It's in the folder roster/2011. The hahnJordan09.swf is located at roster/2011/playerMovies.

I had already changed my path to the absolute /roster/2011/playerMovies/hahnJordan09.swf.

stageRoster is the name of the symbol AND instance. I changed the name of the instance to stage_Roster (in the script too), but none of it worked.

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: Bloom
So if I do what Andrei says, it should be using AS3, correct?




No, what I suggested was AS2 code. This code is used when onRollOver functions is assigned to your button on the main timeline.

Since you are using the on(rollover) from withing the instance and if stageRoaster is located on main timeline - you need to change the scope of stageRoaster. It either can be _root or _parent:

on (rollOver) {_root.stageRoster.loadMovie("playerMovies/hahnJordan09.swf");
}

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: Andrei1
quote:

Originally posted by: Bloom
So if I do what Andrei says, it should be using AS3, correct?




No, what I suggested was AS2 code. This code is used when onRollOver functions is assigned to your button on the main timeline.

Since you are using the on(rollover) from withing the instance and if stageRoaster is located on main timeline - you need to change the scope of stageRoaster. It either can be _root or _parent:

on (rollOver) {_root.stageRoster.loadMovie("playerMovies/hahnJordan09.swf");
}




The _root addition didn't solve the problem, but it made sense to me. : )

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

I was getting ready for dinner and Roster become Roaster. Hmmm... :-)

Anyway, where is the stageRoster (or Roaster or Grill) relative to the button?

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Right now my code is place within the Instance.

on (rollOver) {loadMovie("/roster/2011/playerMovies/hahnJordan09.swf",stageRoster);
}

Votes

Translate

Translate

Report

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
Guest
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Did you try the trace command? This will put something in your Output window when you test in Flash, telling you if the reference stageRoster/stage_Roster is correct.

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

I just did. No change. It just does nothing.

Votes

Translate

Translate

Report

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
Guest
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

If it does nothing at all then your code is not attached at the time you are rolling over the button. How many keyframes do you have for the button?

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: abeall
If it does nothing at all then your code is not attached at the time you are rolling over the button. How many keyframes do you have for the button?


Aaron, not sure what it means to not be attached. Right now I just have one keyframe with ten layers. One layer for my stage (stage_Roster) and nine layers for the players. I put the code in the Actions panel within the Instance.

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

stageRoster and button_jh are on main timeline.

Votes

Translate

Translate

Report

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 Beginner ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

It's frustrating still. I'm doing it exactly as I have seen in other resources, including a couple of other sample here. I have everything set up properly, in terms of using AS2. I have files uploaded. I have tried various different pathways.

Votes

Translate

Translate

Report

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 ,
Dec 25, 2008 Dec 25, 2008

Copy link to clipboard

Copied

Can you try:

on (rollOver) {
trace("_root.stageRoster: " + _root.stageRoster);
trace("_parent.stageRoster: " + _parent.stageRoster);
}

What is the output?

Votes

Translate

Translate

Report

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