FlashComGuru Home InfluxisCDNImediaseeUvault
                                                                                       Forum Index | Active Topics | Register
                                                                                                          List Overview | List Archives
                                                                                                                           About this site | Advertise
 

home

Adobe AIR (11)
Applications (40)
Books & Training (11)
Collaboration (18)
Components (10)
Events (80)
Flash Player (35)
Flex (39)
FMS (110)
General (123)
Hosting (6)
Jobs (17)
Off topic (36)
OSMF (3)
Press Releases (23)
Site Check (11)
Tools (53)
Videos & Players (74)

Follow me on Twitter

 
This is a workaround supplied by Macromedia to fix a major issue that occurs when you load a Flashpaper2 swf into another Flash movie which contains Version2 UI components. The Flashpaper file causes the focusmanagement in the original movie to go ballistic and often renders the entire application unusable.

More details can be found in this thread.

The fix below comes straight from Macromedia engineering and should be applied EXCACTLY as is stated as otherwise compatibility with a new version of Flashpaper can not be guaranteed.

/*
This is a truly heinous fix for an awful problem.
The problem: FP2 content has an onMouseDown handler
that says, "if you clicked somewhere other than
what I think the currently-focused component is,
call Selection.setFocus(null)"
. This is bad because
calling Selection.setFocus(null) tends to completely
confuse the v2 FocusManager,with the net result being
that we end up "dropping" a mousedown event when FP2
content is embedded inside something that uses v2 components.
This "workaround" (actually, "hack") actually dives in
to the content (which we ASSUME TO BE FLASHPAPER)) and
actually replaces the offending onMouseDown handler with a
less-harmful one.

Yes, this is incredibly evil, but an expedient solution
given the nature and timing of the problem.

So that the problem may be fixed in a future version of
FlashPaper, we check for the (currently nonexistent)
member property of "hasSafeSelectionManagement" in the
FlashPaper.MainView class, and only apply this patch if
said member doesn't exist. If we improve FP2's focus
management in the future, we will define this member so
that this patch does not get applied. */

function fixFlashPaper2SelectionManagement(mc:MovieClip):Void {
   // note: it is ASSUMED that mc is a MovieClip that has    // had FlashPaper2 content loaded into it. You should ensure    // this is the case before calling this function. You    // only need to call this once, after the FlashPaper2 content    // is loaded.
if (typeof (mc.gMainView.m_mainMC.onMouseDown) == "function" && mc.gMainView.m_mainMC.hasSafeSelectionManagement === undefined) {
      mc.gMainView.m_mainMC.onMouseDown = function() {
         var fpfocus:MovieClip = _global.FPUI.Component.focusedComponent;
         if (fpfocus != null) {
            var hitFocused:Boolean = false;
            if (fpfocus._visible) {
               var pt:Object = new Object();
               pt.x = _root._xmouse;
               pt.y = _root._ymouse;
               _root.localToGlobal(pt);
               hitFocused = fpfocus.hitTest(pt.x, pt.y, true);
            }
            if (hitFocused == false) {
               // no. no. no. do NOT call this.                //Selection.setFocus(null);                if (typeof (fpfocus.onComponentKillFocus) == "function") {
                  fpfocus.onComponentKillFocus();
               }
            }
         }
      };
   }
}

So basically what you should do is add the above function to your movie and once the Flashpaper swf has finished loading call the function and pass a reference to the Flashpaper movie. If you take the Devcenter article as an example, you would pass a reference to 'dest_mc' and I suggest you do this on the line next to where the visibility of the dest_mc is set to true.

[...]
/ / Now show the document
dest_mc._visible = true;
fixFlashPaper2SelectionManagement(dest_mc); // applies bugfix
[...]
And there you go, finally a working solution. Thanks Macromedia, I wish every company was as approachable as this and I hope this won't change after you're part of Adobe.

Technorati Profile

Related Articles

Comments
[Add Comment]
This does seem to work fine.

My concern is that if this is the official word from Macromedia, why have they only shared it with FlashComGuru and not added it to the FlashPaper or Flash Support on the Macromedia web site?
# Posted By K___H | 11/16/05 3:34 PM
Fantastic! Been looking for something like this for a few months. Haven't tried it yet, but I will ASAP.

