Jump to content
Search Community

Strategy for working with TweenLite/Max in AS2

Gary Horsman test
Moderator Tag

Recommended Posts

When I first started learning ActionScript, the advice I received was to start in version 3.0. It is indeed a better implementation and far more efficient to work with.

 

But now my understanding of AS2 is fairly rudimentary, since I skipped over it. This is a problem since I need to publish some Flash web banners that are compatible with clickTAG tracking that works in AS2 only.

 

With AS3, it's so easy to centralize all the code in one place to control everything on the stage. But if I need to work with AS2, what would be the most efficient strategy for doing this? As far as I understand, in order to tween an object with scripting, the AS code needs to be added to the object itself, not in an external frame on a separate layer. Do I need to put all my objects on the stage on one layer or each on their own layer and separately control them each with their own ActionScript code scattered around the timeline? Is that the best way?

 

I've looked through these forums, but it's not clear how to best make this a pain-free process. Where does the code go? Where do the objects go? Do I hide them until their time to show up in the sequence of animations? Do I use delays to make each animated sequence play in succession? Should I use onComplete callbacks to make them play one after the other?

 

Any basic explanations for strategies would be appreciated. Thanks!

Link to comment
Share on other sites

You can take a similar external AS approach even with AS2 scripting. A method I use is to create a 'holder' movieclip and set a linkage option of that clip to an external AS2 file. You can then place all your movieclip assets into that holder or 'shell' and work with objects just as you would with AS3 from there.

 

Heres a simple AS2 banner add example if you want a look see:

Link to comment
Share on other sites

Looking over your files really helped me understand the method.

 

I apologize if the post turned out more to be about implementing external AS files in AS2 rather than a real discussion about the Greensock libraries. But it really puts everything into context for me.

 

And its great that you have that button on the other layer where I can plug in the clickTag script for my own purposes. I think this was just what I needed.

 

I appreciate your help. I'm just hoping the web publishers will accept my files when they're done.

 

Much thanks!

Link to comment
Share on other sites

Spoke a little too soon. I believe I followed the basic structure of the file you sent me, by placing all the elements inside its own MovieClip instance and then linking to an external ActionScript file. But when I test it, it doesn't work. All the elements are just sitting on the stage doing nothing.

 

Maybe I messed up somewhere. Could it have something to do with the classpath? I see from your file that you work in Windows. I'm on a Mac and I'm not sure where the classes are for AS2 on my hard drive. I'm working with Flash CS5. Could that be the issue?

 

Or maybe there's something wrong with the linkage to the external AS file?

 

I'm attaching the FLA and AS files so you can take a look and see what I've done wrong. Thanks!

 

http://dl.dropbox.com/u/4289569/janeeyre_test.zip

Link to comment
Share on other sites

I see the problem,

 

You turned your assets into movieClips inside your shell Movieclip, but you need to give them instance names. And they have to be the same names that you called them in your as2 file, only then will the link between the external ascode and the objects inside the shell work.

Link to comment
Share on other sites

Thanks Zync. While scanning around, I did notice that those instance names were missing. When I added them, the animation worked perfectly.

 

Thanks a million!

 

One more issue, though. I'm not sure if this is a greensock issue. I uploaded the AS2 SWF with all the animations to our company Flash server. Then I open up a container file which is used for discrete downloads of SWFs. Pardon me if you're already familiar with this, but in order to stay under the 40 Kb limit imposed on Flash ads, we use a container SWF to import the animated SWF from our server. That keeps the file small (cheating, I know).

 

The container SWF has all the clickTag scripts and other scripts for debugging and adapting to different Flash ad publishers.

 

When I test the container SWF with the import of the animated SWF, I get that darned Security Sandbox Violation, saying the imported SWF is trying to access the SWF I'm testing locally on my hard drive. I know the solution is to add the System.security.allowDomain() method with the domain written as the argument. Problem is that the container SWF already has this script in place. The error only pops up with the SWF that was animated with the greensock tweening library. I've tested with other SWFs and no error is triggered.

 

Is there an issue with your methodology when it comes to cross-domain access that might prompt this error? Why isn't the script in our container SWF working to avoid this?

 

This is the last leg in my pursuit to forever rid myself of the obligation to work in the timeline just to make my Flash ads work with these publishers' antiquated specs.

 

The container FLA is here if you'd like to look over it. The animated SWF is already posted to our Flash server.

 

http://dl.dropbox.com/u/4289569/janeeyr ... st_con.fla

Link to comment
Share on other sites

Here's something odd. I decided to test out yet another SWF using the Greensock code in an external .as file just as you'd prescribed. I uploaded the animated SWF to an external server, imported it with the container FLA (with all that clickTag scripting) and tested it locally on my hard drive. As before, I received the security sandbox violation.

 

On a lark, I thought I would try uploading the external .as file into the same directory as the animated SWF on the remote server. I didn't think it would work since a compiled SWF is a compiled SWF, right? The .as file shouldn't be imported at runtime.

 

Guess what? The error went away. It's as if the SWF on the remote server was looking for the .as file on my hard drive at runtime. But put it in with the SWF, and it's no longer going outside its own domain. Am I missing something? Do SWFs with external .as files which link to tweening libraries import that data at runtime?

 

For now, I'm glad it's worked out. But it runs against what I've so far learned about compiled SWFs.

 

Ideas?

Link to comment
Share on other sites

Hmm yeah that sounds really weird indeed. A compiled swf should be a compiled SWF with all the AS code embedded although I haven't worked with As2 is a fair while in regards of loading another SWF into a container SWF for ad distribution. I used to make ads for the Eyeblaster network if your familiar with that. Anyways glad you got it working. The code all seems fine.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...