Reputation: 21934
I'm creating a slideshow where each slide can have: - a video or a still - 1 audio track or many (up to 3) - 1 button or many (up to 3)
I was thinking that each slide can be it's own object, and then I would pass the video, audio, buttons, etc., into it as parameters:
package
{
import flash.media.Video;
public class Section
{
public function Section (video:Video, still:myPhotoClass, audiotrack:Sound, button:myButtonClass) {
// can have video OR a still
// can have 1 audio track or several
// can have 1 button or more
}
}
I'm not sure how to go about approaching this since there can be multiples of certain items (audio, buttons) and also two items are sort-of-optional in the sense that there can be ONE or the OTHER (video/still).
For example, is this something that I should just avoid passing as parameters altogether, using a different approach (getters/setters, maybe)?
Upvotes: 1
Views: 1231
Reputation: 1193
private var _optionalParam:Array;
public function exOptionalParam(arg1:Number, ...optionalParam) {
_optionalParam = optionalParam;
trace(_optionalParam ); // [all the additional arguments]
}
Upvotes: 1
Reputation: 1
Let's see how this goes:
You can add all of your parameters and set them to null so they aren't needed, eg: video:Video = null, still:myPhotoClass = null, audiotrack1:Sound = null, audiotrack2:Sound, audiotrack3:null, button1... etc (Simple test worked)
Or just pass an array for the ones with multiple items, or a vector of the right type.
Upvotes: 0