PDA

View Full Version : trace function not work


monior
03-02-2008, 02:46 PM
Hi ,

I am new in flash,

I make a movie clip in main timeline, its name circle. In circle time line, frame1 I put a variable.Then in main time line (_root) I try to trace the variable.The code is :
trace(circle.myVar)

but it doesnt work, output is : undefined.

However if I trace it using button which I put in main time line, the code is :

on(release){
trace(circle.myVar)
}

it works. So what wrong with it,

raskolnikov
03-06-2008, 07:56 AM
the reason why trace in the main timeline shows "undefined" is coz when the trace action was called at runtime, the button var hasn't be defined yet.

your button trace worked because by then -once the button appears- myVar in circle mc has been defined. confused?

in the flash file, i put trace in frame 2 with your syntax and -viola- it works. unless u write a code telling flash to trace only after the circle is loaded at frame 1, u can get the trace function to work properly. i guess, u can used create new movieclip to solve this issue should u need to have trace action on frame 1. good luck
raskol