A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: html event function problem

Threaded View

  1. #1
    Member
    Join Date
    Feb 2007
    Posts
    53

    html event function problem

    Hi there, over the past couple of days ive been building a model of something in hopes of recreating it in my actual project, and have had the good fortune to recieve excellent answers from some of you guys which solved all my models problems, yet although ive learned a bit about it, i cant seem to implement them in my actual project, as the models were a bit simpler than the project and i erringly thought it wouldnt matter, but it does.. as3 has turned me from an intermediate writer of actionscript to a nitwit writer of actionscript.. so ive decided to abandon the models, Id really appreciate some help. Im trying to pass internal as3 commands through an xml-driven scroller widget which gets loaded into a 5th level holderMC (5th MC down from root) to an MC on the 3rd level down from root (2 MC's above holderMC) as event functions from htmltext.. basically im trying to get an external movieclip @ root.activezoom.menu2.activeclean.holderMC to talk to a clip in root.activezoom.menu2.vib... im at wits end..

    im loading the scrollbar widget into the 5th level (into holderMC) from the 4th like so:


    var swfLoader:Loader = new Loader();
    holderMC.addChild(swfLoader);
    var bgURL:URLRequest=new URLRequest("scroller.swf");
    swfLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, loadProdComplete);
    swfLoader.load(bgURL);
    function loadProdComplete(e:Event):void {
    trace("file loaded");
    }

    in my xmlfile, there are multiple event functions in htmltext passed to the scroller

    <description><![CDATA[<a href='event:specialFunction'>click for black box</a><br></br><a href='event:redbox'>click for redbox</a><br></br><a href='event:yellowbox'>click for yellowbox</a>]]></description>


    the scrollers textfield has this listener attached to it:

    descriptionText.addEventListener(TextEvent.EVENT, linkHandler);


    which referrs to this function, also in the scroller.swf

    function linkHandler(linkEvent:TextEvent):void {
    switch (linkEvent.text) {
    case "specialFunction":
    magicalFunction();
    break;
    case "redbox":
    startredbox();
    break;
    case "yellowbox":
    startyellowbox();
    break;
    default:
    trace(linkEvent.text);
    }
    }


    which referr to these secondary functions, also in the scroller.swf:

    function magicalFunction(event:TextEvent):void {
    trace(event.currentTarget.stage.getChildAt(3));
    event.currentTarget.stage.getChildAt(3).clip.gotoA ndPlay(2);
    }

    function startredbox(event:TextEvent):void {
    trace(event.currentTarget.stage.getChildAt(3));
    event.currentTarget.stage.getChildAt(3).redbox.got oAndPlay(2);
    }

    function startyellowbox(event:TextEvent):void {
    trace(event.currentTarget.stage.getChildAt(3));
    event.currentTarget.stage.getChildAt(3).yellowbox. gotoAndPlay(2);
    }

    when i publish the scroller.swf i get error 1136..which translates into wrong amount of arguments. 1 neccesary. The problem is referring to the functionnames before the breaks in the linkhandler function..

    your help would be hugely appreciated!

    edit: in this post, the secondary functions appear to have a syntax error in their gotoAndPlay commands.. these dont appear in the actual code.. (strange i cant get rid of em if i retype it here either)
    Last edited by jan33; 02-08-2010 at 09:40 AM.

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