Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-20-2011, 08:56 AM   #1
tonesofheresy
Registered User
 
Join Date: Nov 2011
Posts: 2
Default Tricky OOP project

Hello,
I'm having a difficult time with a current project I'm working on. I started AS3 at the end of summer and found the transition from AS2 somewhat challenging. I'm fairly comfortable with the language now (to the extent that I require) when it comes to "non-OOP," but I'm trying to switch over to OOP, both for learning and to help the client. A bit of explanation will be needed, though, so bear with me.
I've created a transition effect that requires multiple instances of a movie clip (which I'll refer to as the containers) containing two overlayed images (contents). Each container is on a separate layer of the timeline, and each has as a separate masking layer unique to it. With some actionscript, I then animate various things in various ways to create the desired effect. Now, by doing it "my" way, I would have to create and name a separate SWF for each image. This, however, doesn't allow the client to make any adjustments, so I'm hoping to be able to fragment my code into classes which can then be manipulated dynamically (say, from XML data). My problem is that I have no idea what I'm doing in an OOP sense. I don't want to give away my "secret" animation, but I don't think anyone will be able to help without some better explanation, so here's a breakdown of my timeline (from top layer to bottom):

mask5
container5
mask4
container4
mask3
container3
mask2
container2
mask1
container1

All masks are equal dimension (1/5th the width of the stage) and placed dynamically based on the width/height of the stage (and remain in place). The containers are all identical (same contents), are placed at differing x coordinates (based on the position of their mask and the stage dimensions) and then animated into place. I like the resulting effect, but my client wants to be able to change photos and the sections to which they apply, which cannot be done with the current method. The following are links to a few of the current SWFs that I load into the main movie (and yes, I realize my "secret" will probably be obvious, but I'd still like to effect this using OOP).

vinylwines . com / cooper / backgrounds / contact.swf
vinylwines . com / cooper / backgrounds / events.swf
vinylwines . com / cooper / backgrounds / wines.swf

Any assistance would be much appreciated. Thanks in advance!
tonesofheresy is offline   Reply With Quote
Old 11-20-2011, 02:00 PM   #2
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,683
Send a message via Skype™ to henke37
Default

It is pretty simple, just reimplement the animation in code and then allow the caller to substitute the image. You could even optimize it by using one BitmapData instance for multiple Bitmap instances.

As for how to get the image? Use a Loader. If you need to know what image to get then you could use an URLLoader to load in a settings file. To change the settings for the movie without changing the code and without replacing the config file contents then use a flashparam setting in the embedding code.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 11-21-2011, 01:06 AM   #3
tonesofheresy
Registered User
 
Join Date: Nov 2011
Posts: 2
Default

Hey henke,
I really appreciate your quick response. I'm not entirely sure how to go about doing what you suggest, as I think I built the site in a way that won't allow it. As it stands now, I have a "backgrounds.swf" file that has jpegs (the backgrounds) imported into it. I exported separate versions of the swf with different names with different pictures substituted into the primary image containers. I understand I could use a loader to load the jpeg instead of importing to the library, but the background swf is added to my main clip using a loader/addChild combination, so how can I pass the loaded swf a parameter? Here's a simple scheme of my current process:

Main clip --> link is clicked ---> SWF is loaded ---> SWF is attached to empty movie clip after loading. Unless there's a way to load a SWF and pass it parameters and then track its loading, I may have to rewrite a bulk of my code. Thanks for the help!
tonesofheresy is offline   Reply With Quote
Old 11-21-2011, 03:31 PM   #4
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,683
Send a message via Skype™ to henke37
Default

Then you don't even need to use any flashparam setup. Just call a method on the loaded background movie from the loading movie. It is quite simple since once loaded the loaded movie is just like any other movieclip.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:18 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.