Hi! I'm trying to figure out the best way to target a Sprite I'm generating within my custom class. I have a class that I call several times to create groups of a photo and headlines. Later in my movie I want to target the headline of one of these groups so I can make it disappear and add in a new Sprite in it's place. Here's the code:
Code:
package Embassy
{
import flash.display.*;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.text.TextFormat;
public class Landscape extends Sprite {
private var format1:TextFormat = new TextFormat();
private var format2:TextFormat = new TextFormat();
private var _c1;
private var _headlineMC;
private var _subheadMC;
public function Landscape(c1:Class, _headline:String, _subhead:String) {
//adds all the MCs to the list
_c1 = new c1();
_c1.x = _c1.x - (_c1.width/2);
_c1.y = _c1.y - (_c1.height/2) + 42;
addChild( _c1);
//positions the headline
_headlineMC = new hotelHeader();
_headlineMC.x += 340;
_headlineMC.y-=115;
_headlineMC.alpha = 1.2;
_headlineMC.textValue.text = _headline
_headlineMC.textValue.autoSize = 'right';
format1.letterSpacing = .6;
_subheadMC = new hotelSubhead();
trace(_subheadMC.name);
//adds the headline to the stage
addChild(_headlineMC);
//adds the subhead to the stage
_headlineMC.addChild(_subheadMC);
_subheadMC.textValue.setTextFormat(format1);
_subheadMC.y += 22;
//_subheadMC.x += 2
_subheadMC.textValue.text= _subhead
//sets the tracking
format2.letterSpacing = 1.;
_subheadMC.textValue.setTextFormat(format2);
_subheadMC.textValue.autoSize = 'right';
}
}
}
It's the "_headlineMC" that I need to target later on. I'm feeding in class names to generate the photos from an array in my main movie, as well as String values from another Array in the main movie. Later on I need to target the "_headlineMC" of a particular instance of my custom class. Here is the code in my main movie that makes all these instances of "Landscape" :
Code:
var largeLandPhotos:Array = [landscape_lg_tahoe,landscape_lg_concord,landscape_lg_deerfield,landscape_lg_delMar,landscape_lg_greenville,landscape_lg_losMarlins,landscape_lg_mandalay,landscape_lg_myrtle,landscape_lg_waikiki]
var largeLandHeaders:Array = [];
largeLandHeaders[0] = "Embassy Suites® Lake Tahoe"
largeLandHeaders[1] = "Embassy Suites® Charlotte - Concord"
largeLandHeaders[2] = "Embassy Suites® Deerfield Beach"
largeLandHeaders[3] = "Embassy Suites® Dorado del Mar"
largeLandHeaders[4] = "Embassy Suites® Greenville"
largeLandHeaders[5] = "Embassy Suites by Hilton™ Los Marlins"
largeLandHeaders[6] = "Embassy Suites® Mandalay Beach"
largeLandHeaders[7] = "Embassy Suites® Myrtle Beach"
largeLandHeaders[8] = "Embassy Suites Waikiki"
var largeLandSubheads:Array = [];
largeLandSubheads[0] = "HOTEL & SKI RESORT"
largeLandSubheads[1] = "GOLF RESORT & SPA"
largeLandSubheads[2] = "RESORT & SPA"
largeLandSubheads[3] = "BEACH & GOLF RESORT"
largeLandSubheads[4] = "GOLF RESORT & CONFERENCE CENTER"
largeLandSubheads[5] = "HOTEL & GOLF RESORT"
largeLandSubheads[6] = "HOTEL & RESORT"
largeLandSubheads[7] = "OCEANFRONT RESORT"
largeLandSubheads[8] = "BEACH WALK®"
var landscapesArray:Array = new Array();
////landscape builders
var landscapeLimit:int = largeLandPhotos.length;
var landscapeTopStack = landscapeLimit-1;
function addLandscapes():void{
var i:int = 0;
for(;i<landscapeLimit;i++){
var _landscape:Landscape = new Landscape(largeLandPhotos[i], largeLandHeaders[i], largeLandSubheads[i]);
_introPhoto.photoMC.addChild(_landscape);
landscapesArray[i] = _landscape;
_landscape.alpha= 0;
_landscape.visible = false;
trace(_landscape.numChildren)
//add actions to the thumbnails
}
}
The code feeds in the class names I designated in my library and the headline string values to each instance of the "Landscape" class and loads each instance of the "Landscape" into a new array so I can target the whole thing. But I can't figure out the best way to target one "_headlineMC" of particular "_landscape". Help?
Thanks much!
Sam
Do you dream in ActionScript?