Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:55:25+00:00 2026-05-22T14:55:25+00:00

package com.fladev.background { //import all classes import caurina.transitions.Tweener; import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.MovieClip;

  • 0
package com.fladev.background
{
    //import all classes
    import caurina.transitions.Tweener;
    import flash.display.Loader;
    import flash.display.LoaderInfo;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.display.StageAlign;
    import flash.display.StageDisplayState;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.FullScreenEvent;
    import flash.events.MouseEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;


public class MainClass extends Sprite 
{
    //create variables
    private var loaderMenu:Loader;
    private var loaderNames:Array = new Array ();
    private var loaderContents:Array = new Array ();
    private var loaderSlide:Loader;
    private var swfDisplayObject:DisplayObject;
    private var swfComObject:Object;
    private var xmlLoader:URLLoader = new URLLoader(); 
    private var xmlSlideLoader:URLLoader = new URLLoader();

    public function MainClass() 
    {
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;          
        stage.addEventListener(Event.RESIZE, stageResize);

        xmlLoader.addEventListener(Event.COMPLETE, showXML);
        xmlLoader.load(new URLRequest("navigation.xml"));

        //xmlSlideLoader.addEventListener(Event.COMPLETE, showSlideXML);
        //xmlSlideLoader.load(new URLRequest("slides.xml"));
    }

    function showXML(e:Event):void 
    {
        XML.ignoreWhitespace = true;

        var menuBtns:XML = new XML(e.target.data);
        var i:Number = 0;

        for ( i = 0; i < menuBtns.navItem.length(); i++ )
        {
            loaderMenu = new Loader();
            loaderMenu.name = menuBtns.navItem[i].name ;
            loaderMenu.load(new URLRequest(menuBtns.navItem[i].swfURL));
            loaderMenu.contentLoaderInfo.addEventListener(Event.COMPLETE, createSwfObjects);
        }
    }

    private function createSwfObjects(event:Event):void
    {
        var swfContent = event.currentTarget.content as MovieClip ;
        var swfName = event.currentTarget.loader ;

        navigationContainer.addChild(event.target.loader);
        showImage(swfContent);

        if ( swfName.name == 'topNavigation' )
        {
            swfContent.addEventListener("clickHandle",topNavigationClickHandler);
        }
    }

    private function topNavigationClickHandler():void
    {
        trace('Back to root');
    }

    private function showImage(navigationItem):void 
    {
        try
            {                       
                navigationItem.alpha = 0;
                Tweener.addTween(navigationItem, { alpha:1, time:1, transition:"easeOutSine" } );               
                navigationItem.smoothing = true;                        

            } catch (e:Error) { trace('Error no tweening'); };

        stageResize();
    }

    private function stageResize(e:Event=null):void
    {
        var centerImages:Array = new Array ( contentContainer, navigationContainer, backgroundImage ) ;

        backgroundImage.x = 0;
        backgroundImage.y = 0;
        backgroundImage.scaleX = backgroundImage.scaleY = 1;            

        if ((stage.stageHeight / stage.stageWidth) < backgroundImage.height / backgroundImage.width) {
            backgroundImage.width = stage.stageWidth;
            backgroundImage.scaleY = backgroundImage.scaleX;
        } else {
            backgroundImage.height = stage.stageHeight;             
            backgroundImage.scaleX = backgroundImage.scaleY;
        }

        for each ( var centered:MovieClip in centerImages )
        {
            centered.x = stage.stageWidth / 2 - centered.width / 2;
            centered.y = stage.stageHeight / 2 - centered.height / 2;   
        }
    }
}   
}

This is my code for the main.as.

And here my code for my loaded SWF on the maintimeline.

addEventListener(Event.ADDED_TO_STAGE, init);

function init(event:Event):void 
{
    trace('try dispatch');
    dispatchEvent(new Event("clickHandle",true));
}

Try dispatch works, but it does not get back to the main to fire up “Back to root”.
Any idea?

thx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:55:26+00:00Added an answer on May 22, 2026 at 2:55 pm

    As long as all movieclips dispatching events are added to the display list, this should work. This makes me think that perhaps the event listener being added is not working. Try adding a trace statement to the block of code as shown below:

    if ( swfName.name == 'topNavigation' )
    {
         trace("adding listener");
         swfContent.addEventListener("clickHandle",topNavigationClickHandler);
    }
    

    I expect that this if condition is failing, and thus your listener is never being created. Also, you need to add a function parameter to the callback method “topNavigationClickHandler” to accept the event as the callback parameter. You have not done this, and this is an error that would be thrown at runtime when the event was received and dispatched to the callback method. You havn’t seen this yet because your listener has never had to invoke the callback. So you’re gonna have to fix this code like so:

    private function topNavigationClickHandler(e:Event):void
    {
        trace('Back to root');
    }
    

    Also I just want to add that your if condition on setting this listener seems a bit redundant, since you already know you are expecting the navigation swf, because you’re explicitly loading it. Also I don’t believe the name property would be set like this. Typically the name is only set inside the IDE before compilation, and if it isn’t, it gets dynamically generated at runtime. What might be more useful is to check the URL of the loaded SWF to see if it contains “topNavigation” or whatever the swf name is. You can do this like so:

    var swfUrl:String = myLoader.contentLoaderInfo.url;
    if (swfUrl.search("topNavigation") != -1){
       //Match found, add listener for navigation
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.adam.etutorial { import flash.display.MovieClip; import flash.text.TextField; import flash.display.Sprite; import flash.text.TextFormat; import flash.display.Shape; public
I have the following custom event: package com.un.photoManager.events { import flash.events.Event; import mx.collections.ArrayCollection; public
This is my code: package com.example.testcode; import android.app.ListFragment; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader;
package com.services { import com.asfusion.mate.events.ResponseEvent; import com.events.navigation.DesgManagementEvent import flash.events.EventDispatcher; import mx.controls.Alert; public class UserManager
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
this is my custom dialog class: package com.WhosAround.Dialogs; import com.WhosAround.AppVariables; import com.WhosAround.R; import com.WhosAround.AsyncTasks.LoadUserStatus;
My code is not working: package com.foo.json; import javax.xml.bind.annotation.XmlRootElement; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @XmlRootElement
This is my FragmentListArraySupport.java package com.test.methods; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.ListFragment; import android.util.Log;
package com.crumbin.tabs; //java package import java.io.IOException; import java.util.ArrayList; import org.json.JSONException; import android.app.Activity; import android.app.AlertDialog;
package com.crumbin.tabs; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.client.HttpClient; import android.content.Context; import android.database.Cursor; import android.location.Location;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.