Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Torres90
Posts: 102
Registered: ‎01-12-2011
My Device: Blackberry Playbook
Accepted Solution

how to make a .swf behaving like an image file?

[ Edited ]

Hello there. I'm currently working on an app, which let user interact an object. When user click on the object,it'll move as a response. Here's my sample code

private var Ball:Image=new Image();

public function myApp()
		{Ball.addEventListener(MouseEvent.CLICK,flyBall);
                 Ball.setImage("ball.png");
                 Ball.setPosition(0,0);
                 addChild(Ball);
		}

private function flyBall(e:MouseEvent):void
		{
                  Ball.removeEventListener(MouseEvent.CLICK,flyBall);
                   Ball.addEventListener(Event.ENTER_FRAME,moveBall);
		}

		private function moveBall(e:Event):void
		{
			Ball.x+=1;
		}

 The code works for one image file. However, I wanted to replace ball.png with a .swf file, and so far i've tried loader, but loader doesn't allow me to set it's position. Is there any possible way to load one .swf file inside an image object? Or is there any other way to load .swf which enable me to move it around as in the code?

Click "like" if my reply helps and click "Accept as Solution" if it solves your problem!

twitter @Twopinstudio
my vendor page https://appworld.blackberry.com/webstore/vendor/7126/?lang=en
Please use plain text.
Retired
rmasroor
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520

Re: how to make a .swf behaving like an image file?

Hello Torres,

 

Can you clarify on your statement "loader doesn't allow me to set it's position." Since the Loader class is inherited from the parent DisplayObject, you can set it's position via x and y values.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html

 

Looking forward to your reply.

 

 

Raihan Masroor
BlackBerry Development Advisor
Please use plain text.
Developer
Torres90
Posts: 102
Registered: ‎01-12-2011
My Device: Blackberry Playbook

Re: how to make a .swf behaving like an image file?

The loader class actually has a .x and .y function, which sets the position. The Img class has .x and .y function as well as a setPosition(), which is more convenient and easier. Still the .x and .y works as well. Thanks! :smileyhappy:
Click "like" if my reply helps and click "Accept as Solution" if it solves your problem!

twitter @Twopinstudio
my vendor page https://appworld.blackberry.com/webstore/vendor/7126/?lang=en
Please use plain text.
Developer
Torres90
Posts: 102
Registered: ‎01-12-2011
My Device: Blackberry Playbook

Re: how to make a .swf behaving like an image file?

One more question, is there any function for .swf files which is equivalent to .bitmapdata of image file?

 

For example, I normally set an Image variable with

Image1.setImage((ImagePreLoad.getChildAt(0) as Bitmap).bitmapData);  because if I use Image1.setImage("path") it'll set the image as well, but with a noticeable lag.

 

Now I got a loader variable, which essentially uses .load(UrlReq) to load a .swf object. I've initialized another pre set .swf variable which is running on the background. Is there any way to access it's .swf file similar to the bitmapdata of image file?

Click "like" if my reply helps and click "Accept as Solution" if it solves your problem!

twitter @Twopinstudio
my vendor page https://appworld.blackberry.com/webstore/vendor/7126/?lang=en
Please use plain text.