Forums

ForumsProgramming Forum

Anyone Wanna Help me improve my code?

Posted Feb 25, '13 at 2:50pm

cheese123

cheese123

20 posts

Oh are you using AS3? Im still in the dark ages with AS2

 

Posted Feb 25, '13 at 4:14pm

weirdlike

weirdlike

463 posts

Knight

var format:TextFormat = new TextFormat();
format.font = "Arial";

label.text = "You awake from sleeping...";

label.onMouseDown=function(evt)
{
    trace("myListener1");
    label.text = "you feel sick";
   
    label.onMouseDown=function(evt)
    {
        trace("myListener2");
        label.text = "perhaps too much to drink...";
    }
}

fla

 

Posted Feb 26, '13 at 7:58am

cheese123

cheese123

20 posts

Also.. Whenever I pick up an object it unloads the movie clip (that was the object)
When I go back to the original scene that object comes back.

To counter this I decided to have all my scenes on one frame, and move the whole scene by about 500px when I click an arrow to go somewhere else. I realized that this could hurt performance?

Do you think when I pick an object, I can push values into an array. Depending on what values the array contains, it removes the object from the scene, and each time I go back to a frame it checks all the values and removes objects accordingly.

 

Posted Feb 26, '13 at 9:46am

weirdlike

weirdlike

463 posts

Knight

additional frames are kinda not good but you can try this

on the first frame add

var box:Boolean = true;

on the 2nd frame (or whichever) check if it is true

if (box)
{
    trace("box true");
    //true function here
}
else
{
    trace("box false");
    box.visible = false;
    //function here
}

don't forget to add the trigger that makes it false so the box is hidden the second time around and the var is on the first frame so it only gets changed through actionscript

also this is 3.0 sorry but it might help a little

 

Posted Feb 26, '13 at 10:21am

cheese123

cheese123

20 posts

no worries, i understand what your saying

yea i thought about that idea, but then you need to add a variable for each item. might get a bit cluttered right?

 

Posted Feb 26, '13 at 10:39am

weirdlike

weirdlike

463 posts

Knight

I suppose so, if you wanted one visible and the another invisible you would need a separate variable for it to work, you can also check to see if it is false so if you wanted one visible while the other is invisible and vise versa

 

Posted Feb 26, '13 at 12:35pm

cheese123

cheese123

20 posts

Why is more than one frame a bad thing.

 

Posted Feb 26, '13 at 2:22pm

weirdlike

weirdlike

463 posts

Knight

I have found in my own writing that it is more organized, which is important if you leave the project for a while and come back to it and realize that it need to be recoded all over again due to the code being jumbled all over the place. Or if you are showing to someone else they can easily find everything

but don't get me wrong I do it too...

 

Posted Feb 26, '13 at 2:55pm

cheese123

cheese123

20 posts

Ok I thought of how I will do it.

I will insert bolleans into an array, when you an item[s] it makes a bollean[s] true.

When bollean[s] is true, unload item[s]

 

Posted Feb 26, '13 at 3:50pm

cheese123

cheese123

20 posts

weirdilike, since you helped me, let me help you if you dont know already.

when making your game place it in a movie clip, then you can use the main timeline to program everything in the movie clip, and have 100 frames in the movie clip

 
Reply to Anyone Wanna Help me improve my code?

You must be logged in to post a reply!