The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 14 of 14

Thread: AS2 -> AS3 convert please

  1. #1

    AS2 -> AS3 convert please

    Hi, can you help me and convert that AS2 code to AS3: http://www.flashframer.com/how-to-cr...vigation-menu/ For you that is 5 minutes, and I'll can see differents.

    Thanks

  2. #2
    Oh cmon man .. :/

  3. #3
    Umm... how about you have a go at doing it yourself, ask questions if you get stuck and actually learn from the experience? That way you'll have a far more useful transfer of knowledge, as if someone else just does the work for you then you'll only skim the surface of learning.

    I mean seriously... if you're not prepared to put any effort in, why should someone else?

  4. #4
    ok my question is ho can I do something like that with addChild()
    _root.attachMovie("button","btn"+i,_root.getNextGi ghestDepth());
    "button" is an instance name of my movie clip which I want to use as a button in my menu.

    I tried to do something like that:

    var button:MovieClip = new MovieClip();
    addChild(button).name = "btn"+i;
    this.getchildByName("btn"+i).y = y_position;

    but I think that is creating a new MovieClip, and I want to use movieClip from library.. with instance name "button"

  5. #5
    var b:button = new button();
    addChild(b);
    b.y = 25;
    b.alpha = .7;

  6. #6
    thanks it's warking I think that now I can finish my menu

  7. #7
    hmm one question more. When I have
    function xmlLoaded(event:Event):void{
    ...
    for(var i:int = 0; i<xmlList.length(); i++)
    ...


    How can I load variable i in new function?

    function btnOver(e:Event):void
    {
    this.getChildByName("btn"+i).gotoAndPlay(2);
    }

  8. #8
    Quote Originally Posted by krystek1987 View Post
    hmm one question more. When I have
    function xmlLoaded(event:Event):void{
    ...
    for(var i:int = 0; i<xmlList.length(); i++)
    ...


    How can I load variable i in new function?

    function btnOver(e:Event):void
    {
    this.getChildByName("btn"+i).gotoAndPlay(2);
    }
    ActionScript Code:
    function xmlLoaded(e:Event):void {
    var len:Number = xmlList.length();
    for(var i:int=0; i<len; ++i) {
    somebtn.addEventListener(MouseEvent.MOUSE_OVER, btnOver);
    }
    }

    function btnOver(e:MouseEvent):void
    {
    e.target.gotoAndPlay(2);
    }


    Something like this?

  9. #9
    I'm trying to convert AS2 to AS3 code from link [top of the page] There are everything to understend "my" code

    if I do:
    e.target.gotoAndPlay(2);

    I have error:
    ReferenceError: Error #1069: Property gotoAndPlay not found on flash.text.TextField and there is no default value.
    at FF_Navigation_Menu_2_fla::MainTimeline/btnOver()


    that is my first AS code..
    thanks for helping

  10. #10
    do mouseChildren = false on your button since your textfields are sending the event atm.

  11. #11
    hmm, I find something like currentTarget and I see that it's working. Is it good ?
    But I'll read about mouseChildren

  12. #12
    yes, if "target" doesn't work, using "currentTarget" is perfectly acceptable - there is a distinct difference that I have yet to get clear within my head

  13. #13
    target is the object that flash has targeted for the event

    currentTarget is the object that is being called by the listener when the event occurs.

  14. #14
    again You have right :) Can you check this :)?

    ActionScript Code:
    var y_pozycja:Number = 0;
    var nazwy:Array = new Array();
    var linki:Array = new Array();
    var xml:XML;
    var xmlList:XMLList;
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest("links.xml"));
    xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

    function xmlLoaded(event:Event):void
    {
    xml = XML(event.target.data);
    xmlList = xml.children();

    for(var i:int = 0; i<xmlList.length(); i++)
    {
    nazwy.push(xmlList[i].@NAME);
    linki.push(xmlList[i].@LINK);

    var b:button = new button();
    addChild(b).name = "btn"+i;

    this.getChildByName("btn"+i).y = y_pozycja;
    y_pozycja += 25;

    this.getChildByName("btn"+i).blackTxt.Txt.text = nazwy[i];
    this.getChildByName("btn"+i).whiteTxt.Txt.text = nazwy[i];

    this.getChildByName("btn"+i).addEventListener(MouseEvent.MOUSE_OVER,btnOver);
    this.getChildByName("btn"+i).addEventListener(MouseEvent.MOUSE_OUT,btnOut);
    this.getChildByName("btn"+i).addEventListener(MouseEvent.CLICK,clicked);

    this.getChildByName("btn"+i).mouseChildren = false;
    }
    }

    function btnOver(e:MouseEvent):void
    {
    e.target.gotoAndPlay(2);
    }

    function btnOut(e:MouseEvent):void
    {
    e.target.gotoAndPlay(16);
    }

    function clicked(e:MouseEvent):void
    {
    var nazwa:String = e.target.name;
    var index:String = nazwa.substring(3,5);
    var request:URLRequest = new URLRequest(linki[index]);
    navigateToURL(request,"_blank");
    }
    Last edited by krystek1987; July 6th, 2008 at 08:51 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012