Problem of event complete SWFLoader/Image (bug?)

I have a SWFLoader in my application whose content is dynamically linked to a data grid for loading different images. Depending on the size of the new image I want to make some adjustments, etc. to the SWFLoader itself... is not important for now.

The problem is that if I take the width of the SWFLoader instance on the 'complete' event, it gives the value for the PREVIOUS imaging so my math function is useless.

Try this to see what I mean:
[Bindable]
public var imageSource:String;

private void temp (): void {}
mx.controls.Alert.show ("imgLoader.width:" + imgLoader.width);
}
..
< mx:Button click = "imageSource ="someImageURL"" / > "
< mx:SWFLoader id = "imgLoader" autoLoad = "true" source = "{imageSource}" complete = "temp ()" / > "


If you implement the code above, and assuming that imageSource is a string zero during initialization, you will get a value of '0' for the width of the imgLoader of the instance when you load a new image.

To work around this problem in Flex 1.5, I could use doLater (Thi, "temp"), but doLater seems to have been deleted in Flex 2.0.

My current work around is to change the above code as follows:

private void temp (): void {}
this.addEventListener ("enterFrame", blorch);
}
private void blorch(b:Event):void {}
mx.controls.Alert.show ("imgLoader.width:" + imgLoader.width);
this.removeEventListener ("enterFrame", blorch);
}

feels like a hack to me... is there any way to get this working without using the above functions? Kind of seems pointless to dismiss 'doLater' just to make me write a function that does essentially the same thing in Flex 2.0. I tried to use the 'resize' instead of 'complete' event and it works... If the loaded image is a different size than the previous. If the image is the same size (as is often the case in my application) then it does not work.

All of the Adobe/Macromedia, fellow developers suggestions?

Never thought to use "init", not sure it will work for images. The recommended solution is to subclass SWFLoader and override updateDisplayList

Tags: Flex

