PDA

View Full Version : please help, onLoad inside on (rollOver)



apache
July 23rd, 2003, 03:23 PM
I tested several times but this piece of code doesn't work at all , please help me .

on (rollOver) {
_root.createEmptyMovieClip("test", 5);
_root.test.onLoad = function () {
trace("Come on");
}
}

I'm looking forward for your help , thanks in advance .

lostinbeta
July 23rd, 2003, 03:29 PM
onLoad isn't used for movie clips, it is used for loading things into Flash (loadVars(), XML(), etc etc)

apache
July 23rd, 2003, 03:36 PM
thanks for your fast reply .

But as I read in FLash Doc :


MovieClip.onLoad

Availability


Flash Player 6.

Usage


myMovieClip.onLoad
Parameters


None.

Returns


Nothing.

Description


Event handler; invoked when the movie clip is instantiated and appears in the Timeline.

You must define a function that executes when the event is invoked.

Example


The following example defines a function for the onLoad method that sends a trace action to the Output window:

myMovieClip.onLoad = function () {
trace ("onLoad called");
};


-------------

without inside rollOver I can use that methods perfectly but it's just weird when place inside codes of button's handler . Is there a way out ? please help .

I want to init and do something with a clip created on button's events

thanks again

lostinbeta
July 23rd, 2003, 04:05 PM
Just remembered...

h88 posted this a while back...
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=10604

apache
July 23rd, 2003, 04:20 PM
thanks , now i understand why it is , but , sorry , can you help me one more time , I still can't figure out how to deal with my specific task .



- on button rollover :
- one empty mc created
- on empty mc load :
- load 1 pic and create one textfield
- on empty mc enterFrame :
- mess with loaded and created stuff inside it .



I do appreciate for your help .

lostinbeta
July 23rd, 2003, 04:24 PM
I usually keep all my actions on a frame.... soo...
buttonInstanceName.onRollOver = function() {
this.createEmptyMovieClip("container", depth);
container.loadMovie("pictureToLoad")
this.createTextField("instanceName", depth, x, y, width, height)
container.onEnterFrame = function(){
//do what you want
}
}

You will of course need to change the information to your own.

Also, for this you will need to read up on dynamic event handlers here...

http://www.kirupa.com/developer/actionscript/tricks/dynamicevent.asp

apache
July 23rd, 2003, 05:19 PM
I usually keep all my actions on a frame.... soo...

yup , i do the same :)

----

thanks , my fault , i didn't test with only onEnterFrame :sleep: so I thought all the handlers are unable to use , but it was only onload :+)

actually , the onEnterFrame doesn't work if we load the movie before it . I've found a walkaround, create a dummy ctroller mc , use its onEnterFrame to control other private mcs and txt :)

:thumb: thanks thanks and thanks

senocular
July 23rd, 2003, 05:36 PM
onLoad in the AS Dictionary capacity really only applies to class building with a class registered to a movieClip symbol. An instance of a movieclip associated with a class will, when attached, run the onLoad command.

This differs from the class constructor call (which also gets called as the movieclip is attached) in that the onLoad wont fire until any and all internal movieclip clips and actions have had a chance to be created/defined etc.

This class association also bypasses the problems h88 posted solutions for (well the biggest problem - that being onLoad in consideration with loaded swfs or jpgs).

... otherwise, in the circumstance initially posted, the onload is redundant because you can just assign properties to that empty clip right there after creating it. Theres no need to assign a function to do that. Just say test.whatever = whatever right after that line.

lostinbeta
July 23rd, 2003, 05:40 PM
What sen said.

Sen: You are too good at explanations. Are you for hire as a personal tutor?

senocular
July 23rd, 2003, 05:46 PM
Originally posted by lostinbeta
Sen: You are too good at explanations. Are you for hire as a personal tutor?

yes, yes I am. :) But Id do you for free =)

lostinbeta
July 23rd, 2003, 05:48 PM
Originally posted by senocular
yes, yes I am. :) But Id do you for free =)

:blush: Do you travel or would I have to come to you?

senocular
July 23rd, 2003, 05:52 PM
I could travel, philly aint no big deal. :)

apache
July 23rd, 2003, 06:04 PM
perfect explanation !


I could travel, philly aint no big deal.

how about asia Sen ? ;)

happy to be here with your help but it'd b e better if I have a teacher , a friend here at my right hand :)

senocular
July 23rd, 2003, 06:05 PM
thats a bit of a stretch ;)

lostinbeta
July 23rd, 2003, 06:05 PM
You know Sen... I may take you up on that offer ;)

I think I am at a wall with this AS stuff :(

h88
July 23rd, 2003, 06:08 PM
Originally posted by senocular
onLoad in the AS Dictionary capacity really only applies to class building with a class registered to a movieClip symbol. An instance of a movieclip associated with a class will, when attached, run the onLoad command.

AS Dictionary blows, It even didn't say that we should invoke the onLoad Event Handler on a MovieClip Subclass.

lostinbeta
July 23rd, 2003, 06:10 PM
Originally posted by lostinbeta
I think I am at a wall with this AS stuff :(



Originally posted by h88
AS Dictionary blows



And that might be the reason I am at a wall :P

senocular
July 23rd, 2003, 06:29 PM
Originally posted by h88
AS Dictionary blows, It even didn't say that we should invoke the onLoad Event Handler on a MovieClip Subclass.

Yeah. It does blow, but also, in terms of it being 'there' its just documenting its existance and not so much application which is kind of an after-thought in the dictionary often the example is based on simple (untested or properly documented) code.

But, it is there, and you can even get one called on _root by defining onLoad in the first frame there since it is the 'root' timeline and its definition and timeline initiation is a little different than that of other movieclps.

thoriphes
July 23rd, 2003, 06:33 PM
I always enjoyed the AS help files :-\

senocular
July 23rd, 2003, 06:35 PM
;) theres just a lot of typos and lack of clearity on things. But its how I learned so I can't complain :)

Lost, have you thought about getting any books?

thoriphes
July 23rd, 2003, 06:37 PM
i have one complaint though about the help files:

they're incorrect most of the time about what some of the functions return.

h88
July 23rd, 2003, 06:39 PM
Right.

lostinbeta
July 23rd, 2003, 06:41 PM
Originally posted by senocular
Lost, have you thought about getting any books?

Every day, but then the fact that i'm poor and can't afford one right now slaps me across the face then points and laughs.

senocular
July 23rd, 2003, 06:41 PM
ooo yeah there are a lot of returns missing. Even on some of the amendums they left them out. It is a mess :) a good reference to start, but nothing to live by

lostinbeta
July 23rd, 2003, 06:58 PM
I concur