Skip to main content
Known Participant
June 26, 2013
Question

want to close a function and load new function...by button....

  • June 26, 2013
  • 1 reply
  • 643 views

my button code is ..

on(release) {

this.wall.removeMovieClip(callThumbs());

loadnextF();

}

and my all scripts is ............

import mx.transitions.Tween;

import mx.transitions.Zoom.*;

import caurina.transitions.*;

var myGalleryXML = new XML();

myGalleryXML.ignoreWhite = true;

myGalleryXML.load("26-demo.xml");

myGalleryXML.onLoad = function()

{

    _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x = 100;

    _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;

    _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;

    _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;

    _root.myImages = myGalleryXML.firstChild.childNodes;

    _root.myImagesTotal = myImages.length;

    _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;

    _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;

    _root.full_x = myGalleryXML.firstChild.attributes.full_x;

    _root.full_y = myGalleryXML.firstChild.attributes.full_y;

    callThumbs();

};

function callThumbs()

{

    _root.createEmptyMovieClip("wall",_root.getNextHighestDepth());

    wall._x = _root.gallery_x = 0;

    wall._y = _root.gallery_y = 230;

    wall.addEventListener(MouseEvent.CLICK);

    var clipLoader = new MovieClipLoader();

    var preloader = new Object();

    clipLoader.addListener(preloader);

    for (i = 0; i < 6; i++)

    {

        thumbURL = myImages.attributes.thumb_url;

        myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());

        myThumb_mc._x = _root.thumb_height * i;

        myThumb_mc._x = _root.thumb_position = -3260 + i * 765;

        clipLoader.loadClip("shop/" + thumbURL,myThumb_mc);

        preloader.onLoadStart = function(target)

        {

            target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);

            target.my_txt.selectable = false;

        };

        preloader.onLoadProgress = function(target, loadedBytes, totalBytes)

        {

            target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);

        };

        preloader.onLoadComplete = function(target)

        {

            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);

            target.my_txt.removeTextField();

            target.onRelease = function()

            {

                callFullImage(this._name);

            };

            target.onRollOver = function()

            {

                this._alpha = 100;

            };

            target.onRollOut = function()

            {

                this._alpha = 100;

            };

        };

    }

/*

    for (i = 6; i < 12; i++)

    {

        thumbURL = myImages.attributes.thumb_url;

        myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());

        myThumb_mc._x = _root.thumb_height * i;

        myThumb_mc._x = _root.thumb_position = -7367 + i * 765;

        myThumb_mc._y = _root.thumb_position = 180;

        clipLoader.loadClip("shop/" + thumbURL,myThumb_mc);

        preloader.onLoadStart = function(target)

        {

            target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);

            target.my_txt.selectable = false;

        };

        preloader.onLoadProgress = function(target, loadedBytes, totalBytes)

        {

            target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);

        };

        preloader.onLoadComplete = function(target)

        {

            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);

            target.my_txt.removeTextField();

            target.onRelease = function()

            {

                callFullImage(this._name);

            };

            target.onRollOver = function()

            {

                this._alpha = 100;

            };

            target.onRollOut = function()

            {

                this._alpha = 100;

            };

        };

    }

*/

}

//var gapX:Number=5;

var nextX:Number = 7;

var loadNum:Number=7;

var preloader:Object={};

var clipLoader:MovieClipLoader=new MovieClipLoader();

clipLoader.addListener(preloader);

function loadnextF(){

        thumbURL = myImages[loadNum].attributes.thumb_url;

        myThumb_mc = wall.createEmptyMovieClip(loadNum, wall.getNextHighestDepth())

        myThumb_mc._alpha=0;

        clipLoader.loadClip("shop/"+thumbURL,myThumb_mc);

        }

for (j=7; j<9; j++)

    {

        thumbURL = myImages.attributes.thumb_url;

        myThumb_mc = wall.createEmptyMovieClip(j.getNextHighestDepth());

        myThumb_mc._x = _root.thumb_height * j;

        myThumb_mc._x = _root.thumb_position = -3260 + j * 765;

/*

        preloader.onLoadStart = function(target) {

            target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);

            target.my_txt.selectable = false;

        };

        preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {

            target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);

        };

*/

    }

        preloader.onLoadComplete = function(target) {

target._x = nextX;

nextX += target._width+gapX;

loadNum++;

if(loadNum>7){

loadnextF();

}

            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);

            target.my_txt.removeTextField();

            target.onRelease = function() {

                callFullImage(this._name);

            };

            target.onRollOver = function() {

                this._alpha = 100;

            };

            target.onRollOut = function() {

                this._alpha = 100;

            };

        };

function callFullImage(myNumber)

{

    myURL = myImages[myNumber].attributes.full_url;

    myTitle = myImages[myNumber].attributes.title;

    _root.createEmptyMovieClip("ajit",_root.getNextHighestDepth());

    ajit._x = _root.full_x = 130;

    ajit._y = _root.full_y = 32;

    /*by forum*/

    _root.onEnterFrame = function()

    {

        wall._alpha = 0;

        if (_root._currentframe == 2)

        {

            wall._alpha = 100;

        }

    };

    this.gotoAndStop(21);

    var fullClipLoader = new MovieClipLoader("ajit");

    var fullPreloader = new Object();

    fullClipLoader.addListener(fullPreloader);

    fullPreloader.onLoadStart = function(target)

    {

        target.createTextField("my_txt",ajit.getNextHighestDepth(),0,0,400,20);

        target.my_txt.selectable = false;

    };

    fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes)

    {

        target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);

    };

    fullPreloader.onLoadComplete = function(target)

    {

        new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);

        target.my_txt.text = myTitle;

    };

    fullClipLoader.loadClip("full_images/" + myURL,ajit);

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 26, 2013

you can call a function but, you can't open or close a function and you can't load a function.

you can load a movieclip (ie, swf), bitmap (eg, jpg), sound etc and you can remove movieclips and you can do those things in a function body and you can call that function using a button.

so, what exactly, are you trying to do and do you understand your code?

Known Participant
June 27, 2013

yes ... i want to remove movie clip "wall" of "callThumbs" function.... and want to call it again with next 6 thumbs. what should i do for this.

kglad
Community Expert
Community Expert
June 27, 2013

if you have a movieclip wall and it has a child movieclip (callThumbs which has a linkage id=callThumbsID) you can use:

btn1.onRelease=removeThumbsF;  // to remove wall.callThumbs

//and

btn2.onRelease = addThumbsF;  // to add callThumbs to wall

function removeThumbs():Void{

wall.callThumbs.removeMovieClip();

}

function addThumbs():Void{

wall.attachMovie("callThumbsID","callThumbs",wall.getNextHighestDepth());

}