dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: problems with 'if and else' and other stuff

  1. #1

    problems with 'if and else' and other stuff

    hi there

    i'm starting on a personal project to try and build and 'e-card maker' so that users can create their own e-cards by selecting a background pattern, an object to place on the stage and an animated effect [very basic at the moment as i just want to get it to work].

    download the fla if you want to see how i've set this up and don't laugh at the graphics as it's only basic crap at the moment.

    file

    my first problem is that the way i've set this up - with 3 container mocieclips [bg_cont, sfx_cont, obj_cont] the different elements selected would sit within each of these container movies when selected.

    but attchMovie seems to work in Levels, so i've supplied a different level for each. when selecting a bg and then going to choose an object - i would think that when returning to the main part the bg would still be there, but it isn't. each selection overwrites the previous. what am i doing wrong there?

    also - new to functions - still can't get my head round them, but here's the code for this bit - sits on first frame of the movie:

    Code:
    stop();
    function itemAttach(linkage, instance, level, type) {
    	trace("we are function start");
    	trace(type);
    	if (type=0); {
    		trace("we are here bg");
    		_root.bg_cont.attachMovie(linkage, instance, level);
    		bg = instance;
    		trace(bg);
    	} 
    	if (type=1);{
    		trace("we are here sfx");
    		_root.sfx_cont.attachMovie(linkage, instance, level);
    		sfx = instance;
    		trace(sfx);
    	}
    	if (type=2);{
    		trace("we are here obj");
    		_root.obj_cont.attachMovie(linkage, instance, level);
    		obj = instance;
    		trace(obj);
    	}
    }

    why is it in my output window - the function seems to run right the way through - should it test for the first bit and if this is true stop there. i don't know if i've got my if and else statements right either.

    can someone please give me some pointers in the right direction??

    cheers

    e

  2. #2
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    My first though is that you have to do this:
    Code:
    if (type=0); {
     instance = 'bg';
     _root.bg_cont.attachMovie(linkage, instance, level);
    }
    Else you'll end up with a movie clip with an instance of 'instance'!

    Stu

  3. #3
    it's ok i've sorted it out now thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center