Similar Questions

  • Unable to access children in the init event or complete SWFLoader (numchildren =-1)

    Trying to put a label to a loaded flash (it is public), works fine if I call a timer and wait 2 seconds. Then I tried to do the 'right' way and it fails. (See the code example) Aparnently the flash charge (type FlashLoader) has a child (type SystemManager) with numChildren-1 at the event.

    Tried the init and event complete but no workie.
    http://livedocs.Adobe.com/Flex/3/langref/MX/controls/SWFLoader.html#summaryTableEvent
    init: dispatched when the properties and methods of a loaded SWF file are accessible.
    full: dispatched when the content is finished loading.

    Here is the code example:
    the file swf to load only fitted with a label with the id innerLabel and is called inner.swf

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML 'creationComplete = "init ();' >
    < mx:Script >
    <! [CDATA]
    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    Import mx.controls.Label;
    import flash.utils. *;
    Import mx.controls.SWFLoader;
    Import mx.core.Container;
    Import mx.core.FlexLoader;
    Import mx.managers.SystemManager;

    public var errors: Array = new Array();
    public var ld:SWFLoader = new SWFLoader();
    public void init (): void {}
    LD. Load ("Inner.swf");
    ld.addEventListener (Event.COMPLETE, setInnerLabel);
    this.addChild (ld);

    COMMENT THE ADDEVENTLISTENER METHOD AND UNCOMMENT THE LINES 3 AND IT WORKS
    LIKE A CHARM
    var t:Timer = new Timer(2000, 1);
    t.addEventListener (TimerEvent.TIMER, setInnerLabel);
    t.Start ();
    var doneTimer:Timer = new Timer (3000, 1);
    doneTimer.addEventListener (TimerEvent.TIMER, checkDone);
    doneTimer.start ();
    }
    public void checkDone(o:Object):void {}
    If (this.errors.length! = 0) {}
    trace (this.) Errors.Join ("\n"));
    } else {}
    trace ("done without error");
    }
    }

    public void setInnerLabel(o:Object):void {}
    var l:Label = getObjectsByProperty ("id", "innerLabel", Thi, null) [0] as Label;
    If (l == null) {}
    Errors.push ("unexpected innerLabel reduced label...");
    } else {l.text = "OK getbyid." ;}
    }
    {region for getElementById functions
    public void getObjectsByProperty (startFrom:DisplayObjectContainer,
    Public,
    PropertyValue:String,
    arrRet:Array = null): Array {}
    If (terminate == null) {}
    Terminate = new Array();
    }
    in the case where you pass a null value
    If (startFrom == null) {}
    return terminate;
    }
    If (startFrom.hasOwnProperty (propertyName)) {}
    If (startFrom [propertyName] = propertyvalue) {}
    arrRet.push (startFrom);
    }
    }
    trace ("HOW MANY of the CHILDREN:" + new String (startFrom.numChildren));
    traceElem (startFrom);
    for (var i: int = 0; i < startFrom.numChildren; i ++) {}
    traceElem (startFrom.getChildAt (i));
    If (startFrom.getChildAt (i) is DisplayObjectContainer) {}
    var tmpArr:Array = getObjectsByProperty (startFrom.getChildAt (i) as DisplayObjectContainer,
    propertyName, propertyvalue, terminate);
    Terminate = tmpArr;
    } else {}
    trace ("THE FOLLOWING WAS NOT A DISPLAYOBJECTCONTAINTER :");
    traceElem (startFrom.getChildAt (i));
    }
    }
    return terminate;
    }

    private void traceElem(elem:Object):void {}
    var x: XML = describeType (elem);
    var s:String = "got an item of the type:"+ x.attribute("name").toString ();.
    for (var i: int = 0; i < x.child("method").length (); i ++) {}
    If (x.child ("method") [i].attribute('name').toString () == 'getChildAt') {}
    s = s + "\n\t\t\tSupports getChildAt;
    }
    }
    for (i = 0; i < x.child("accessor").length (); i ++) {}
    If (x.child ("accessor") [i].attribute('name').toString () == 'numChildren') {}
    s = s + "\n\t\t\tSupports numChildren;
    s = s + "\n\t\t\tChildren:"+ new String ((elem.numChildren)); "
    }
    }
    trace (s);
    }
    } endregion
    []] >
    < / mx:Script >
    < / mx:Application >

    Common practice is to listen to the event APPLICATION_COMPLETE of SWFLoader.content once you get the COMPLETE event.  When loading a SWF Flex events really mean:

    Init: Enough of the properties and methods of SystemManager are available to implement the preloader, but we are waiting for the rest of the SWF file before we create all children whose main application:

    Full: All the bytes of the SWF file are downloaded, but we expect the event framework before the Framework 2 and the creation of the main application.

    So, your code would look more like:

    ld.addEventListener (Event.COMPLETE, completeHandler);

    function completeHandler(event:Event):void

    {

    ld.content.addEventListener (FlexEvent.APPLICATION_COMPLETE, setInnerLabel);

    }

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • Video stop event COMPLETE and action

    Hello, I am a demand for an exhibition and is necessary to restart to start itself if it is innactiv, for other visitors.

    I use

    addEventListener (Event.ENTER_FRAME, fl_EnterFrameHandler);

    function fl_EnterFrameHandler(event:Event):void

    {

    MovieClip (this.root) .gotoAndPlay (1, "Scene 1");

    }

    For most of my sequences, but when it's for the pages of the video, I have a question:

    I have a PlaybackFLV video on my 'sequence 4' and I want to return to the Sequence 1 when this video is over

    I tried whith, copy the following code:

    @

    Import fl.video.FLVPlayback;

    Import fl.video.VideoEvent;

    comp.addEventListener (Event.COMPLETE, videoComplete);

    function videoComplete(Event:Event):void {}

    MovieClip (this.root) .gotoAndStop (1, "Scene 1");

    }


    and


    Import fl.video.VideoEvent;

    video_secret_fab_EN.addEventListener (VideoEvent.COMPLETE, videoComplete);

    function videoComplete(Event:VideoEvent):void {}

    MovieClip (this.root) .gotoAndStop (1, "Scene 1");

    }

    But I always get this message:

    004, layer 'Actions', Image 28056 sequence, line 55, column 611119: Access the FULL maybe property not set through the static class type reference.

    Sequence 004, layer 'Actions', Image 28056, line 55, column 61 1119: access to the COMPLETE poperty can be undefined, via the type of reference a static class. (Sorry I'm french and not bilingual...)

    I am new to AS3 and I don't know what the problem is.

    I don't want to use a timer, because I have to integrate the same code for multiple video pages in my project.

    Thank you for your attention and hope you can help me.

    I think that the event Complete for FLVPlayback uses only the standard event class:

    import flash.events. *;

    comp.addEventListener (Event.COMPLETE, videoComplete);

    function videoComplete(e:Event):void

    {

    MovieClip (this.root) .gotoAndStop (1, "scene 1");

    }

  • Problem change event banners

    I can no longer change images banner event after I created an event. The first banner that I download when you create the event works, but it does not work if I try to change it later to a different banner image. I still not see either the original image or a white space appears instead. I tried with several types of files and in different browsers, but the problem persists. Everyone knows about this problem? Is it possible to fix it?

    Hello

    The problem has been identified as a bug and is now followed as bug # 3732149... We will provide a fix for the same thing soon.

    Thank you

    Sameer Puri

  • Mouse event to &lt; mx:Image / &gt; does not good localX, locally

    Hello

    I display an image in a titleWindow (as a popup). Now I'm events look on the image if the user clicks on the image then I display a popup at the corresponding position, but everytime that I click on the flex gives me contact information which is not where I clicked, it gives me the coords (localx, locally) further to the right. Is there a better way to manage events on the Image? Or is this a bug in adobe?

    PS I'm listening for the click event on the titleWindow nt on the image, but the result must be the same.

    LocalX/Y is relative event.target see so what's the event.target.  You

    can use localToGlobal and globalToLocal to convert any other objects

    coordinate space.

  • Need help with the earpiece of video events complete and twinkle in Web site button

    Hello.

    I'm building my first site flash on AS3 and I'm having some problems that I can't solve.

    Question No. 1:

    I have a video that plays on a page (frame) and want to go to the next page after the video is finished. It's pretty easy... I did a search for information and came to the top with something in the sense of (written in memory):

    instance.addEventListener (Event.COMPLETE, instancecomplete);


    function instancecomplete(event:Event):void {}

    gotoAndStop (3)
    }

    And it worked fine when the page loaded initially (it was the homepage), but after he moved to the next page, I clicked the button which takes back me to the homepage and what might happen is that the video would play for about 1 second and send me back to the next page. My assumption is that what is happening is in loading, the event listener is to see that the video does not play, assuming that it is finished, and it takes me to the next page. If this is true, is there a way to delay the eventlistener?

    Question 2:

    The buttons on my page of sparkle. I read on this topic, and I apparently it's because I'm on a mac. I checked on a PC and the flicker isn't here so it must be because im on a mac. On a forum I found the following line to fix it:

    btnHome_mc.buttonMode = true;

    The problem is... I never wrote this line, and if it is a code generated automatically, I can't find it in the scripts of action... so I'm stumped. Any help?

    I don't know what to say without seeing the code.

    Try to remove the listener:

    function onComplete(e:VideoEvent):void {}

    instance.removeEventListener (VideoEvent.COMPLETE, onComplete);

    }

  • my iphone 5s problem could not complete touch setup ID come back please and try again... I need to fix the problem

    my iphone 5s problem could not complete touch setup ID come back please and try again... I need solve the problem... Thank you

    Same question! Please help. I have installed 9.3.1 on iphone 5 s. error message"could not complete touch setup ID come back please and try again. »

  • Microsoft Fix it's error: "we're sorry, but we met an unexpected problem and cannot complete this diagnostic solution."

    When I try to run Microsoft Fix it automated troubleshooting services, I get - "we're sorry, but we met an unexpected problem and cannot complete this diagnostic solution." I ran before with great success, but it did work for awhile now. I can't understand how uninstall/reinstall, or how to solve why it does not work for me any more. I run Vista Home Premium. This problem has happened to others?

    original title: Microsoft Fix it does not work

    Hello

    Are your logged as administrator?

    What I wanted was otherwise, what issues are having you? Why do you need to run a Fixit? This could
    It does not lead to why the FixIt.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    I would also like to launch SFC and Chkdsk to ensure that corruption is disabled.

    Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN

    Enter this at the command prompt - sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Run checkdisk - schedule it to run at the next startup, then apply OK then restart your way.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    -----------------------------------------------------
    Perhaps an installation problem.

    Spotlight utility Windows Installer CleanUp Utility
    http://TechNet.Microsoft.com/en-us/magazine/2008.08.UtilitySpotlight.aspx

    Description of the Windows Installer CleanUp utility
    http://support.Microsoft.com/kb/290301

    Windows install 4.5 Redistributable
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=5A58B56F-60B6-4412-95B9-54D056D6F9F4&displaylang=en

    Hope these helps.
    Rob - bicycle - Mark Twain said it is good.

  • BlackBerry smartphones, I can't clear the log of events completely! Bold 9900

    I don't know why, but I just can't clear the log of events completely. I always stayed with two newspapers which cannot be erased. The two newspapers said: error and mistake. It's only affect the phone, but it's pretty disturbing with two newspapers cannot clear. I had tried to pull battery, resets and it can always be removed. Help, please.! My phone is the Bold 9900. Carrier is Singtel. Operating system to 7.1.0. HELP PLEASE! Thank you!

    Nope.

  • Hello, I have a problem and cannot complete the installation of the creative cloud, signature of the photographer, has been convfirmado and I can not download some applications, the latest CLOUDS INSTALLATION GIVES ERROR 201, I DO NOT KNOW HOW to RES

    Hello, I have a problem and cannot complete the installation of the creative cloud, signature of the photographer, has been convfirmado and I can not download some applications, the latest CLOUDS INSTALLATION GIVES ERROR 201, I DO NOT KNOW HOW to SOLVE IT MORE.

    Error 201 & 205 & 206 & 207 or several U43 errors

    -https://helpx.adobe.com/creative-cloud/kb/download-update-errors.html

  • Hello! I ve a problem with the complete abo... How can I activate illustrator after regulation time? the complete abo is already saved for the last month...

    Hello! I ve a problem with the complete abo... How can I activate illustrator after regulation time? the complete abo is already saved for the last month...

    [Duplicate message deleted... post the same question more than once is confusing... MOD]

    [This is an open forum, not a direct line to Adobe support... you have to wait a response]

    Hello

    Please see: -.

    https://helpx.Adobe.com/manage-account-membership/CC-reverts-to-trial.html

  • Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. All ideas

    Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. Any ideas?

    Not sure that you need a different directory.

    If you are working on a local computer, create a new site with all the same settings for local files and change the remote server settings to match the second server.

    This ensures you that there is no difference between the two websites.

  • I have a problem downloading the complete costume. Only 41% downloaded and it says this "Creative Cloud desktop could not be updated. (Error code: 50) Contact Customer Support

    I have a problem downloading the complete costume. Only 41% downloaded and it says this "Creative Cloud desktop could not be updated. () Error code: 50) Customer Contact

    Meresianak73703965 you use the steps listed in the "failed to install" error Creative Cloud Desktop application to reinstall the creative Cloud Desktop application?

  • Problem: the command to Interpret images appear dark grey

    Problem: the command to Interpret images appears in the black dark gray instaed when I RMB click on a sequence and the images of Int window does not open. All thoughts. Thank you

    RMB: right mouse b...?

    Footage interpreter working on images (audio/video/clips) not on sequences.

    If you want to know its settings light up in sequence/sequence settings or right-click on the sequence in the project window/sequence settings.

  • Problems with events in flex

    Hello. I'm a guy AS2 and Flash CS3. I started to learn AS3 and Flex 3 transfer. But I had a problem w / events in AS3. I add a component of the canvas to the scene. On this canvas, I added 3 different events: mouse down, mouse move, and mouse upwards. When the mouse move is triggered, it is impossible for me to get the mouse an event triggered, and vice versa, when the mouse upward is triggered, there is no way to get the mouse don't move event triggered. Is there someone to help this newbie with this problem? Any help will be much appreciated.

    Code:

    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML layout "="absolute">
    < mx:canvas id = "myCanvas" x = "50" y = "50" width = "500" height = "500" click = "event_1 (); "mouseMove ="event_2 (); "mouseUp ="event_3 (); ">
    < / mx:Canvas >

    < mx:Script >
    <! [CDATA]
    Import mx.controls.Alert;
    import flash.events. *;
    public function event_1 (): void
    {Alert.show ("first event fired") ;}}
    public function event_2 (): void
    {Alert.show ("Second event fired") ;}}
    public function event_3 (): void
    {(Alert.show ("troisième événement déclenché) ;}}
    < / mx:Script >
    < / mx:Application >

    The problem is that your event listeners are not properly configured.

    Your "p1" to listen for the 'mouseUp' event because he was managing the events at this time.

    This is your modified and test code, as long as the mouse is down on the canvas, she fares at the time where you 'mouseUp' stop drawing.


    http://www.Adobe.com/2006/mxml"layout ="absolute"creationComplete =" initApp () ">"

    import com.myDomain.Lines.Main;
    Mx.graphics import. *;
    Import mx.binding.utils.BindingUtils;
    import flash.events.IOErrorEvent;
    import flash.events.Event;
    import flash.display. *;
    Import mx.controls.Alert;
    import com.myDomain.Lines.Main;
      
    public var p1:Main;
    public var pre:Number = 0;
      
    public function initApp (): void
    {
    P1 = new Main();
    this.addChild (p1);
              
    }
     
    public function prepToDraw (): void
    {
    pre = 1;
    }
     
    public void startDraw(event:MouseEvent):void
    {
    if(pre == 1)
    {
    P1. Graphics.Clear ();
    var newColor:int = 0xFF00FF;
    var iniX:Number = mouseX;
    var iniY:Number = mouseY;
    var lineWidth:Number = 10;
    P1. Graphics.LineStyle (width of stripe, newColor);
    P1. Graphics.MoveTo (gwenael, iniY);
    }
       
    imageView.addEventListener (MouseEvent.MOUSE_MOVE, drawLine);
    P1.addEventListener (MouseEvent.MOUSE_UP, stopDraw);
    }
      
    public void drawLine(event:MouseEvent):void
    {
    if(pre == 1)
    {
    P1. Graphics.LineTo (mouseX, mouseY);
    }
    }
    public void stopDraw(event:MouseEvent):void
    {
    imageView.removeEventListener (MouseEvent.MOUSE_MOVE, drawLine);
    }
     
     
    ]]>


     
    mouseDown = "{startDraw (event)}" > "
     



    HTH,

    Kenny

Maybe you are looking for