|
-
Total Universe Mod
Yep, you can treat a movieclip as if it was a button. I actually make a lot of my buttons out of 3 frame movieclips with a stop on the first one. Then I have my onRollOver and onRollOut functions make it gotoAndStop accordingly.
You could use loadMovie, loadClip or attachMovie. I just used attachMovie for this example because it takes less understanding of importing clips.
attachMovie takes 3 parameters and should be called on the target clip.
myContainerMovieClip.attachMovie('myLinkageName', 'myInstanceName', depth);
No two instances can occupy the same depth.
So each of your offices would have a unique linkage name. Something like office305, office306, office307 etc. If you were making a literal reference your attachMovie would look like this:
targetMC.attachMovie("office305", "officeButton"+i, i);
Note that i is an iterant variable in a for loop
I just picked a good sounding name when I used officeMovieClip, you should replace that with the name of your movieclip that will contain all the office buttons.
As far as loading data, I would try not to put asynchronous actions as part of your main classes code flow. It's tough to wrap normal in line logic around load events. I would create Office.as to accept an xml object. You could then load that xml as part of your flash movies script and trigger the Office constructor as part of the onLoad() function for that xml. Loading a text file would work the same way. As long as your Office class knows what to do with the data.
Say you had a method in the Office class called buildOffices(). And lets say buildOffices loops over the data you imported and creates new OfficeButton instances accordingly.
If buildOffices's job was to attach each office movie and give it an onRelease, it could use the iterant value of a for loop to match up the button with the data.
//not sure how your data is structured but could be something like
public function buildOffices(data){
for(var i=0; i<data.length; i++){
var clip = officeMovieClip.attachMovie(data[i][0], 'officeButton'+i, i);
var btn = new OfficeButton(clip, i);
}
}
Once the data was loaded, your entire app thus far could conceivably look like this:
myOffice = new Office(myLoadedData);
myOffice.buildOffices();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|