A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: _global.identifier

  1. #1
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291

    _global.identifier

    I'm using KM version 4.4.5. The Supported Syntax reference has "_global.identifier" listed under Flash MX/Miscellaneous, but I've not been able to get it to work. In fact, using _global in the actionscript seems to kill execution when I preview in browser - just see the shapes in the first frame.

    I've searched the KM support forum on "global", but didn't find any relevant threads (might have skipped it if the subject was way off). Please let me know if this is a bug, future feature, if there is a KM alternative, whatever. I'm just teaching myself actionscript, no specific application in mind. Thanks!

    Peter

  2. #2
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    As far as I know,the _global instruction doesn't work in KoolMoves.
    For those interested: global variables and functions are visible to every timeline.
    Now for pherbrick: there're many methods to "emulate" or to "skip" this instruction.

  3. #3
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    _global works fine.

    Try for yourself.

    1. Create a new movie.
    2. Create a new movieclip with a dynamic textfield in it and an actionscript attached to the first frame to assign the variable MyVar to the textfield.
    3. Add a line of actionscript to the main timeline to set the variable MyVar to any text you like.

    If you will check now, nothing happens.

    4. Put _global. before MyVar in the script attached to the main timeline.

    Check again. Now the text should be displayed (it does on my computer)

  4. #4
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291
    Hi Wiley, I tried your sequence (used preview in Web Browser to execute the code), and the _global.MyVar in the main timeline failed to populate the dynamic text box in the movieclip.

    Because I'm a newbie, I tested my variable names, use of dynamic text, et.al. by putting 'MyVar = "Hello There";' in the MC and removing '_global.MyVar = "Hello There";' from the main timeline. That worked.

    Next I put '_global.bbb = 1;' in the main timeline, and the MC failed to execute (text box empty). In the testing I did before posting, it looked like _global kills code execution.

    I just did some further testing (three frames, a shape on frames 2, different shape on frame 3, AS code gotoAndPlay(2) on frame 3). _global is just stopping code execution for the frame it is on (frame 1); the frames still cycle and the AS code on frame 3 executes, so I see the empty dynamic text box on 1 and the shape on frame 2, over and over.

    So, like Necromanthus, _global isn't working for me. At least I'm in good company . This may be another one of those inconsistencies like the crashing issue. Hopefully it will clear up with the next release.

    Meanwhile, Necromanthus, once I get more knowledgeable, I'll see if I can't discover those emulations you mentioned. If I can't hack it (distinct possibility ) I'll scrutinize your downloads for clues on emulating _global. If I still can't hack it ( ) I'll post here again. Thanks!

    Peter

  5. #5
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    If you are exporting as flash 6, the correct syntax is
    _global.MyVar.text = "Hello There";

    The argument n to gotoAndPlay(n) is total keyframes plus tweens. It is best to use frame labels to avoid this problem.

  6. #6
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291
    Hi Bob,

    I'm wondering if when I upgraded from 4.4.3 to 4.4.5, if everything went well. Either I'm missing something obvious, or something minor is not working. No attack on you or anyone else, just confused and very appreciative of your help. Here are file names/dates/sizes to help in diagnosis. After that, a couple test cases where I couldn't get _global to work.

    (I can see in the preview that my blank spaces are removed. Oh well, so much for formatting.)

    koolmoves.exe 5,829 KB 7/3/04
    unins000.dat 21 KB 6/2/04
    History.txt 20 KB 5/28/04
    koolmoves.exe.4-4-3 5,829 KB 5/22/04
    koolmoves.chm 512 KB 4/1/04
    file_id.diz 1 KB 4/1/04
    pad_file.xml 12 KB 4/1/04
    unins000.exe 75 KB 2/25/04
    ReadMe.txt 4 KB 2/14/04
    license.rtf 5 KB 7/14/03
    Dav332.dll 351 KB 6/25/03
    Leon332.dll 86 KB 6/24/03
    Tips.tip 6 KB 6/19/03

    ----------------------------------------
    I started over from scratch, closed the KM session and started a new one. Working with a one frame fun file with a one frame moveclip. The movieclip is mc1 and contains a dynamic text box txt1. I have the following actionscript.

    1) On the main timeline in frame 1: _global.MyVar.text = "Hello There";
    2) In mc1 in frame 1: txt1 = MyVar.text;

    When I preview in web browser, all I get is the blank box.

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

    Next case. Forget trying to access info in a _global variable, just verifying that its presence stops execution of action script (on my computer).

    I went back to the looping 3 key frame file. It is supposed to loop between key frames 1 and 2 (thanks for the catch on frame numbering/labeling), the execution of gotoAndPlay() on key frame 3 indicates that the impact of _global on action script is limited to frame 1. I have the following actionscript on frame 1:

    _global.bobo.x = 1;

    function trace(stuff){
    debug += stuff + "\n";
    }

    trace("frame 1");


    With _global.bobo.x = 1 I don't see frame 1 in the dynamic text box debug. When I delete the line or comment it out, I do. Either way, I see the shape on frame 2 and not the shape on frame 3, so action scripting on frames other than 1 work. If I put _global.bobo.x = 1 below the trace function, the trace function still doesn't work.

    Again, thanks for your help. I think KM is a great application and I really appreciate its ease of use.

    Peter

  7. #7
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    Be patient, KM action script experts on this forum, most of which are located outside the USA, will figure this out.

  8. #8
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Well, here we go again

    First of all _global definitely should't stop the execution of the code that follows.
    _global is used a lot by the KComponents and it never has stopped the following lines from being executed.

    As for you example...
    1. Assigning a value to _global.MyVar.text doesn't make sense. Just assign a value to _global.MyVar
    2. _global forces flash 6 export. The correct flash 6 syntax for setting the text of a dynamic textfield txt1 is txt1.text = MyVar . If the variable MyVar in the movieclip isn't found, it checks if a global variable with the same name exists and uses the value of that variable. If you would set the variable before assigning it to txt1.text it will use the local variable. Only if you use txt1.text = _global.MyVar it always uses the global variable.

    Wilbert

  9. #9
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by w.brants
    _global works fine.
    This is great !
    I have to review my "KoolMoves AS black list" sometime ... LOL
    But now I have to "reborn" necromanthus.com ...
    cheers

  10. #10
    Senior Member pherbrick's Avatar
    Join Date
    Jul 2004
    Location
    Los Angeles
    Posts
    291
    Thanks Wilbert!

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