Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49

    Passare un comando pulsante da XML a Action script

    Ciao a tutti!
    Il menù fighissimo che potete vedere in questo link
    http://flashden.net/item/xml-team-menu/3356
    carica dei clip filmato "dude" identificati anche con la proprietà di concatenamento, identificatore "dude1", "dude2", "dude3", ecc...
    Caricati grazie alle action script contenenti in un clip (che non contiene grafica, solo azioni), che poi è il menù. E grazie ai comandi del file "menu.xml".

    Il problema è che si aprono dei link ad altre pagine, ma per migliorare la navigazione del sito, interamente in flash, occorre che i pulsanti (dude) si aprano delle scene all'interno dell'swf.
    é possibile, combiando dei comandi???
    Il problema è che le sagome del menù (dude) vengono caricate grazie al file .xml

    Queste le azioni del clip filmato menu:
    //________ MENU ________
    // Importing the transition class
    import mx.transitions.*;
    import mx.transitions.easing.*;


    easeSpeed = 3; // set the ease sensetivity
    MovieClip.prototype.elasticScale = function(toSize) {
    easeType = mx.transitions.easing.Regular.easeInOut;
    myTween = new Tween(this, "_yscale", easeType, this._yscale, toSize, easeSpeed);
    myTween = new Tween(this, "_xscale", easeType, this._xscale, toSize, easeSpeed);
    };
    //////////////////////////////////////////////////////////////////////////
    // Here the array object is created.
    var rubrieken:Array = new Array();
    // Here the XML object is created.
    myXML = new XML();
    myXML.ignoreWhite = true;
    myXML.onLoad = function(success) {
    // De data from the xml is loaded into flash
    // Using a 'for' loop the data is placed inside the array
    if (success) {
    menuItems = this.firstChild;
    for (i=0; i<menuItems.childNodes.length; i++) {
    rubriek = menuItems.childNodes[i];
    rubrieken.push(rubriek);
    }
    }
    // As soon as the data is loaded int the array the function below will be executed
    attachMenu();
    };
    myXML.load("xml/menu.xml");
    // This function attaches the people figures to the stage with the right data
    function attachMenu() {
    // This margin variable sets the space on the right and the left. roght now 80px;
    margin = (Stage.width-680)/rubrieken.length;
    for (i=0; i<rubrieken.length; i++) {
    loadDude = rubrieken[i].attributes.dude;
    var menuItems = peopleHolder.attachMovie(loadDude, "dude"+i, 10000+i);
    menuItems._x = menuItems._x+(margin)*i;

    // This inline fuction executes the proximity function onEnterFrame
    menuItems.onEnterFrame = function() {
    proximity(this);
    };

    menuItems._href = rubrieken[i].attributes.href;
    menuItems.idText = rubrieken[i].attributes.dudesname;
    menuItems.knopTekst.text = rubrieken[i].attributes.naam;
    // The events when you roll over the button
    menuItems.onRollOver = function() {
    this.swapDepths(10000+i);
    // makes the tooltip appear
    this.nameTip._alpha = 100;
    // Out the name from the xml inside the tooltip
    this.nameTip.idTag.text = this.idText;
    };
    menuItems.onRollOut = function() {
    // makes the tooltip disappear
    this.nameTip._alpha = 0;
    };
    menuItems.onRelease = function() {
    getURL(this._href, "_self");
    };
    }
    }
    //////////////////////////////////////////////////////////////////////////

    // This here is the function that calculates the size of each item depending on the proximity of the mouse position
    // You could play a little with these number but it is kinda tricky.
    function proximity(clip) {
    var x:Number = peopleHolder._xmouse;
    var y:Number = peopleHolder._ymouse;
    var cx:Number = clip._x;
    var cy:Number = clip._y-clip._height/2;
    var prox:Number = Math.sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy));
    // if the mouse is closer to the object than 100px it increases its size
    if (prox<100) {
    clipx = 300-prox*2;
    clip.elasticScale(clipx);
    // if the mouse is futher away than 100 it keeps it original size
    } else {
    clipx = 100;
    clip.elasticScale(clipx);
    }
    }

    Questo il contenuto del file "menu.xml":
    <?xml version="1.0" encoding="iso-8859-1"?>
    <rubriekenxml>
    <project dude="dude0" dudesname="Sam" href="http://www.google.nl"/>
    <project dude="dude1" dudesname="Richard" href="http://www.google.nl"/>
    <project dude="dude2" dudesname="John" href="http://www.google.nl"/>
    <project dude="dude3" dudesname="Curtis" href="http://www.google.nl"/>
    <project dude="dude4" dudesname="Charles" href="http://www.google.nl"/>
    <project dude="dude5" dudesname="Otis" href="http://www.google.nl"/>
    <project dude="dude6" dudesname="Benny" href="http://www.google.nl"/>
    <project dude="dude7" dudesname="Ray" href="http://www.google.nl"/>
    <project dude="dude8" dudesname="Billy" href="http://www.google.nl"/>
    <project dude="dude9" dudesname="Paul" href="http://www.google.nl"/>
    </rubriekenxml>

    Chi ha qualche idea/soluzione...???

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49
    Dunque...
    penso che si debba inserire al posto dell'azione getURL quella che si vuole che esegua... se vuoi cambiarla poi runtime puoi fare uno switch(variable) dove variable dipende dal nodo xml corrente...

    Ho scoperto che al posto di href ci si potrebbe mettere un attributo Pageid="1", cosi si sa a che fotogramma devi andare...

    Per l'xml ho messo

    codice:
      <project dude="dude0" dudesname="l'evento" pageid="1"/>
    ma ho provato anche con scena + fotogramma
    e anche con una etichetta ad un fotogramma chiamato "tac"
    codice:
      <project dude="dude0" dudesname="l'evento" pageid="Scena 1, 1"/>
     
      <project dude="dude0" dudesname="l'evento" pageid="tac"/>
    Per le azioni:
    [/CODE]
    menuItems.onRelease = function() {
    gotoAndStop(elemento.attributo_pageid)
    [CODE]

    Non va. L'xml è di sicuro toppata...
    Come faccio a dirgli di andare a quel preciso fotogramma??? Nome scena + fotogramma, nome etichetta fotogramma?
    E cosa posso mettere di preciso al posto di elemento.attributo???

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49
    Ho provato sostituendo action script e xml come e nella stessa scena funziona! (ma mi serve che vada in un'altra scena........!!!)

    menuItems._pageid = rubrieken[i].attributes.pageid;

    menuItems.onRelease = function() {
    gotoAndPlay(this._pageid);
    <project dude="dude0" dudesname="l'evento" pageid="10"/>
    oppure
    <project dude="dude0" dudesname="l'evento" pageid="easy"/>
    Dove 10 è il fotogramma e "easy" è un etichetta presente nella stessa scena

    Adesso che ci penso quel menù è dentro un clip filmato (esigenze per la struttura della pagina) così ho pensato di dirgli di andare ad un fotogramma etichettato chiamato "fax" presente in un'altra scena, ma niente...

    Insomma se metto un etichetta in un fotogramma all'interno di quel clip funziona,
    ma va appunto al fotogramma dentro il clip...........
    io devo farlo andare in un fotogramma nella scena (in cui è contenuto il menu) o in un fotogramma di un'altra scena...
    che comando gli posso dare???
    Centra la root vero...?

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49
    In definitiva, pare che così funzioni:
    menuItems._pageid = rubrieken[i].attributes.pageid;

    menuItems.onRelease = function() {
    _parent.gotoAndPlay(this._pageid);
    e per l'xml
    <project dude="dude0" dudesname="Sam" pageid="fax"/>
    Dove "fax" è l'etichetta di un fotogramma contenuta in un'altra scena.

    Funziona anche con _root
    _root.gotoAndPlay(this._pageid);

  5. #5
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49
    Un'altro problema...
    Per motivi tecnici faccio caricare il menù con un loadmovie
    loadMovieNum("menu.swf", 1);
    che rimane caricato in tutte le scene del sito, tutto il tempo.

    Però adesso il comando non funziona più, va modificato...
    In pratica seve un comando che gli dica di andare al fotogramma di una scena contenuta nell'swf che contiene il menu.swf...

    Come sostituisco il
    _parent.gotoAndPlay ???

    O cosa aggiungo???

  6. #6
    Non ho avuto il tempo di leggere tutto il post, cmq se ti serve inviare comandi da un XML a Flash puoi usare le asfunction.
    Tipo ad esempio:

    <mioNodo><![CDATA["stampami"]]></mioNodo>

    Quindi praticamente stampami diventa un bottone che una volta cliccato chiama la funzione stampa a cui passa un valore ciao.
    Chiaramente la funzione tela imposti come ti pare e i parametri che gli puoi passare possono essere più di uno ('asfunction:_level0.stampa,ciao,pippo,3') .... unica cosa ricordati che quando i parametri sono più di uno li devi trattare come un'array (che poi ti splitterai per la virgola).
    Nello specifico nel nostro esempio la funzione _level0.stampa dovrà essere fatta così:

    function stampa(myParam:Array){
    var mySplit:Array = myParam.split(",");
    var myVar1:String = mySplit[0];
    var myVar2:String = mySplit[1];
    var myVar3:Number = Number(mySplit[3]);
    // altre azioni che ti servono
    }

    Non so se ti serviva precisamente sta cosa, cmq spero di esserti stato utile lo stesso

  7. #7
    Utente di HTML.it
    Registrato dal
    Jan 2008
    Messaggi
    49
    Grazie mille per l'aiuto!
    Ho risolto con _level

    _level.gotoAndPlay

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.