Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    286

    come faccio a utilizzare un oggetto creato dentro una funzione?

    ciao ragazzi!
    ho creato una funzione che mi crea un oggetto bitmap al suo interno.

    vorrei utilizzare l'oggetto creato per applicare dei filtri
    solo che nn so come fare a richiamare l'oggetto appena creato

    codice:
    carica_img = function (dest_mc:MovieClip, file_name):BitmapData {
    	//create a movie clip to hold the external file
    	this.createEmptyMovieClip("holder", this.getNextHighestDepth());
    	/*
    	Use the MovieClipLoader class so we can be told
    	when the external file loads or fails to load
    	*/
    	loader = new MovieClipLoader();
    	//Give us status updates by firing events
    	loader.addListener(this);
    	//Load the external file into the holding movie clip
    	loader.loadClip(file_name, holder);
    	//this function is called by the 'loader' object when the file is loaded and ready to use
    	loader.onLoadInit = function() {
    		//Create a new bitmap object in memory that is the same size as
    		//the loaded file and fill it with transparent pixels
    		myBitmap = new BitmapData(holder._width, holder._height, true, 0x00FFFFFF);
    		//Snapshot the movie clip that contains the external file we loaded
    		myBitmap.draw(holder);
    		//
    		//we don't need this movie clip anymore, so remove it
    		//we already have the bmp in myBitmap istance
    		//NOTE that bmp doesn't appear since we attach it on a clip
    		holder.removeMovieClip();
    		//
    		//
    		_root.test.attachBitmap(myBitmap, 1);
    	};
    	//this function is called by the 'loader' object if the file couldn't be loadd
    	function onLoadError() {
    		/*		
    		    The external file failed to load so we don't need 
    		    the holding movieclip anymore
    		*/
    		holder.removeMovieClip();
    	}
    	return myBitmap;
    };
    dopo aver chiamato la func vorrei poter utilizzare myBitmap...
    ma come valore è undefined

    sapete dirmi perchè?

    grazieeeee

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182

    Re: come faccio a utilizzare un oggetto creato dentro una funzione?

    se la funzione si trova dichiarata in _root, allora il tuo oggetto/clip creato nella funzione avrò comunque come riferimento _root

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    286
    uhm
    ho provato ma nn funzia
    appena esce da loader.onLoadInit()
    myBitmap diventa undefined

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da Aran Benjo
    uhm
    ho provato ma nn funzia
    appena esce da loader.onLoadInit()
    myBitmap diventa undefined
    prova a dar a myBitmap un percorso assoluto e dichiararla come _root.myBitmap

    è probabile che ora prenda il percorso interno a "loader", ma non ne son sicurissimo

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    286
    niente da fare!

    ho provato a usare anche return mybitmap ma uscito dall'onLoadInit il valore va a undefined


  6. #6
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    ma se la funzione la metti come "Void" e non fai restituire niente, cambia qualcosa? dovrei provarlo 'sto coso, ma non posso perchè non ho flash8

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    286


    ma come faccciiiiiiiiiooooooooooooooooo
    porca puzzola

    come faccio a rendere visibile dappertutto quel bitmapdata!!!!


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.