Great detail, thanks. I'm reading up on component development, as this
really seems like a useful concept for other development with this client.
I appreciate the time you took to write this out. I'll be back with
questions, no doubt....
One quick question for now: Will the component objects be persistant across
scenes, or do I need to reload them if the client is using scenes for very
long swf's? (training vo/slides that go 2-3 minutes each)??
thanks again,
Doug
[quoted text, click to view] "proxmaster" <webforumsuser@macromedia.com> wrote in message
news:cn9gtn$7ev$1@forums.macromedia.com...
> This isn't overly difficult to do, but it will require a bit of work. The
> example I have provided is meant to be a general overview of the process
and
> the various pieces required. I use this same process of dynamically
creating my
> buttons as well as other flash objects from an external xml file all the
time.
>
> In order for this to work with the following example, you will need
create a
> movie clip from a button and then define it as a component in flash with
the
> following parameters:
>
> txtlabel - String
> xpos - number
> ypos - number
> urlpath - String
>
> Let me know if you require more detailed information on creating
components
> and defining parameters in them.
> This code would be on the component:
> this.buttonlabel = this.txtlabel;
> this._x = this.xpos;
> this._y= this.ypos;
> this.onRelease=function(){
> getURL(this.urlpath);
>
>
> // The following code should be executed on the root level of the movie.
This
> example will load and parse the xml file, and create the buttons
dynamically on
> the initial movie load.
>
> buttons_xml= new XML();
> buttons_xml.load ("buttons.xml");
> buttons_xml.ignoreWhite = true;
> buttons_xml.onLoad = loadXMLData;
>
> function loadXMLData(){
>
> ilen = buttons_xml.childNodes.length;
> i=0;
>
> while(i<ilen){
> if (buttons_xml.childNodes.nodeName.toLowerCase() == "buttons") {
>
> klen = buttons_xml.childNodes.childNodes.length;
> k=0;
> while(k<klen){
> subObj = buttons_xml.childNodes[k];
>
> if (subObj.nodeName.toLowerCase() == "button") {
> _root.ph1.attachMovie("buttoncomponent","newbutton"+k,k);
> var btn = _root.ph1["newbutton"+k];
> btn.txtlabel=buttons_xml.childNodes[k].attributes.txtlabel;
> btn._x=buttons_xml.childNodes[k].attributes.xpos;
> btn._y=buttons_xml.childNodes[k].attributes.ypos;
> btn.urlpath=buttons_xml.childNodes[k].attributes.urlpath;
> }
> k++;
> }
> }
> i++;
> }
> }
>
> //The following is a basic xml file that is saved as buttons.xml in the
same
> location as the final swf file. I have include a few basic attributes for
> creating buttons for demo purposes. You will most likely want to modifiy
these
> to suit your own needs.
>
> <buttons>
> <button txtlabel="button1" xpos="50" ypos="120"
> urlpath="http://www.mylocation1.com"/>
> <button txtlabel="button2" xpos="50" ypos="140"
> urlpath="http://www.mylocation2.com"/>
> <button txtlabel="button3" xpos="50" ypos="160"
> urlpath="http://www.mylocation3.com"/>
> <button txtlabel="button4" xpos="50" ypos="180"
> urlpath="http://www.mylocation4.com"/>
> <button txtlabel="button5" xpos="50" ypos="200"
> urlpath="http://www.mylocation5.com"/>
> </buttons>
>