Flash 5/MX vs Flash 4 code

I don’t know if anyone else is in my shoes, but the change in Actionscripting from Flash 4 to 5/MX has left me in the dust. Just as I was becoming quite comfortable with ‘Tell Target’,etc, Macromedia went and changed eveything to ‘Root’ and ‘This’ and ‘_Parent’!!! I’ve been trying for a long time to learn how to do the simplest of tasks with the newer coding, and I can’t even get a button to work! Macromedia’s Help Files are pitifully difficult to understand, and I haven’t to date found a tutorial on how to do what we used to do with ‘Tell Target’ with the new code (i.e., programming a button, or controlling MCs with buttons). :-\

If anyone’s willing to post a simple tutorial or explanation, I would be eternally grateful.

Thanks! :slight_smile:

Check out ilyaslamasse’s tutorial on AS tricks. It should give you the lowdown on at least SOME of the new things in Flash 5/MX

http://www.kirupa.com/developer/actionscript/as_tricks.asp

as for tellTarget, yeah, it is out the door. I just found that out, I was still using tellTarget in Flash MX, until I learned the other way.

Good ol’ Iammontoya taught me this

Your old tell target code looks like this …

 
on (release) {
    tellTarget ("_root.yourMC") {
        gotoAndPlay(1);
    }
}


The new tell target code will look like this…


on(release){
  _root.yourMC.gotoAndPlay(1);
}


Wher yourMC = the movie clip instance name.

I think this is much simpler. The _root just tells Flash that the movie clip is on the MAIN stage.

Hey,

In regards to your telltarget comment, there’s another way of doing that too that’s pretty similar.

code:EG1

on (rollOver) {
tellTarget(“mymovie1”) {
gotoAndPlay(1);
}

}


code:EG2

on (rollOver) {
with(mymovie1) {
gotoAndPlay(1);
}
}

code:EG3

on(release){
_root.yourMC.gotoAndPlay(1);
}


It’s always good to be up on the most current thing. Having said that, there’s plenty of ways to do whatever it is you want. There are a lot of tutorials on www.kirupa.com that I’m sure could help you out with learning the new arguments/methods. But you can always stick with what you know best.

Have a good one,

Uth

I like the last one better, its shorter…lol.

I think that there are no clip handlers in FLash 4. You had to loop ‘manually’… Arghh!!

pom :asian:

Wow, I am glad I never tried Flash 4, if I did I probably would have never wanted to use Flash again.

I’d like to thank everyone for your prompt and excellent advice. I’ve been digging through help files and websites for weeks now, coming up empty. I think this will really help!

Sorry it took me awhile to respond, the Thread notifications got sent to my junk-mail by mistake.

Glad to know other people are battling the ‘TellTarget’ problem. After your guys’ explanations, I think it’s making more sense.

One more thing I’ve never really understood about Levels; I’m very clear on how loading swf’s works (Base = Level 0,etc)…but say you have a button inside a MC, which is placed on the stage. If you want the button to affect the timeline of the mainstage (say GoTo…or something), what level is the mainstage? Do you use that _parent/_child stuff to go up 2 levels? What level is the button on? Does this make sense (I know these kind of questions are hard to convey…)?

Thanks again for your help, I’ll post a link to the site I’m doing when I’m done!

Here is the way to remember root and parent

_root is an absolute reference starting at the main timeline.

ie: _root.gotoAndPlay(2) will take you to frame 2 main timeline:
_root.someclip.gotoAndPlay(2)
takes you to frame 2 of someclip nested in the maintimeline.
You can do this for as many nested clips you have for any property or action/method or homemade functions, not just gotoAndPlay.

ie:_root.clip1.clip2.clip3.clip4.clip5._alpha=50 sets the alpha of clip5 (which is in clip4, clip4 is in clip3,clip3 is in clip2, clip2 is in clip1 and clip1 is in the main timeline) to 50%.

_parent is relative reference.
ie: if your in clip1 targeting clip2 both of which are on the same level (both in the main timeline or the same movieclip) then you would use:
_parent.clip2.gotoAndPlay(2)
(you go up out of clip1 and down into clip2)

similarily you can do this as many times as you want:
ie: _parent._parent._parent.clip2 will take you 3 levels up and into clip2
Sorry but there isn’t a _child reference just _parent

You can use either way, most people like to use relative because absolute references can be difficult to fix if you start changing your movie around. A simple analogy is to compare it to driving directions. If your discribing your neighbours address its easier to say he lives 2 houses down (possibly _parent.house2), but if your giving directions to your aunt on the other side of the country it may be easier to give the exact address (_root.city.street.housenumber)

This became a rather lengthy explaination on root and parent, I hope it is easy to understand.

Sniggins

Dude! That was an excellent explanation. Thank you very much!

I’m still a little fuzzy on the parent explanation, though:

**ie: if your in clip1 targeting clip2 both of which are on the same level (both in the main timeline or the same movieclip) then you would use:
_parent.clip2.gotoAndPlay(2) **

is _parent clip1? Or is it moving the the action a level up, like you used to have to do with " TellTarget…/ "? I think that’s what you mean, because you’re saying that you can use _parent to keep going up levels.

One other thing (to you or anyone); are these scripts easy to select in the Actionscript Browser, or do you have to hand-code all this stuff? It seems to be getting harder and harder to insert code in Flash, especially with the collapsing, Tree-Folder Structure in MX.

I’ll try this stuff out, that was a great explanation.
Thanks again, Sniggins. :slight_smile:

For your first question:
_parent moves you up on level. So in my example clip1 and clip2 are in the main timeline, if you start in clip1 _parent moves you to the main timeline then adding the .clip2 moves you into clip 2.

For Question #2
I find its tough to get the structure down if your in normal mode, since you have to find _root and _parent in the browser before you add the other stuff. I, myself, use expert mode if I have to target outside my current clip. You can use normal mode, or the browser in expert mode to find the actions you’d like to insert then once inserted you can edit the targets in expert mode, this often works well for me. After a while I got use to the structure of the actions/methods and properties I used most often and found using expert mode and typing in the code was often the quickest. I then check with normal mode to make sure my syntax is right, or if I forget the order of the parameters and such.

Hope this helps

Sniggins

So if you are using Slash Syntax (which went out with Flash 4, but is used in HTML) parent would look like this “…/”

… = go back a directory / in flash case it would be go back a clip
/ = enter another directory / in flash it would be enter another clip

thanks again, Sniggins and lostinbeta!

It’s funny; I’m clear on your explanations now, I understand _parent replaces “…/” - but I tried experimenting yesterday, and I kept getting Syntax warnings on output! Then I tried using the 'ol deprecated Tell Target, and it did the same thing in a fraction of the time! Geuss I just have to get used to hand-coding more, instead of relying on Flash to insert its pre-written snippets. Oh well.

Thanks a million, everyone.