Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

dupliranje movieClip-a u klasi

[es] :: Flash :: dupliranje movieClip-a u klasi

[ Pregleda: 3279 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

sekvoja

Član broj: 91239
Poruke: 269
*.ptt.yu.



Profil

icon dupliranje movieClip-a u klasi28.04.2006. u 17:18 - pre 218 meseci
Pozdrav svima. Kako se duplira movieClip u zavisnosti od broja nodova u XML fajlu? To nikako ne mogu da provalim zato sto sam slab sa programiranjem u klasi. To bez problema postizem kada kucam obican as, ali ovde sam se zakucao. Predpostavljam da je problem u ovom this ispred ["kvadrat"+i]._x = i*30;

class pitanje extends MovieClip {

var kvadrat:MovieClip;
var xml:XML;
var root:XMLNode;

function pitanje() {
fja();
}

private function fja() {

this.createEmptyMovieClip("kvadrat", -1);
kvadrat.lineStyle(3, 0x000099, 100);
kvadrat.lineTo(25,0);
kvadrat.lineTo(25,25);
kvadrat.lineTo(0,25);
kvadrat.lineTo(0,0);

xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(ok) {
if (ok) {
root = this.firstChild;
for(var i=0; i<root.childNodes.length; i++) {

kvadrat.duplicateMovieClip("kvadrat" + i, i);
this["kvadrat"+i]._x = i*30;
}
}
}
xml.load("bla bla.xml");
}
}
 
Odgovor na temu

Vranac
Vranac Srdjan
Software developer
Novi Sad, Vojvodina

Član broj: 3493
Poruke: 353
..mtsns-ns.customer.sbb.co.yu.

Jabber: vranac@elitesecurity.org
ICQ: 64150005
Sajt: www.linkedin.com/in/vrana..


+1 Profil

icon Re: dupliranje movieClip-a u klasi28.04.2006. u 17:46 - pre 218 meseci
Ajd da nastavimo gde smo stali sa proslim postom ...
Napravi MC u library i daj mu ime kakvo hoces,
u properties-u kao AS 2.0 klasu stavi klasu pitanje.

Prevuci MC iz library-a na stage, daj mu ime kakvo zelis.

na _leve0 timeline-u dodaj sledece

Code:


this.onLoad = function() {
    imeMCaKojeSiDao.init();
}


to ce obezbediti da se kod pocne izvrsavati kad se sve ucita i inicijalizuje

napravi AS 2.0 class file i u njega ubaci vec poznatu nam klasu
Code:

import mx.utils.Delegate;

class pitanje extends MovieClip {
    // declare vars needed for class
    private var i:Number;
    private var my_ar:Array; 
    private var xmlData:XML;
    
    private var kvadrat:MovieClip;
    
    
    // initialize the vars, set the XML Object to ignore the white space,
    // set the function that will be called for the XML onLoad event
    function pitanje() {
            
        my_ar = new Array();
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = Delegate.create(this,goto);
        
    }
    
    //initialize function, it will create the MC and draw a square in it
    // also it will start the loading of the XML
    public function init(){
        kvadrat = this.createEmptyMovieClip("kvadrat", this.getNextHighestDepth());
        kvadrat.lineStyle(3, 0x000099, 100);
        kvadrat.lineTo(25,0);
        kvadrat.lineTo(25,25);
        kvadrat.lineTo(0,25);
        kvadrat.lineTo(0,0);
        kvadrat._visible = false;
        
        loadXML();
        // if you call array function here you will get nothing back, 
        // since the loading has been started, it may not have completed yet
        //array();
    }
    
    // start the loading of the xml file
    private function loadXML() {
        trace("loadXML");
             
        xmlData.load("pitanje.xml");
        
    }
    
    
    //function that is called when the xml file is loaded,
    // param success will be true for successfull loading of the xml file
    function goto(success) {
        if (success) {
            // trace the whole xml file 
            trace(xmlData)
            // set the root node
            var rootNode:XMLNode = xmlData.firstChild;
            // go through all the childnodes in the root node
            for (i=0; i<rootNode.childNodes.length; i++) {
                //var my_ar = new Array();
                // and add their text values to the array
                my_ar.push(rootNode.childNodes[i].firstChild);
                // trace the current content of the my_ar array
                //trace("my_ar = " + my_ar);
                kvadrat.duplicateMovieClip("kvadrat"+i,this.getNextHighestDepth());
                this["kvadrat"+i]._x = (this["kvadrat"+i]._width + 5) * i
            }
            
            // when you call the function here it will list the contents of 
            // the array, because the load has been completed and the xml
            // has been parsed
            array();
        } else {
            trace("crap")
        }
    }
    
    // list the contents of the my_ar array
    private function array() {
        trace("array = " + my_ar)
    }
}


taj fajl snimi kao pitanje.as

i to je to...

Sad dalje bi bilo lepo da radis sam........
Idle mind is the devils playground, in my case it turned out to be an amusement park.

Sustina problema ove zemlje:
Legeonar_: Sto pre treba da shvatite da je EU propast i da se tamo mora raditi,a ne samo biti zaposlen.
http://www.elitemadzone.org/p1864861

Nobody Remains Virgin, Life Fucks Everyone
 
Odgovor na temu

sekvoja

Član broj: 91239
Poruke: 269
*.ptt.yu.



Profil

icon Re: dupliranje movieClip-a u klasi28.04.2006. u 22:23 - pre 218 meseci
Vranac ti si kralj!!!
 
Odgovor na temu

[es] :: Flash :: dupliranje movieClip-a u klasi

[ Pregleda: 3279 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.