6 Replies Latest reply on Dec 15, 2006 5:05 PM by kglad

    asfunction, cursor states, and moviclips...oh my

    flashWannaBe Level 1
      Hello all. I've ran into a bit of a snag and I'm thinking the obvious is sitting right in front of me...

      I have a dynamic movieclip that is created to serve as a container for a dynamically created textfield. The textfield has html text. Within that html text is an asfunction to call a method. Code is posted below:

      MovieClip(this.createEmptyMovieClip("textOneContainer_mc", this.getNextHighestDepth());
      TextField(textOneContainer_mc.createTextField("textOneField", textOneContainer_mc.getNextHighestDepth(), 10, 10, 300, 30));

      // Method triggered from asfunction call from html text
      textOneContainer_mc.launchGlossary = function(arg){
      trace("Launch Glossary Method Hit, Glossary Word: "+arg);

      textOneContainer_mc. textOneField.html = true;
      textOneContainer_mc. textOneField.htmlText = htmlString_str;

      Now the issues are:
      1. if applied, textOneContainer_mc onRollOver, onRollOut, onRelease, and etc seem to not allow the asfunction to be called
      2. i'm using custom cursors, which work fine...however, the system hand cursor appears over the word I have linked via asfunction. I've tried using the useHandCursor = false MovieClip property, but it still appears.

      I hope this makes sense, i'm a little dumbfounded on this one. The last thing I want to do is to do a split on the html text and put each word in it's own MovieClip just to achieve what the asfunction already does.
        • 1. Re: asfunction, cursor states, and moviclips...oh my
          kglad Adobe Community Professional & MVP
          the first few lines of your code look like actionscript, but, i doubt, that code would compile and it certainly wouldn't do anything. copy and paste your code.

          but once you correct your code you're still going to have a problem: you can't define mouse handlers for a parent movieclip and expect a child textfield to detect mouse events. the parent movieclip will intercept the mouse events.

          to remedy, either don't use a parent movieclip, don't use mouse handlers for your parent movieclip or use a hitTest and various mouse state detectors to fake rollover, rollout and onrelease handlers.

          • 2. Re: asfunction, cursor states, and moviclips...oh my
            flashWannaBe Level 1

            // Store Text and Audio Data From XML
            var pagetext_xmlnodeOne:XMLNode = matchSiblingNode(_parent.currentPage_xmlnode.firstChild,"instructionalTextOne");
            var pagetext_xmlnodeTwo:XMLNode = matchSiblingNode(_parent.currentPage_xmlnode.firstChild,"instructionalTextTwo");
            var swf_xmlnode:XMLNode = matchSiblingNode(_parent.currentPage_xmlnode.firstChild,"externalSwfFile");
            var swfLocation:String = swf_xmlnode.attributes.swfFilePath;
            var textOneAudio:String = pagetext_xmlnodeOne.attributes.audioPath;
            var textTwoAudio:String = pagetext_xmlnodeTwo.attributes.audioPath;
            var titleText:String = _parent.currentPage_xmlnode.attributes.title;
            var textOne_str:String = pagetext_xmlnodeOne.firstChild.nodeValue;
            var textTwo_str:String = pagetext_xmlnodeTwo.firstChild.nodeValue;

            trace("///// Title Text: "+titleText+" /////////////////////////////////////////////////////////");

            //Loads SWF File
            function loadSWF(externalSwfLocation:String){
            var swfFile:Boolean = false;
            //Object to Load SWF File
            var mcLoader:MovieClipLoader = new MovieClipLoader();
            var mclListener:Object = new Object();
            if (externalSwfLocation != undefined){
            if (externalSwfLocation.indexOf(".swf") > 0){
            swfFile = true;
            trace(".SWF Path: "+externalSwfLocation+" Target Clip: "+mediaSWF_mc);
            image_mc = mediaSWF_mc;
            } else {
            //In the Event There is No SWF File, loadText Method Called
            trace("No SWF File to Load, loadText Method Being Called");

            mclListener.onLoadComplete = function(){
            trace(".swf Loaded Successfully");
            trace("loadText Method Being Called");
            mclListener.onLoadInit = function(target_mc:MovieClip){
            //Adjust SWF
            var pictH:Number = target_mc._height;
            var pictW:Number = target_mc._width;
            var pictX:Number = target_mc._x;
            var pictY:Number = target_mc._y;
            if (swfFile){
            pictH = Number(swf_xmlnode.attributes.swfHeight);
            pictW = Number(swf_xmlnode.attributes.swfWidth);

            pictX = Number(swf_xmlnode.attributes.swfX);
            } else { pictX = 0 };

            pictY = Number(swf_xmlnode.attributes.swfY);
            } else { pictY = 0 };
            //Adjust to New SWF Size and _x/_y Cooordinates
            mediaSWF_mc._width = pictW;
            mediaSWF_mc._height = pictH
            mediaSWF_mc._x = pictX;
            mediaSWF_mc._y = pictY;
            mediaSWF_mc._alpha = 0;

            // loadText Method
            // Creates Movieclips to Store Textfield Data
            function loadText(textOne_str:String, textTwo_str:String, textOneAudio:String,textTwoAudio:String){
            var txtOneY_num:Number = pagetext_xmlnodeOne.attributes._y;
            } else {
            var txtOneY_num:Number = 0;
            var txtOneBlock:String = pagetext_xmlnodeOne.attributes.textBlock;
            var vlaInstrOneTxt_mc = MovieClip(this.createEmptyMovieClip("vlaInstrOneTxt_mc", this.getNextHighestDepth()));
            var vlaInstrOne_txt = TextField(vlaInstrOneTxt_mc.createTextField("vlaInstrOne_txt", vlaInstrOneTxt_mc.getNextHighestDepth(), 8, txtOneY_num, 0, 0));
            var vlaInstrOneFld = vlaInstrOneTxt_mc.vlaInstrOne_txt;
            vlaInstrOneFld.autoSize = "left";
            vlaInstrOneFld.embedFonts = true;
            vlaInstrOneFld.selectable = false;
            vlaInstrOneFld.multiline = true;
            vlaInstrOneFld.border = false;
            vlaInstrOneFld.html = true;
            vlaInstrOneFld.htmlText = textOne_str;
            vlaInstrOneTxt_mc.enabled = false;
            vlaInstrOneTxt_mc._alpha = 0;

            vlaInstrOneTxt_mc.launchGlossary = function(arg){
            trace ("You clicked me!Argument was "+arg);

            var txtTwoY_num:Number = pagetext_xmlnodeTwo.attributes._y;
            } else {
            var txtTwoY_num:Number = 0;
            var txtOneBlock:String = pagetext_xmlnodeOne.attributes.textBlock;
            var vlaInstrTwoTxt_mc = MovieClip(this.createEmptyMovieClip("vlaInstrTwoTxt_mc", this.getNextHighestDepth()));
            var vlaInstrTwo_txt = TextField(vlaInstrTwoTxt_mc.createTextField("vlaInstrTwo_txt", vlaInstrTwoTxt_mc.getNextHighestDepth(), 8, txtTwoY_num, 0, 0));
            var vlaInstrTwoFld = vlaInstrTwoTxt_mc.vlaInstrTwo_txt;
            vlaInstrTwoFld.autoSize = "left";
            vlaInstrTwoFld.embedFonts = true;
            vlaInstrTwoFld.selectable = false;
            vlaInstrTwoFld.multiline = true;
            vlaInstrTwoFld.border = false;
            vlaInstrTwoFld.html = true;
            vlaInstrTwoFld.htmlText = textTwo_str;
            vlaInstrTwoTxt_mc.enabled = false;
            vlaInstrTwoTxt_mc._alpha = 0;

            var vlaInstrText_fmt:TextFormat = new TextFormat();
            vlaInstrText_fmt.font = "VAGRoundedRegular";


            // Make Sure Text Stays Within Bounds
            if(pagetext_xmlnodeOne.attributes.textBlock == "Left"){
            if(vlaInstrOneFld._width > 375){
            vlaInstrOneFld.wordWrap = true;
            vlaInstrOneFld._width = 375;
            } else {
            if(vlaInstrOneFld._width > 670){
            vlaInstrOneFld.wordWrap = true;
            vlaInstrOneFld._width = 670;

            if(pagetext_xmlnodeTwo.attributes.textBlock == "Left"){
            if(vlaInstrTwoFld._width > 375){
            vlaInstrTwoFld.wordWrap = true;
            vlaInstrTwoFld._width = 375;
            } else {
            if(vlaInstrTwoFld._width > 670){
            vlaInstrTwoFld.wordWrap = true;
            vlaInstrTwoFld._width = 670;

            // Call Transitions Clip for TextFields
            trace("All Textfield Clips Loaded, Transitions and Audio Will Now Take Place");

            // Apply Transitions Clip to First TextField
            function transitionInFirstTxtClip(){
            fadeIn(vlaInstrOneTxt_mc, 7, this, "readFirstAudioClip");
            } else {
            trace("No Instructional Text 1 Found, calling readFirstAudioClip");

            // Play Audio Related to First TextField
            function readFirstAudioClip(){
            playSFX(textOneAudio, this, "nextClipTransition");
            vlaInstrOneTxt_mc.enabled = true;
            } else {
            trace("No Instructional Text 1 Audio File Found, calling nextClipTransition");

            // Apply Transtions Clip to Second TextField
            function nextClipTransition(){
            fadeIn(vlaInstrTwoTxt_mc, 7, this, "readSecondAudioClip");
            } else {
            trace("No Instructional Text 2 Found, calling readSecondAudioClip");

            /// Play Audio Related to Second TextField
            function readSecondAudioClip(){
            playSFX(textTwoAudio, this, "displaySwfFile");
            vlaInstrTwoTxt_mc.enabled = true;
            } else {
            trace("No Instructional Text 2 Audio File Found, calling displaySwfFile");

            // Display SWF File
            function displaySwfFile(){
            fadeIn(mediaSWF_mc, 1, this, "applyCursorStates");
            } else {
            trace("No SWF File Found, calling applyCursorStates");

            function applyCursorStates(){
            // Apply MovieClip Methods to TextField
            vlaInstrOneTxt_mc.onRollOver = vlaInstrTwoTxt_mc.onRollOver =function(){

            vlaInstrOneTxt_mc.onRollOut = vlaInstrTwoTxt_mc.onRollOut =function(){

            vlaInstrOneTxt_mc.onRelease = function(){

            vlaInstrTwoTxt_mc.onRelease = function(){

            var __soundFX:Sound = new Sound();
            var audioFlag:Boolean = false;
            function playSFX(audioClip:String, targ:MovieClip, onComplete:String):Void {
            __soundFX.onLoad = function(success:Boolean){
            audioFlag = true;
            trace("Audio Clip: "+audioClip+" is Now Playing");
            } else {
            audioFlag = false;
            trace("Audio Clip Stopped");
            var args = arguments.slice(3, arguments.length);
            __soundFX.onSoundComplete = function() {
            audioFlag = false;
            trace("Audio Clip Completed");
            trace("Audio "+audioClip+" Completed, Calling onComplete Method: "+onComplete);
            } else {
            trace("Audio Completed, no onComplete Method to Call");

            // Stop Audio Method
            function stopSFX():Void {
            trace("__PLAYER: AUDIO CLIP STOPPED");

            • 3. Re: asfunction, cursor states, and moviclips...oh my
              kglad Adobe Community Professional & MVP
              there's no textOneContainer_mc in that code. copy and paste just the relevent parts of your code.
              • 4. Re: asfunction, cursor states, and moviclips...oh my
                flashWannaBe Level 1
                vlaInstrOneTxt_mc and vlaInstrTwoTxt_mc are the moviclips in which the textfields are contained in. The reason why there isn't textOneContainer_mc in this code is because I wanted to avoid having to post this all up and just give a relevant example.
                • 5. Re: asfunction, cursor states, and moviclips...oh my
                  flashWannaBe Level 1
                  The only other alternative I see at this point would be to put each word in its own separate movieclip. The reason being is because there may be a word within the sentence that contains a "glossary" word. That word, when clicked, need to luanch a glossary. However the other words, when clicked, will have an audio associated to it. At the same time, if I put each word in a separate movieclip, I lose the html font formatting. It's kind of a bum deal...a lot of work to put each word in a movieclip, position the movieclips so that it still looks like a sentence(s). I'm trying to find a work around on this, but no such luck.
                  • 6. Re: asfunction, cursor states, and moviclips...oh my
                    kglad Adobe Community Professional & MVP
                    that code will compile but nothing is accomplished by using MovieClip() as a function and TextField() as a function.

                    so, you're left with the problem and solutions i gave in my above message.