Thanks!
# Posted By bslice | 11/18/05 9:21 PM
Hi,

I have a problem. I am loading flashpaper swfs into a movieclip to create a flipbook. i need to add zoom feature in this. problem is the sample i modified has kept the movieclips on stage and i am unable to use v2scrollpane component as it doesnt work for movieclips on stage. As an alternative i tried loading the flipbook swf inside another movie which holds a scrollpane. Now the focus goes haywire when my flipbook swf is loaded inside the scrollpane. i tried using the function you had given but its not working. Can you please suggest any solution for this problem. Awaiting your reply.

Thanks and regards,
Pushpa
# Posted By Pushpa | 5/25/06 7:56 AM
sorry Pushpa I haven't got a fix for you. The app you've built sounds slightly complex but I guess it's fair to say that you have some sort of focusmanagement problem. Maybe you could try disabling fosumanagement altogether?
# Posted By stoem | 5/25/06 8:29 AM
thats great it has been driving me mad for ages.
I was due to release an early access version of my project today and I thought that I was going to have to chuck FlashPaper in the bin and start again.
# Posted By fleecie | 7/4/06 6:08 PM
This workaround totally works! Thanks a lot. Its great that the Macromedia dev team decided to publish this fix, but I am a little concerned how FlashPaper2 even made it to release with a *serious* bug like this. This isnt the first bug I've noticed with the 2.0 UI components. They really need to think about doing some QA over there because this stuff is costing us time and money.
# Posted By flashguru | 9/14/06 4:43 PM
Thank you!!!!!!!!
# Posted By Rolf Lid | 11/10/06 1:05 PM
Hey i am working on flashpaper embedding into a flex application throught ExternalInterface. I got thru darron schall's blog.But i m facing some issues with that..I want to put my own search functionality in that..I have one textbox named searchTextBox and there is one button called searchButton..Can anyone help me out in that.please help..
# Posted By Rajesh Bhadra | 2/8/07 8:39 AM
Dear users,

I need this fix too, because my flipbook is going crazy as it is right now. But I do not know where to put the code you added above. I have a index file, where the flipbook is loaded in. The Flashpaper 2 pages are loaded in this flipbook, of course. Can you please help me?

Greetings Fred.
# Posted By Fred | 3/7/07 1:34 PM
Hi guys,

Can someone tell me if it is possible to stream page by page a 10 MB FlashPaper SWF file?

Is a streaming server needed or can this be done internally in the SWF file?
# Posted By Sam | 3/27/07 6:37 PM
it was my understanding that fp streams page by page any way. it puts up the first page and streams the rest in behind
# Posted By fleecie | 3/28/07 5:03 PM
Can you let me know how FlashPaper SWF file of 10 MB can stream in Internet Explorer page by page.
It is happening in Opera,Mozilla but not IE.
# Posted By Sam | 3/28/07 7:25 PM
the FlashPaper when run from within the flash App exe works well with the fix , but doesn't when run the app is run in .swf format. Is there a way out, cause I need to run the swf file from an HTML page. An urgent help needed!
# Posted By Vengz | 3/30/07 12:44 PM
Absolutely fantastic guys!!! Even two years after the original post the same problem still persists and the above fix still works like a baby!!! FANTASTIC!!
# Posted By Rayden | 6/21/07 11:13 PM
pleas Help!!!!!!!!!!!!
I try to attach a TextField or MovieClip
to
flashPaper2.document_mc.pages_mc
...
but i have the feeling that flashPaper overide this functions even
ASSetPropFlags(path, null, 6, 1);
don`t help... :(
# Posted By Jenia | 10/24/07 3:53 PM
Hi. I'm trying to link/load external Flash Paper into a Flash movie but it won't display properly; came across this fix. Can anyone help with how to apply the fix- where does it go in the movie? Thanks.
# Posted By Ralph | 11/15/07 3:01 PM
I find that flash paper files that are free standing are not showing up in Internet explorer 7. They always worked like a dream before. Any idea as to what the problem is and how to fix it? Thanks for any help you can give me
# Posted By clay | 2/25/08 3:16 AM