Article View: adobe.atmosphere
Article #28910Re: Reusing the subworld file
From: Rolu
Date: Thu, 09 May 2002 03:21
Date: Thu, 09 May 2002 03:21
54 lines
3782 bytes
3782 bytes
"Norm Lindenberg" <nlindenberg@home.com> wrote in message news:ef86495.7@WebX.aaQKaf7vad4...
> Rolu,
>
> I cannot think of a way to generate the subworld names programmatically and I am trying to avoid manually assigning different
names to each subworld. Instead, I am trying to identify them by their other properties so they can be created generically and share
the same functions. It may turn out that I cannot do this but I am hoping I can.
>
If you want to have a bunch of subworlds around without explicitly naming them you should consider putting them in an array. An
array is a thing that can hold other variables, which you can then index using a number. For example:
subworlds=new Array();
subworlds[0]=SubWorld("subw.aer").add();
subworlds[1]=SubWorld("subw.aer").add();
From now on, subworlds[0] refers to the first subworld, and subworlds[1] refers to the second one. The number between the square
brackets is the index, which is an expression. This means that, for example, subworlds[4*0.25] also refers to the second subworld,
as 4*0.25 evaluates to 1. This allows for a nice way to create them generically:
subworlds=new Array();
this.initsubs=function()
{
var i, amount, subw;
amount=20; // Create this many subworlds.
for(i=0;i<amount;i++)
{
subw=SubWorld("subw.aer").add();
subw.position=world.find(".../subpos"+i).position; // This assigns the position of subpos0 to the first subworld, that of
subpos1 to the second, etc. In this case it requires twenty anchors named subpos0 to subpos19.
(do more things to subw, these things will be done to every created subworld)
subworlds[i]=subw; // Place the newly created subworld at slot i in the array.
}
}
this.initsubs();
Now you have one variable, subworlds, which holds twenty subworlds, accessible using subworld[0] to subworlds[19].
> Is it possible to back into the subworld name from within the onMouseOver function so I can get to the Name property I have
assigned to the subworld (eg. vsw.Name = "scout1";)without referencing the actual subworld name (vsw)? I tried using "this.Name" and
"world.parent.Name" and a number of other things so I could get away from using "vsw" but nothing worked.
>
Yes, that's possible. Assign a reference to the subworld object to the world property of the subworld. In the onMouseOver function,
'this' refers to that world property as that is what it is attached to. In the onWorldLoad callback, when you also create the
onMouseOver function, next to it place a line like
this.world.owner=this;
Then, inside the onMouseOver function, which is attached to the world property (this.world.onMouseOver=etcetc...), you can refer to
the original subworld with this.owner.
Rolu
Technical Details
Message-ID:
<6E1930C30D50A5E190BA52971031985C@in.WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!netnews.com!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef86495.-1@WebX.aaQKaf7vad4> <ef86495.7@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa820,71055f44dd0e58e2 X-Google-Attributes: gidfa820,public X-Google-ArrivalTime: 2002-05-08 20:37:38 PST From: "Rolu" <rolu@roce.org> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!netnews.com!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.atmosphere Subject: Re: Reusing the subworld file Message-ID: <6E1930C30D50A5E190BA52971031985C@in.WebX.aaQKaf7vad4> Date: Wed, 8 May 2002 20:21:04 -0700 References: <ef86495.-1@WebX.aaQKaf7vad4> <ef86495.7@WebX.aaQKaf7vad4> Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit