Topic: coding with MX (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11440" title="Pages that link to Topic: coding with MX (Page 1 of 1)" rel="nofollow" >Topic: coding with MX <span class="small">(Page 1 of 1)</span>\

 
derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-18-2003 13:56

Hi there,

I need some advice on flash MX actionscript.

I want to write a code for something like this:

I want to create an object type, and put 10 of instances to the stage.

They will be numbered from 1 to 10.
- objects will be pointing next one, (1 to 2, 2 to 3 etc.)
-Flagged object will be flashing (1st one)
-Flashing object will point next one when pressed and stop flashing.
-Pointed object will start flashing,

and so on.

Seemed very simple to me first but i am very confused after i started although i am familiar to object oriented programming with c++ and java.I need a starting point.

thanks...




Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 08-19-2003 02:15

I'm having a real hard time getting a mental image of what you want to accomplish. Would the graphics be distributed randomly on the stage? Would they all be in a vertical or horizontal line? Would they actually look like "pointers" of some sort?

Getting 10 instances of a movie clip on stage is simple with a loop:

code:
for (var i=0; i<10; i++){
..attachMovie code...
}


VERY simplified, but I don't want to insult you if you already know this. I could go into more detail if necessary.

Each instance would be given a name at the time they were attached; part of that name would most likely be a unique integer, commonly derived either from i or depth: for example "pointer"+i. (tacking on a single digit 0-9 would be simpler than 1-10 when it comes to extracting the digit later, or if you push them into a 0-based array.) Thus each instance could be "aware" of itself and potentially all the others by using a string method such as substring to extract that integer. Depending on how elaborate you need this to be, each clip could contain an array of all the others (see Jared Tarbell's binary networks composed of self-and-other-aware "nodes"), or just simply know which number was greater that iteslf.

Movie clip objects in MX are now capable of receiving mouse evens such as onRelease. If the first clip's initial behavior is to blink until clicked on, and the subsequent clips' behavoir is to not blink until pointed to and then blink until clicked on, that wouldn't be hard. The blink could be a simple frame loop and the onClick function could send the clip to a frame beyond the loop.

Getting it to "point" to the next clip would involve some trigonometry if the clips are scattered around the stage.

Does this need to be object oriented? No. Could it be? Sure. You could script a "Pointer" class. You could write the class constructor in the timeline of the movie clip and use registerClass so that every instance of the clip created a new instance of the class. That's a lot more work, so give us some more details about what you want to accomplish and maybe we can work out a rational approach.

Flash is very flexible compared with java and c++. I'm not a java or c++ programmer, but from what I understand, ActionScript can be initially disorienting for those coming from the stricter languages. ActionScript is considered "loosely typed", and is technically a prototype based language, not a strict class based language. I know a lot more than I did a year ago, but a lot less than I need to know to speak with authority. Still, game for trying.




[This message has been edited by Steve (edited 08-19-2003).]

derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-19-2003 09:40

No, whatever you say will not insult me about the actionscript, i know very little about it, in fact i ve been working on it for 3 days,reading actionscript.org and tutorials.

I am used to flash but not actionscript. My main problem is to relate graphics and code. I can create a movieclip and put its instances to the stage, but i can not create an automation with script. In fact what i want to do can be done with a little script like gotoAndPlay2,3,4..., but i really want to learn the actionscript.

i want to create an object type,

numbers=new object();

numbers.onMouseDown=function () { //new object methods and attributes.
tellTarget ....gotoAndPlay...//show next
this.blink=false //no flashing
....
}
mouse.addListener(numbers); // i think i have to add this.


for (i=1,i<10,i++) {
num[i]=new numbers(); //creating new objects
}
num[1].blink=true;
for (i=1,i<10,i++){
num[i].blink=true; //start blink (need to stop this loop until a mouseDown event (could be in movieclip action).
}


something like that for example.How can i relate this object with a movieclip?

does it make any sense?



derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-19-2003 09:41

by the way, thank you very much )

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 08-19-2003 12:52

No prolem. Let me think about it for a bit.

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 08-19-2003 15:21

derketa;

I've got a pretty hectic day today, so won't get much done on this issue, but let me ask a question and point out some potential problems with your approach.

The question: will this need to work backwards too? Meaning if you click pointer 1, then 2, then 3 then 4 then 5 ... then 1 - does it need to reset 2,3,4 and 5? Or is it only to work in a linear way? What happens if you skip a pointer? (1, 2, 3, 7 ...)

(BTW, you still haven't told us how the clips will be positioned on the stage. Will they be arranged in a line of some sort (like a menu), or distributed randomly?)

On to some thoughts about coding as you have started it.

First: I wouldn't add the pointer as a listener to the mouse object, because that won't target any particular clip. The onMouseDown event could happen anywhere on the stage if you subscribe the clips as listeners to the mouse object, which just broadcasts to any subscribers the fact that the event happened, not WHERE it happened. Better to write an onRelease method on the clip's timeline so that specific graphic is the target of the mouse event. (And I wouldn't use onMouseDown - the user has no opportunity to change their mind. onRelease is better in my opinion.)

"tellTarget" is a Flash 4 remnant, though commonly seen in older tutorials that still flourish on the internet. Better syntax would be "this.gotoAndPlay(frameLabel);"

Finally: "numbers=new Object();" is a perfectly acceptable way to begin a constructor method, but it won't result in anything visible on your stage. It constructs a new Object object, but it's not tied to a movie clip. There are examples of classes that handle, for example, scripted movement. They are invisible, helper classes not tied to a specific clip. If you want your pointer class to be intrinsic to something visible, it needs to be in the timeline of the library symbol, and the clip and the code need to be bound to each other using registerClass. Colin Moock's CodeDepot has some outstanding examples to study. Scroll down to "Chapter 14 (2nd Edition)" and download some of his examples, particularly "Ball, a MovieClip subclass" and "Ball subclass in a Library Symbol". Study the code and it should start to make sense if you have a OOP coding background. (Note that in the second demo I recommend, the pertinent code will be in the symbol's timeline, not the movie's main timeline.)



[This message has been edited by Steve (edited 08-19-2003).]

derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-19-2003 16:39

it will work linearly and will not let disorder.The positions of the nodes are constant.I mean puting 10 keyframes with stop and play will do but i just dont understand visible objects and code objects and trying to figure out relation among them.I will look at tuts that you suggested now.

and thank you very much for giving your time and explaining patiently.


Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 08-19-2003 22:52

Take a look at this. It's painfully crude (not much time today to make it pretty), and not at all object oriented, but perhaps gives us something to talk about, a point of departure. Not too much code, but reasonably well commented.

Did I come anywhere close to what you had in mind?

derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-20-2003 09:19

yes ,
Its far better than i wanted in fact
that's very close what i want to do but one thing,i think i gave you wrong information, nodes will not be linear, but their places are constant.
code is very clear, i think i must give the path for new instances of the movieclip.
the button behaviour of mc was the thing i could not solve.
can i ask you where do you work?

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 08-22-2003 05:42

"Its far better than i wanted in fact"

Excellent. Always like to exceed expectations


"the button behaviour of mc was the thing i could not solve."

This is a WONDERFUL improvement in MX. You should explore it. MovieClips behaving as buttons can sometimes have real advantages, so you should study up on this subject if you plan to stick with Flash.


"can i ask you where do you work?"

I'm a commercial photographer working in Boston, Mass, north east USA.
Flash has nothing to do with my profession. I do Flash because I can't control myself....


derketa
Bipolar (III) Inmate

From: Ankara, Turkey
Insane since: Aug 2000

posted posted 08-22-2003 15:24

Thanks a lot for your help,

i have to learn this Flash thing, because it is my profession(not intentionally)...
not knowing much but being have to create Flash games, i am disturbing everybody here with my endless questions.

hoping to be answering some day.

thanks again.

Bmud
Bipolar (III) Inmate

From: Raleigh, NC
Insane since: Mar 2001

posted posted 09-10-2003 17:47

"I do Flash because I can't control myself...."

I feel your pain my friend. Your pain and your obsession. WOOAHAJKSFHOWH!! =D



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu