A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: getting movieclips from an external swf to load image on main stage

  1. #1
    Senior Member
    Join Date
    Aug 2008
    Posts
    137

    Lightbulb getting movieclips from an external swf to load image on main stage

    hello!

    ok, i have a question. is it possible to make a movie clip thats loaded externally, show a clicked image on the main swf stage??

    if it is possible, could someone please show me the source to do it??
    NO *****ASSNESS AROUND ME!!!!

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You could copy the pixels of the clicked image into a new BitmapData object then associate it with a new Bitmap object created on the stage.

    PHP Code:
    import flash.display.BitmapData;
    import flash.display.Bitmap;

    var 
    myClickedImageData:BitmapData = new BitmapData(img.widthimg.height);
    myCilckedImageData.draw(img);

    //then on the stage.
    var bitmapOfClicked:Bitmap = new Bitmap(myClickedImageData);
    addChild(bitmapOfClicked); 

  3. #3
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    jAQUAN,

    thanks for the speedy reply. the code that you gave me, would that have to be loaded into both the swf containing the images and the main stage, or just the main stage?
    NO *****ASSNESS AROUND ME!!!!

  4. #4
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I imagine you could record the clicked image data into an object created by the loaded swf and pass a reference to it to a function in the main stage that would complete the process. I've never actually done it so maybe one of the other as3 wizards here could clarify.

  5. #5
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    bump?? anyone else??
    NO *****ASSNESS AROUND ME!!!!

  6. #6
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    I'm unclear on what you're trying to do...load a swf and then access an image inside it?

  7. #7
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    exactly. load an swf that has a bunch of images and access them in the main swf... if that's possible???
    NO *****ASSNESS AROUND ME!!!!

  8. #8
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    All you need to do is get a handle on the image...so if you had one in the loadee named pic1 you could add it to the main stage like this:

    root.addChild(loadee.getChildByName( "pic1" ));

  9. #9
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    nez,

    could i??

    Code:
    root.addChild(gLoader.iMC.getChildByName("pic1"));
    i guess i am worried about depth. because in essence the images i am trying to access are basically "two steps down" inside the gLoader.. e.g.

    Mainstage(gLoader ( MC ( imgContainerMC (img) ) ) )
    NO *****ASSNESS AROUND ME!!!!

  10. #10
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    That should work fine...

  11. #11
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    nez,

    i tried it your way, i am keep getting an error 1061 at that line.
    is there a way to hard code the destination being the main.swf???
    Last edited by maximillion; 10-03-2008 at 01:34 PM.
    NO *****ASSNESS AROUND ME!!!!

  12. #12
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    addChild(gLoader.getChildByName("iMC").getChildByN ame("pic1"));

  13. #13
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    Code:
    galleryMC.award01Btn.addEventListener(MouseEvent.CLICK, showImage);
    
    function showImage(evt:MouseEvent):void{
    	addChild(Gallery.getChildByName('pic'));
    	trace('it loaded!!');
    	
    	}
    Last edited by maximillion; 10-03-2008 at 02:43 PM.
    NO *****ASSNESS AROUND ME!!!!

  14. #14
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Please post the code where you load the swf...

  15. #15
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    BUMP anyone else?!?!?! this thing is really frustrating me!!! PLS HELP
    NO *****ASSNESS AROUND ME!!!!

  16. #16
    Senior Member
    Join Date
    Aug 2008
    Posts
    137
    ok, so i dont think i worded this properly. cause after finally getting the darned thing to load it loads in the external swf... i need it to load in the main swf....


    Code:
    galleryMC.award01Btn.addEventListener(MouseEvent.CLICK, showImage);
    
    function showImage(evt:Event){
    	var request:URLRequest = new URLRequest("award1.swf");
    	var loader:Loader = new Loader();
    
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    
    function loadProgress(event:ProgressEvent):void {
    	var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
    		percentLoaded = Math.round(percentLoaded * 100);
    		trace("Loading: "+percentLoaded+"%");
    }
    function loadComplete(event:Event):void {
    	trace("Complete");
    }
    
    loader.load(request);
    root.addChild(loader);
    NO *****ASSNESS AROUND ME!!!!

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