A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Add a skip intro btn to AS3 preloader

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    3

    Add a skip intro btn to AS3 preloader

    Hello, bit of a AS3 newbie here.

    I've created a preloader.swf that (when loaded) loads an external swf. I would also like to add a skip intro btn, but when I do, the preloader seems to loop over and over (blinking - I know, high tech).

    This is the preloader code. I have it in the first frame of the preloader.swf:

    stop();

    var myRequest:URLRequest = new URLRequest("flash/index.swf");
    var myLoader:Loader = new Loader();

    myLoader.load(myRequest);

    myLoader.contentLoaderInfo.addEventListener(Event. OPEN,showPreloader);
    myLoader.contentLoaderInfo.addEventListener(Progre ssEvent.PROGRESS,showProgress);
    myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE,showContent);

    var myPreloader:Preloader = new Preloader();

    function showPreloader(event:Event):void {
    addChild(myPreloader);
    myPreloader.x = stage.stageWidth/2;
    myPreloader.y = stage.stageHeight/2;
    }

    function showProgress(event:ProgressEvent):void {
    var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
    myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
    myPreloader.bar_mc.width = 198 * percentLoaded;
    }

    function showContent(event:Event):void {
    removeChild(myPreloader);
    addChild(myLoader);
    }


    On it's own, it works fine.

    Then I added a MC with the instance name "skipIntro", and then added this script to the script above:

    skipIntro.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_2);

    function fl_ClickToGoToWebPage_2(event:MouseEvent):void
    {
    navigateToURL(new URLRequest("/residences/residences.php"), "_blank");
    }


    Any help? Thanks.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    I really don't understand the relationship between the preloader and the button...
    When you add the button and publish the SWF, do you get any errors?
    And when you test it directly from the Flash IDE?
    Does the problem occur immediately or only after you click the button?
    Is there a link where one can have a look at?

    Not the cause of the problem, but why use "_blank" instead of "_self"?

    Use AS tags please.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    3
    Hi, thanks for the post...
    I've got it figured out

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